Skip to content

Commit 22c127e

Browse files
authored
Unrolled build for rust-lang#134024
Rollup merge of rust-lang#134024 - jieyouxu:ui-cleanup-2, r=Nadrieril Advent of `tests/ui` (misc cleanups and improvements) [2/N] Part of rust-lang#133895. Misc improvements to some ui tests immediately under `tests/ui/`. Best reviewed commit-by-commit. Please see individual commit messages for some further rationale and change summaries. r? compiler
2 parents 4d669fb + 754dec3 commit 22c127e

14 files changed

+176
-63
lines changed

Diff for: tests/ui/assign-imm-local-twice.rs

-13
This file was deleted.

Diff for: tests/ui/assoc-lang-items.rs

-21
This file was deleted.

Diff for: tests/ui/assoc-oddities-3.rs

-13
This file was deleted.

Diff for: tests/ui/atomic-from-mut-not-available.rs

-7
This file was deleted.

Diff for: tests/ui/borrowck/assign-imm-local-twice.fixed

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Check that we do not allow assigning twice to an immutable variable. This test also checks a
2+
//! few pieces of borrowck diagnostics:
3+
//!
4+
//! - A multipart borrowck diagnostics that points out the first assignment to an immutable
5+
//! variable, alongside violating assignments that follow subsequently.
6+
//! - A suggestion diagnostics to make the immutable binding mutable.
7+
8+
//@ run-rustfix
9+
10+
fn main() {
11+
let mut v: isize;
12+
//~^ HELP consider making this binding mutable
13+
//~| SUGGESTION mut
14+
v = 1;
15+
//~^ NOTE first assignment
16+
println!("v={}", v);
17+
v = 2;
18+
//~^ ERROR cannot assign twice to immutable variable
19+
//~| NOTE cannot assign twice to immutable
20+
println!("v={}", v);
21+
}

Diff for: tests/ui/borrowck/assign-imm-local-twice.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Check that we do not allow assigning twice to an immutable variable. This test also checks a
2+
//! few pieces of borrowck diagnostics:
3+
//!
4+
//! - A multipart borrowck diagnostics that points out the first assignment to an immutable
5+
//! variable, alongside violating assignments that follow subsequently.
6+
//! - A suggestion diagnostics to make the immutable binding mutable.
7+
8+
//@ run-rustfix
9+
10+
fn main() {
11+
let v: isize;
12+
//~^ HELP consider making this binding mutable
13+
//~| SUGGESTION mut
14+
v = 1;
15+
//~^ NOTE first assignment
16+
println!("v={}", v);
17+
v = 2;
18+
//~^ ERROR cannot assign twice to immutable variable
19+
//~| NOTE cannot assign twice to immutable
20+
println!("v={}", v);
21+
}

Diff for: tests/ui/assign-imm-local-twice.stderr renamed to tests/ui/borrowck/assign-imm-local-twice.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
error[E0384]: cannot assign twice to immutable variable `v`
2-
--> $DIR/assign-imm-local-twice.rs:7:5
2+
--> $DIR/assign-imm-local-twice.rs:17:5
33
|
44
LL | v = 1;
55
| ----- first assignment to `v`
6-
LL | println!("v={}", v);
6+
...
77
LL | v = 2;
88
| ^^^^^ cannot assign twice to immutable variable
99
|

Diff for: tests/ui/assign-assign.rs renamed to tests/ui/codegen/assign-expr-unit-type.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
//! Regression test for [Using the result of an assignment expression results in an LLVM assert
2+
//! #483][issue-483]. This test checks that assignment expressions produce a unit type, and is
3+
//! properly lowered to LLVM IR such that it does not trigger an LLVM assertion. This test was added
4+
//! *really* early, back in 2011.
5+
//!
6+
//! [issue-483]: https://github.com/rust-lang/rust/issues/483
7+
18
//@ run-pass
2-
// Issue 483 - Assignment expressions result in nil
39

