diff --git a/tests/ui/autoderef-full-lval.rs b/tests/ui/autoderef-full-lval.rs deleted file mode 100644 index 0fadc5c98277e..0000000000000 --- a/tests/ui/autoderef-full-lval.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct Clam { - x: Box, - y: Box, -} - - - -struct Fish { - a: Box, -} - -fn main() { - let a: Clam = Clam{ x: Box::new(1), y: Box::new(2) }; - let b: Clam = Clam{ x: Box::new(10), y: Box::new(20) }; - let z: isize = a.x + b.y; - //~^ ERROR cannot add `Box` to `Box` - println!("{}", z); - assert_eq!(z, 21); - let forty: Fish = Fish{ a: Box::new(40) }; - let two: Fish = Fish{ a: Box::new(2) }; - let answer: isize = forty.a + two.a; - //~^ ERROR cannot add `Box` to `Box` - println!("{}", answer); - assert_eq!(answer, 42); -} diff --git a/tests/ui/autoref-autoderef/autoderef-box-no-add.rs b/tests/ui/autoref-autoderef/autoderef-box-no-add.rs new file mode 100644 index 0000000000000..f8085c1ae961d --- /dev/null +++ b/tests/ui/autoref-autoderef/autoderef-box-no-add.rs @@ -0,0 +1,35 @@ +//! Tests that auto-dereferencing does not allow addition of `Box` values. +//! +//! This test ensures that `Box` fields in structs (`Clam` and `Fish`) are not +//! automatically dereferenced to `isize` during addition operations, as `Box` +//! does not implement the `Add` trait. + +struct Clam { + x: Box, + y: Box, +} + +struct Fish { + a: Box, +} + +fn main() { + let a: Clam = Clam { + x: Box::new(1), + y: Box::new(2), + }; + let b: Clam = Clam { + x: Box::new(10), + y: Box::new(20), + }; + let z: isize = a.x + b.y; + //~^ ERROR cannot add `Box` to `Box` + println!("{}", z); + assert_eq!(z, 21); + let forty: Fish = Fish { a: Box::new(40) }; + let two: Fish = Fish { a: Box::new(2) }; + let answer: isize = forty.a + two.a; + //~^ ERROR cannot add `Box` to `Box` + println!("{}", answer); + assert_eq!(answer, 42); +} diff --git a/tests/ui/autoderef-full-lval.stderr b/tests/ui/autoref-autoderef/autoderef-box-no-add.stderr similarity index 91% rename from tests/ui/autoderef-full-lval.stderr rename to tests/ui/autoref-autoderef/autoderef-box-no-add.stderr index d90238a7fb210..20ef3352831a4 100644 --- a/tests/ui/autoderef-full-lval.stderr +++ b/tests/ui/autoref-autoderef/autoderef-box-no-add.stderr @@ -1,5 +1,5 @@ error[E0369]: cannot add `Box` to `Box` - --> $DIR/autoderef-full-lval.rs:15:24 + --> $DIR/autoderef-box-no-add.rs:25:24 | LL | let z: isize = a.x + b.y; | --- ^ --- Box @@ -13,7 +13,7 @@ note: the foreign item type `Box` doesn't implement `Add` = note: not implement `Add` error[E0369]: cannot add `Box` to `Box` - --> $DIR/autoderef-full-lval.rs:21:33 + --> $DIR/autoderef-box-no-add.rs:31:33 | LL | let answer: isize = forty.a + two.a; | ------- ^ ----- Box diff --git a/tests/ui/bare-fn-implements-fn-mut.rs b/tests/ui/functions-closures/bare-fn-implements-fn-mut.rs similarity index 76% rename from tests/ui/bare-fn-implements-fn-mut.rs rename to tests/ui/functions-closures/bare-fn-implements-fn-mut.rs index 49b31f28f8a0a..52d5ad3d0f794 100644 --- a/tests/ui/bare-fn-implements-fn-mut.rs +++ b/tests/ui/functions-closures/bare-fn-implements-fn-mut.rs @@ -1,3 +1,7 @@ +//! Tests that bare functions implement the `FnMut` trait. +//! +//! See . + //@ run-pass fn call_f(mut f: F) { diff --git a/tests/ui/big-literals.rs b/tests/ui/lint/overflowing-literals-valid.rs similarity index 84% rename from tests/ui/big-literals.rs rename to tests/ui/lint/overflowing-literals-valid.rs index d2f447a595c99..08aa092ee71ef 100644 --- a/tests/ui/big-literals.rs +++ b/tests/ui/lint/overflowing-literals-valid.rs @@ -1,5 +1,7 @@ +//! Test that valid large numeric literals do not trigger the `overflowing_literals` lint. + //@ run-pass -// Catch mistakes in the overflowing literals lint. + #![deny(overflowing_literals)] pub fn main() { diff --git a/tests/ui/auto-ref-slice-plus-ref.rs b/tests/ui/methods/vec-autoderef-autoref.rs similarity index 79% rename from tests/ui/auto-ref-slice-plus-ref.rs rename to tests/ui/methods/vec-autoderef-autoref.rs index 00b279d3226c1..38c0ba8574b08 100644 --- a/tests/ui/auto-ref-slice-plus-ref.rs +++ b/tests/ui/methods/vec-autoderef-autoref.rs @@ -1,8 +1,7 @@ -fn main() { - - // Testing that method lookup does not automatically borrow - // vectors to slices then automatically create a self reference. +//! Test that method resolution does not autoderef `Vec` +//! into a slice or perform additional autorefs. +fn main() { let mut a = vec![0]; a.test_mut(); //~ ERROR no method named `test_mut` found a.test(); //~ ERROR no method named `test` found diff --git a/tests/ui/auto-ref-slice-plus-ref.stderr b/tests/ui/methods/vec-autoderef-autoref.stderr similarity index 83% rename from tests/ui/auto-ref-slice-plus-ref.stderr rename to tests/ui/methods/vec-autoderef-autoref.stderr index 806c1ee064ffa..61c3bcc5b3b37 100644 --- a/tests/ui/auto-ref-slice-plus-ref.stderr +++ b/tests/ui/methods/vec-autoderef-autoref.stderr @@ -1,12 +1,12 @@ error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:7:7 + --> $DIR/vec-autoderef-autoref.rs:6:7 | LL | a.test_mut(); | ^^^^^^^^ | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test_mut`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ @@ -14,40 +14,40 @@ help: there is a method `get_mut` with a similar name, but with different argume --> $SRC_DIR/core/src/slice/mod.rs:LL:COL error[E0599]: no method named `test` found for struct `Vec<{integer}>` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:8:7 + --> $DIR/vec-autoderef-autoref.rs:7:7 | LL | a.test(); | ^^^^ method not found in `Vec<{integer}>` | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:10:11 + --> $DIR/vec-autoderef-autoref.rs:9:11 | LL | ([1]).test(); | ^^^^ method not found in `[{integer}; 1]` | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope - --> $DIR/auto-ref-slice-plus-ref.rs:11:12 + --> $DIR/vec-autoderef-autoref.rs:10:12 | LL | (&[1]).test(); | ^^^^ method not found in `&[{integer}; 1]` | = help: items from traits can only be used if the trait is implemented and in scope note: `MyIter` defines an item `test`, perhaps you need to implement it - --> $DIR/auto-ref-slice-plus-ref.rs:14:1 + --> $DIR/vec-autoderef-autoref.rs:13:1 | LL | trait MyIter { | ^^^^^^^^^^^^ diff --git a/tests/ui/bare-static-string.rs b/tests/ui/str/str-static-literal.rs similarity index 51% rename from tests/ui/bare-static-string.rs rename to tests/ui/str/str-static-literal.rs index b71cf38cfe819..61630f0f22bdf 100644 --- a/tests/ui/bare-static-string.rs +++ b/tests/ui/str/str-static-literal.rs @@ -1,3 +1,5 @@ +//! Check that a bare string literal is typed as a `&'static str` and is usable. + //@ run-pass pub fn main() {