diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-05-31 00:30:37 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-05-31 19:49:19 +0500 |
| commit | afc64242b61041ee2f6e107c9483957dacfbf090 (patch) | |
| tree | 8e284f9cea9aa064af69bcf701d697623a7328ca /tests/ui/methods | |
| parent | 8afd71079a729ac002298239f5010ccaac5807ca (diff) | |
| download | rust-afc64242b61041ee2f6e107c9483957dacfbf090.tar.gz rust-afc64242b61041ee2f6e107c9483957dacfbf090.zip | |
cleaned up some tests
Diffstat (limited to 'tests/ui/methods')
| -rw-r--r-- | tests/ui/methods/vec-autoderef-autoref.rs | 26 | ||||
| -rw-r--r-- | tests/ui/methods/vec-autoderef-autoref.stderr | 57 |
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/ui/methods/vec-autoderef-autoref.rs b/tests/ui/methods/vec-autoderef-autoref.rs new file mode 100644 index 00000000000..38c0ba8574b --- /dev/null +++ b/tests/ui/methods/vec-autoderef-autoref.rs @@ -0,0 +1,26 @@ +//! 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 + + ([1]).test(); //~ ERROR no method named `test` found + (&[1]).test(); //~ ERROR no method named `test` found +} + +trait MyIter { + fn test_mut(&mut self); + fn test(&self); +} + +impl<'a> MyIter for &'a [isize] { + fn test_mut(&mut self) { } + fn test(&self) { } +} + +impl<'a> MyIter for &'a str { + fn test_mut(&mut self) { } + fn test(&self) { } +} diff --git a/tests/ui/methods/vec-autoderef-autoref.stderr b/tests/ui/methods/vec-autoderef-autoref.stderr new file mode 100644 index 00000000000..61c3bcc5b3b --- /dev/null +++ b/tests/ui/methods/vec-autoderef-autoref.stderr @@ -0,0 +1,57 @@ +error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope + --> $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/vec-autoderef-autoref.rs:13:1 + | +LL | trait MyIter { + | ^^^^^^^^^^^^ +help: there is a method `get_mut` with a similar name, but with different arguments + --> $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/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/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/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/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/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/vec-autoderef-autoref.rs:13:1 + | +LL | trait MyIter { + | ^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0599`. |
