]> git.lizzy.rs Git - rust.git/blob - src/test/ui/single-use-lifetime/one-use-in-fn-argument.rs
Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup
[rust.git] / src / test / ui / single-use-lifetime / one-use-in-fn-argument.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 fn a<'a>(x: &'a u32) { //~ ERROR `'a` only used once
9     //~^ HELP elide the single-use lifetime
10 }
11
12 struct Single<'a> { x: &'a u32 }
13 struct Double<'a, 'b> { f: &'a &'b u32 }
14
15 fn center<'m>(_: Single<'m>) {} //~ ERROR `'m` only used once
16 //~^ HELP elide the single-use lifetime
17 fn left<'x, 'y>(foo: Double<'x, 'y>) -> &'x u32 { foo.f } //~ ERROR `'y` only used once
18 //~^ HELP elide the single-use lifetime
19 fn right<'x, 'y>(foo: Double<'x, 'y>) -> &'y u32 { foo.f } //~ ERROR `'x` only used once
20 //~^ HELP elide the single-use lifetime
21
22 fn main() { }