diff options
Diffstat (limited to 'src/test/ui/single-use-lifetime/fn-types.rs')
-rw-r--r-- | src/test/ui/single-use-lifetime/fn-types.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/single-use-lifetime/fn-types.rs b/src/test/ui/single-use-lifetime/fn-types.rs new file mode 100644 index 000000000..018535f64 --- /dev/null +++ b/src/test/ui/single-use-lifetime/fn-types.rs @@ -0,0 +1,16 @@ +#![deny(single_use_lifetimes)] +#![allow(dead_code)] +#![allow(unused_variables)] + +// Test that we DO warn when lifetime name is used only +// once in a fn argument. + +struct Foo { + a: for<'a> fn(&'a u32), //~ ERROR `'a` only used once + b: for<'a> fn(&'a u32, &'a u32), // OK, used twice. + c: for<'a> fn(&'a u32) -> &'a u32, // OK, used twice. + d: for<'a> fn() -> &'a u32, // OK, used only in return type. + //~^ ERROR return type references lifetime `'a`, which is not constrained by the fn input types +} + +fn main() { } |