diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-06-01 00:03:54 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-06-03 07:38:06 +0500 |
| commit | e7e884b0a4b5f012864562b0bb550d80d3e5f03b (patch) | |
| tree | 20e189b8ec9a54f4e63b4136e2756c246396c210 /tests/ui/autoref-autoderef | |
| parent | 852f15c0f146fc292c9b20f2a8f44c1f671d7845 (diff) | |
| download | rust-e7e884b0a4b5f012864562b0bb550d80d3e5f03b.tar.gz rust-e7e884b0a4b5f012864562b0bb550d80d3e5f03b.zip | |
cleaned up some tests
Diffstat (limited to 'tests/ui/autoref-autoderef')
| -rw-r--r-- | tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs b/tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs new file mode 100644 index 00000000000..4d67c3a6733 --- /dev/null +++ b/tests/ui/autoref-autoderef/autoderef-vec-to-slice-by-value.rs @@ -0,0 +1,18 @@ +//! Tests that a `Vec<isize>` can call a method defined in a trait (`Foo`) +//! implemented for `&[isize]` with a by-value receiver (`self`), relying on auto-dereferencing +//! from `Vec` to `&[isize]` during method resolution. + +//@ run-pass + +trait Foo { + fn foo(self); +} + +impl<'a> Foo for &'a [isize] { + fn foo(self) {} +} + +pub fn main() { + let items = vec![ 3, 5, 1, 2, 4 ]; + items.foo(); +} |
