diff --git a/tests/ui/op-assign-builtins-by-ref.rs b/tests/ui/binop/compound-assign-by-ref.rs similarity index 90% rename from tests/ui/op-assign-builtins-by-ref.rs rename to tests/ui/binop/compound-assign-by-ref.rs index 73788da92321c..e1f519a137fc9 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 similarity index 53% rename from tests/ui/once-cant-call-twice-on-heap.rs rename to tests/ui/closures/fnonce-call-twice-error.rs index 3fd8c5cadca98..1662b7bddaaee 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(blk: F) { +fn foo(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 similarity index 56% rename from tests/ui/once-cant-call-twice-on-heap.stderr rename to tests/ui/closures/fnonce-call-twice-error.stderr index 42697374115ca..51d8a33dcd796 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(blk: F) { - | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait +LL | fn foo(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(blk: F) { - | ^^^^^^^^ `F` is made to be an `FnOnce` closure here +LL | fn foo(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 9289a8e870a18..0000000000000 --- 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 377a043daf3f6..0000000000000 --- a/tests/ui/occurs-check-3.rs +++ /dev/null @@ -1,11 +0,0 @@ -// From Issue #778 - -enum Clam { A(T) } -fn main() { - let c; - c = Clam::A(c); - //~^ ERROR overflow assigning `Clam<_>` to `_` - match c { - Clam::A::(_) => { } - } -} diff --git a/tests/ui/occurs-check.rs b/tests/ui/occurs-check.rs deleted file mode 100644 index 638b9b6d7e4c2..0000000000000 --- 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 956ea0684fa70..0000000000000 --- 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 similarity index 86% rename from tests/ui/oom_unwind.rs rename to tests/ui/panics/oom-panic-unwind.rs index be5e63d430b70..5974ad91406f3 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 similarity index 82% rename from tests/ui/opt-in-copy.rs rename to tests/ui/traits/copy-requires-all-fields-copy.rs index d0257b5745d8b..8c829a7382b3e 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 similarity index 86% rename from tests/ui/opt-in-copy.stderr rename to tests/ui/traits/copy-requires-all-fields-copy.stderr index 258ff16e6e485..1a9e1ada36637 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 0000000000000..6e3d8251fc4f8 --- /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 . + +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 similarity index 79% rename from tests/ui/occurs-check.stderr rename to tests/ui/type-inference/direct-self-reference-occurs-check.stderr index ea7c541abc135..6c522ffac1f7a 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 0000000000000..2905868b8bfa9 --- /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 . + +enum Clam { + A(T), +} + +fn main() { + let c; + c = Clam::A(c); + //~^ ERROR overflow assigning `Clam<_>` to `_` + match c { + Clam::A::(_) => {} + } +} diff --git a/tests/ui/occurs-check-3.stderr b/tests/ui/type-inference/enum-self-reference-occurs-check.stderr similarity index 80% rename from tests/ui/occurs-check-3.stderr rename to tests/ui/type-inference/enum-self-reference-occurs-check.stderr index eb05c94957c98..3239be51a1766 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 0000000000000..b353824e931d4 --- /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 . + +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 similarity index 81% rename from tests/ui/occurs-check-2.stderr rename to tests/ui/type-inference/infinite-type-occurs-check.stderr index 5f296967f30d8..9cb8bb917962e 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; | ^