about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdrian Taylor <adetaylor@chromium.org>2024-06-04 15:06:25 +0000
committerAdrian Taylor <adetaylor@chromium.org>2024-06-04 15:06:43 +0000
commitc20a90f2b87bf935d7e62124cf0660839813f1a9 (patch)
tree2394071b1e717f61393604899d40c245a04e7c4d
parent8c1777750bce6329a3ce1268c0f6f49b7842f7d2 (diff)
downloadrust-c20a90f2b87bf935d7e62124cf0660839813f1a9.tar.gz
rust-c20a90f2b87bf935d7e62124cf0660839813f1a9.zip
Add additional tests.
-rw-r--r--tests/ui/self/elision/ignore-non-reference-lifetimes.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/self/elision/ignore-non-reference-lifetimes.rs b/tests/ui/self/elision/ignore-non-reference-lifetimes.rs
new file mode 100644
index 00000000000..f7f61b8c810
--- /dev/null
+++ b/tests/ui/self/elision/ignore-non-reference-lifetimes.rs
@@ -0,0 +1,22 @@
+//@ check-pass
+
+struct Foo<'a>(&'a str);
+
+impl<'b> Foo<'b> {
+    fn a<'a>(self: Self, a: &'a str) -> &str {
+        a
+    }
+    fn b<'a>(self: Foo<'b>, a: &'a str) -> &str {
+        a
+    }
+}
+
+struct Foo2<'a>(&'a u32);
+impl<'a> Foo2<'a> {
+    fn foo(self: &Self) -> &u32 { self.0 } // ok
+    fn bar(self: &Foo2<'a>) -> &u32 { self.0 } // ok (do not look into `Foo`)
+    fn baz2(self: Self, arg: &u32) -> &u32 { arg } // use lt from `arg`
+    fn baz3(self: Foo2<'a>, arg: &u32) -> &u32 { arg } // use lt from `arg`
+}
+
+fn main() {}