diff options
Diffstat (limited to 'tests/ui/single-use-lifetime/one-use-in-inherent-method-argument.rs')
-rw-r--r-- | tests/ui/single-use-lifetime/one-use-in-inherent-method-argument.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/single-use-lifetime/one-use-in-inherent-method-argument.rs b/tests/ui/single-use-lifetime/one-use-in-inherent-method-argument.rs new file mode 100644 index 000000000..eecd715ef --- /dev/null +++ b/tests/ui/single-use-lifetime/one-use-in-inherent-method-argument.rs @@ -0,0 +1,18 @@ +#![deny(single_use_lifetimes)] +#![allow(dead_code)] +#![allow(unused_variables)] + +// Test that we DO warn for a lifetime used only once in an inherent method. + +struct Foo<'f> { + data: &'f u32 +} + +impl<'f> Foo<'f> { //~ ERROR `'f` only used once + //~^ HELP elide the single-use lifetime + fn inherent_a<'a>(&self, data: &'a u32) { //~ ERROR `'a` only used once + //~^ HELP elide the single-use lifetime + } +} + +fn main() { } |