]> git.proxmox.com Git - rustc.git/blob - tests/ui/single-use-lifetime/fn-types.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / single-use-lifetime / fn-types.rs
1 #![deny(single_use_lifetimes)]
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4
5 // Test that we DO warn when lifetime name is used only
6 // once in a fn argument.
7
8 struct Foo {
9 a: for<'a> fn(&'a u32), //~ ERROR `'a` only used once
10 b: for<'a> fn(&'a u32, &'a u32), // OK, used twice.
11 c: for<'a> fn(&'a u32) -> &'a u32, // OK, used twice.
12 d: for<'a> fn() -> &'a u32, // OK, used only in return type.
13 //~^ ERROR return type references lifetime `'a`, which is not constrained by the fn input types
14 }
15
16 fn main() { }