410
fn test_assign() {
511
let mut x: isize;
@@ -27,4 +33,7 @@ fn test_assign_op() {
2733
assert_eq!(z, ());
2834
}
2935

30-
pub fn main() { test_assign(); test_assign_op(); }
36+
pub fn main() {
37+
test_assign();
38+
test_assign_op();
39+
}

Diff for: tests/ui/lang-items/assoc-lang-items.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Check that associated items can be marked as lang items, so that they don't have to be looked up
2+
//! by name or by definition order indirectly.
3+
//!
4+
//! This test is not *quite* high-fidelity: it checks that you can use lang items on associated
5+
//! items by looking at the error message *as a proxy*. That is, the error message is about
6+
//! undefined lang items and not invalid attribute target, indicating that it has reached lang item
7+
//! machinery (which is relying on knowing the implementation detail). However, it's annoying to
8+
//! write a full-fidelity test for this, so I think this is acceptable even though it's not *great*.
9+
//!
10+
//! This was implemented in <https://github.com/rust-lang/rust/pull/72559> to help with
11+
//! <https://github.com/rust-lang/rust/issues/70718>, which is itself relevant for e.g. `Fn::Output`
12+
//! or `Future::Output` or specific use cases like [Use `T`'s discriminant type in
13+
//! `mem::Discriminant<T>` instead of `u64`](https://github.com/rust-lang/rust/pull/70705).
14+
15+
#![feature(lang_items)]
16+
17+
trait Foo {
18+
#[lang = "dummy_lang_item_1"] //~ ERROR definition
19+
fn foo() {}
20+
21+
#[lang = "dummy_lang_item_2"] //~ ERROR definition
22+
fn bar();
23+
24+
#[lang = "dummy_lang_item_3"] //~ ERROR definition
25+
type MyType;
26+
}
27+
28+
struct Bar;
29+
30+
impl Bar {
31+
#[lang = "dummy_lang_item_4"] //~ ERROR definition
32+
fn test() {}
33+
}
34+
35+
fn main() {}

Diff for: tests/ui/assoc-lang-items.stderr renamed to tests/ui/lang-items/assoc-lang-items.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error[E0522]: definition of an unknown lang item: `dummy_lang_item_1`
2-
--> $DIR/assoc-lang-items.rs:4:5
2+
--> $DIR/assoc-lang-items.rs:18:5
33
|
44
LL | #[lang = "dummy_lang_item_1"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_1`
66

77
error[E0522]: definition of an unknown lang item: `dummy_lang_item_2`
8-
--> $DIR/assoc-lang-items.rs:7:5
8+
--> $DIR/assoc-lang-items.rs:21:5
99
|
1010
LL | #[lang = "dummy_lang_item_2"]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_2`
1212

1313
error[E0522]: definition of an unknown lang item: `dummy_lang_item_3`
14-
--> $DIR/assoc-lang-items.rs:10:5
14+
--> $DIR/assoc-lang-items.rs:24:5
1515
|
1616
LL | #[lang = "dummy_lang_item_3"]
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_3`
1818

1919
error[E0522]: definition of an unknown lang item: `dummy_lang_item_4`
20-
--> $DIR/assoc-lang-items.rs:17:5
20+
--> $DIR/assoc-lang-items.rs:31:5
2121
|
2222
LL | #[lang = "dummy_lang_item_4"]
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown lang item `dummy_lang_item_4`

Diff for: tests/ui/parser/assoc/assoc-oddities-3.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//! Check that braces has the expected precedence in relation to index op and some arithmetic
2+
//! bin-ops involving nested braces.
3+
//!
4+
//! This is a regression test for [Wrapping expr in curly braces changes the operator precedence
5+
//! #28777](https://github.com/rust-lang/rust/issues/28777), which was fixed by
6+
//! <https://github.com/rust-lang/rust/pull/30375>.
7+
8+
//@ run-pass
9+
10+
fn that_odd_parse(c: bool, n: usize) -> u32 {
11+
let x = 2;
12+
let a = [1, 2, 3, 4];
13+
let b = [5, 6, 7, 7];
14+
x + if c { a } else { b }[n]
15+
}
16+
17+
/// See [Wrapping expr in curly braces changes the operator precedence
18+
/// #28777](https://github.com/rust-lang/rust/issues/28777). This was fixed by
19+
/// <https://github.com/rust-lang/rust/pull/30375>. #30375 added the `that_odd_parse` example above,
20+
/// but that is not *quite* the same original example as reported in #28777, so we also include the
21+
/// original example here.
22+
fn check_issue_28777() {
23+
// Before #30375 fixed the precedence...
24+
25+
// ... `v1` evaluated to 9, indicating a parse of `(1 + 2) * 3`, while
26+
let v1 = { 1 + { 2 } * { 3 } };
27+
28+
// `v2` evaluated to 7, indicating a parse of `1 + (2 * 3)`.
29+
let v2 = 1 + { 2 } * { 3 };
30+
31+
// Check that both now evaluate to 7, as was fixed by #30375.
32+
assert_eq!(v1, 7);
33+
assert_eq!(v2, 7);
34+
}
35+
36+
fn main() {
37+
assert_eq!(4, that_odd_parse(true, 1));
38+
assert_eq!(8, that_odd_parse(false, 1));
39+
40+
check_issue_28777();
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0658]: use of unstable library feature `atomic_from_mut`
2+
--> $DIR/atomic-from-mut-not-available.rs:24:5
3+
|
4+
LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #76314 <https://github.com/rust-lang/rust/issues/76314> for more information
8+
= help: add `#![feature(atomic_from_mut)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0658`.

Diff for: tests/ui/atomic-from-mut-not-available.stderr renamed to tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0599]: no function or associated item named `from_mut` found for struct `AtomicU64` in the current scope
2-
--> $DIR/atomic-from-mut-not-available.rs:5:36
2+
--> $DIR/atomic-from-mut-not-available.rs:24:36
33
|
44
LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
55
| ^^^^^^^^ function or associated item not found in `AtomicU64`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//! This test exercises the combined effect of the `cfg(target_has_atomic_equal_alignment = "...")`
2+
//! implementation in the compiler plus usage of said `cfg(target_has_atomic_equal_alignment)` in
3+
//! `core` for the `Atomic64::from_mut` API.
4+
//!
5+
//! This test is a basic smoke test: that `AtomicU64::from_mut` is gated by
6+
//! `#[cfg(target_has_atomic_equal_alignment = "8")]`, which is only available on platforms where
7+
//! `AtomicU64` has the same alignment as `u64`. This is notably *not* satisfied by `x86_32`, where
8+
//! they have differing alignments. Thus, `AtomicU64::from_mut` should *not* be available on
9+
//! `x86_32` linux and should report assoc item not found, if the `cfg` is working correctly.
10+
//! Conversely, `AtomicU64::from_mut` *should* be available on `x86_64` linux where the alignment
11+
//! matches.
12+
13+
//@ revisions: alignment_mismatch alignment_matches
14+
15+
// This should fail on 32-bit x86 linux...
16+
//@[alignment_mismatch] only-x86
17+
//@[alignment_mismatch] only-linux
18+
19+
// ... but pass on 64-bit x86_64 linux.
20+
//@[alignment_matches] only-x86_64
21+
//@[alignment_matches] only-linux
22+
23+
fn main() {
24+
core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
25+
//[alignment_mismatch]~^ ERROR no function or associated item named `from_mut` found for struct `AtomicU64`
26+
//[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut`
27+
}

0 commit comments

Comments
 (0)