summaryrefslogtreecommitdiffstats
path: root/src/test/ui/single-use-lifetime/one-use-in-inherent-method-return.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/single-use-lifetime/one-use-in-inherent-method-return.rs')
-rw-r--r--src/test/ui/single-use-lifetime/one-use-in-inherent-method-return.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/single-use-lifetime/one-use-in-inherent-method-return.rs b/src/test/ui/single-use-lifetime/one-use-in-inherent-method-return.rs
new file mode 100644
index 000000000..c5938f4a1
--- /dev/null
+++ b/src/test/ui/single-use-lifetime/one-use-in-inherent-method-return.rs
@@ -0,0 +1,18 @@
+#![deny(single_use_lifetimes)]
+#![allow(dead_code)]
+#![allow(unused_variables)]
+
+// Test that we DO NOT warn for a lifetime used just once in a return type,
+// where that return type is in an inherent method.
+
+struct Foo<'f> {
+ data: &'f u32
+}
+
+impl<'f> Foo<'f> { //~ ERROR `'f` only used once
+ fn inherent_a<'a>(&self) -> &'a u32 { // OK for 'a
+ &22
+ }
+}
+
+fn main() { }