diff options
| author | Jubilee <workingjubilee@gmail.com> | 2025-07-04 23:26:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-04 23:26:22 -0700 |
| commit | fde4de4d2d7fe0678c17c4e413f40b30b07b6da2 (patch) | |
| tree | 40c0b8517e7ad262fbf1624f57a4e447c46c56de | |
| parent | 19a7f0fb7dcf3f92574232333b53d7e1aab37542 (diff) | |
| parent | 0f7a86bb2ac5b2ca57e5524127f9cbeb88f89a74 (diff) | |
| download | rust-fde4de4d2d7fe0678c17c4e413f40b30b07b6da2.tar.gz rust-fde4de4d2d7fe0678c17c4e413f40b30b07b6da2.zip | |
Rollup merge of #143297 - Kivooeo:tf22, r=tgross35
`tests/ui`: A New Order [22/N] > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@tgross35`
16 files changed, 57 insertions, 60 deletions
diff --git a/tests/ui/op-assign-builtins-by-ref.rs b/tests/ui/binop/compound-assign-by-ref.rs index 73788da9232..e1f519a137f 100644 --- a/tests/ui/op-assign-builtins-by-ref.rs +++ b/tests/ui/binop/compound-assign-by-ref.rs @@ -1,9 +1,8 @@ +//! Test compound assignment operators with reference right-hand side. + //@ run-pass fn main() { - // test compound assignment operators with ref as right-hand side, - // for each operator, with various types as operands. - // test AddAssign { let mut x = 3i8; diff --git a/tests/ui/once-cant-call-twice-on-heap.rs b/tests/ui/closures/fnonce-call-twice-error.rs index 3fd8c5cadca..1662b7bddaa 100644 --- a/tests/ui/once-cant-call-twice-on-heap.rs +++ b/tests/ui/closures/fnonce-call-twice-error.rs @@ -1,16 +1,15 @@ -// Testing guarantees provided by once functions. -// This program would segfault if it were legal. +//! Test that `FnOnce` closures cannot be called twice. use std::sync::Arc; -fn foo<F:FnOnce()>(blk: F) { +fn foo<F: FnOnce()>(blk: F) { blk(); blk(); //~ ERROR use of moved value } fn main() { let x = Arc::new(true); - foo(move|| { + foo(move || { assert!(*x); drop(x); }); diff --git a/tests/ui/once-cant-call-twice-on-heap.stderr b/tests/ui/closures/fnonce-call-twice-error.stderr index 42697374115..51d8a33dcd7 100644 --- a/tests/ui/once-cant-call-twice-on-heap.stderr +++ b/tests/ui/closures/fnonce-call-twice-error.stderr @@ -1,18 +1,18 @@ error[E0382]: use of moved value: `blk` - --> $DIR/once-cant-call-twice-on-heap.rs:8:5 + --> $DIR/fnonce-call-twice-error.rs:7:5 | -LL | fn foo<F:FnOnce()>(blk: F) { - | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait +LL | fn foo<F: FnOnce()>(blk: F) { + | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait LL | blk(); | ----- `blk` moved due to this call LL | blk(); | ^^^ value used here after move | note: `FnOnce` closures can only be called once - --> $DIR/once-cant-call-twice-on-heap.rs:6:10 + --> $DIR/fnonce-call-twice-error.rs:5:11 | -LL | fn foo<F:FnOnce()>(blk: F) { - | ^^^^^^^^ `F` is made to be an `FnOnce` closure here +LL | fn foo<F: FnOnce()>(blk: F) { + | ^^^^^^^^ `F` is made to be an `FnOnce` closure here LL | blk(); | ----- this value implements `FnOnce`, which causes it to be moved when called diff --git a/tests/ui/occurs-check-2.rs b/tests/ui/occurs-check-2.rs deleted file mode 100644 index 9289a8e870a..00000000000 --- a/tests/ui/occurs-check-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - - let f; - let g; - - g = f; - //~^ ERROR overflow assigning `Box<_>` to `_` - f = Box::new(g); -} diff --git a/tests/ui/occurs-check-3.rs b/tests/ui/occurs-check-3.rs deleted file mode 100644 index 377a043daf3..00000000000 --- a/tests/ui/occurs-check-3.rs +++ /dev/null @@ -1,11 +0,0 @@ -// From Issue #778 - -enum Clam<T> { A(T) } -fn main() { - let c; - c = Clam::A(c); - //~^ ERROR overflow assigning `Clam<_>` to `_` - match c { - Clam::A::<isize>(_) => { } - } -} diff --git a/tests/ui/occurs-check.rs b/tests/ui/occurs-check.rs deleted file mode 100644 index 638b9b6d7e4..00000000000 --- a/tests/ui/occurs-check.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - let f; - f = Box::new(f); - //~^ ERROR overflow assigning `Box<_>` to `_` -} diff --git a/tests/ui/opeq.rs b/tests/ui/opeq.rs deleted file mode 100644 index 956ea0684fa..00000000000 --- a/tests/ui/opeq.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass - -pub fn main() { - let mut x: isize = 1; - x *= 2; - println!("{}", x); - assert_eq!(x, 2); - x += 3; - println!("{}", x); - assert_eq!(x, 5); - x *= x; - println!("{}", x); - assert_eq!(x, 25); - x /= 5; - println!("{}", x); - assert_eq!(x, 5); -} diff --git a/tests/ui/oom_unwind.rs b/tests/ui/panics/oom-panic-unwind.rs index be5e63d430b..5974ad91406 100644 --- a/tests/ui/oom_unwind.rs +++ b/tests/ui/panics/oom-panic-unwind.rs @@ -1,3 +1,5 @@ +//! Test that out-of-memory conditions trigger catchable panics with `-Z oom=panic`. + //@ compile-flags: -Z oom=panic //@ run-pass //@ no-prefer-dynamic diff --git a/tests/ui/opt-in-copy.rs b/tests/ui/traits/copy-requires-all-fields-copy.rs index d0257b5745d..8c829a7382b 100644 --- a/tests/ui/opt-in-copy.rs +++ b/tests/ui/traits/copy-requires-all-fields-copy.rs @@ -1,3 +1,5 @@ +//! Test that `Copy` cannot be implemented if any field doesn't implement `Copy`. + struct CantCopyThis; struct IWantToCopyThis { diff --git a/tests/ui/opt-in-copy.stderr b/tests/ui/traits/copy-requires-all-fields-copy.stderr index 258ff16e6e4..1a9e1ada366 100644 --- a/tests/ui/opt-in-copy.stderr +++ b/tests/ui/traits/copy-requires-all-fields-copy.stderr @@ -1,5 +1,5 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/opt-in-copy.rs:7:15 + --> $DIR/copy-requires-all-fields-copy.rs:9:15 | LL | but_i_cant: CantCopyThis, | ------------------------ this field does not implement `Copy` @@ -8,7 +8,7 @@ LL | impl Copy for IWantToCopyThis {} | ^^^^^^^^^^^^^^^ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/opt-in-copy.rs:19:15 + --> $DIR/copy-requires-all-fields-copy.rs:21:15 | LL | ButICant(CantCopyThisEither), | ------------------ this field does not implement `Copy` diff --git a/tests/ui/type-inference/direct-self-reference-occurs-check.rs b/tests/ui/type-inference/direct-self-reference-occurs-check.rs new file mode 100644 index 00000000000..6e3d8251fc4 --- /dev/null +++ b/tests/ui/type-inference/direct-self-reference-occurs-check.rs @@ -0,0 +1,9 @@ +//! Test that occurs check prevents direct self-reference in variable assignment. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/768>. + +fn main() { + let f; + f = Box::new(f); + //~^ ERROR overflow assigning `Box<_>` to `_` +} diff --git a/tests/ui/occurs-check.stderr b/tests/ui/type-inference/direct-self-reference-occurs-check.stderr index ea7c541abc1..6c522ffac1f 100644 --- a/tests/ui/occurs-check.stderr +++ b/tests/ui/type-inference/direct-self-reference-occurs-check.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow assigning `Box<_>` to `_` - --> $DIR/occurs-check.rs:3:18 + --> $DIR/direct-self-reference-occurs-check.rs:7:18 | LL | f = Box::new(f); | ^ diff --git a/tests/ui/type-inference/enum-self-reference-occurs-check.rs b/tests/ui/type-inference/enum-self-reference-occurs-check.rs new file mode 100644 index 00000000000..2905868b8bf --- /dev/null +++ b/tests/ui/type-inference/enum-self-reference-occurs-check.rs @@ -0,0 +1,16 @@ +//! Test that occurs check prevents infinite types with enum self-references. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/778>. + +enum Clam<T> { + A(T), +} + +fn main() { + let c; + c = Clam::A(c); + //~^ ERROR overflow assigning `Clam<_>` to `_` + match c { + Clam::A::<isize>(_) => {} + } +} diff --git a/tests/ui/occurs-check-3.stderr b/tests/ui/type-inference/enum-self-reference-occurs-check.stderr index eb05c94957c..3239be51a17 100644 --- a/tests/ui/occurs-check-3.stderr +++ b/tests/ui/type-inference/enum-self-reference-occurs-check.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow assigning `Clam<_>` to `_` - --> $DIR/occurs-check-3.rs:6:17 + --> $DIR/enum-self-reference-occurs-check.rs:11:17 | LL | c = Clam::A(c); | ^ diff --git a/tests/ui/type-inference/infinite-type-occurs-check.rs b/tests/ui/type-inference/infinite-type-occurs-check.rs new file mode 100644 index 00000000000..b353824e931 --- /dev/null +++ b/tests/ui/type-inference/infinite-type-occurs-check.rs @@ -0,0 +1,12 @@ +//! Test that occurs check prevents infinite types during type inference. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/768>. + +fn main() { + let f; + let g; + + g = f; + //~^ ERROR overflow assigning `Box<_>` to `_` + f = Box::new(g); +} diff --git a/tests/ui/occurs-check-2.stderr b/tests/ui/type-inference/infinite-type-occurs-check.stderr index 5f296967f30..9cb8bb91796 100644 --- a/tests/ui/occurs-check-2.stderr +++ b/tests/ui/type-inference/infinite-type-occurs-check.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow assigning `Box<_>` to `_` - --> $DIR/occurs-check-2.rs:6:9 + --> $DIR/infinite-type-occurs-check.rs:9:9 | LL | g = f; | ^ |
