]> git.lizzy.rs Git - rust.git/blob - tests/ui/single-use-lifetime/one-use-in-fn-return.rs
Rollup merge of #106978 - mejrs:mir_build3, r=davidtwco
[rust.git] / tests / ui / single-use-lifetime / one-use-in-fn-return.rs
1 // Test that we DO NOT warn when lifetime name is used only
2 // once in a fn return type -- using `'_` is not legal there,
3 // as it must refer back to an argument.
4 //
5 // (Normally, using `'static` would be preferred, but there are
6 // times when that is not what you want.)
7
8 // check-pass
9
10 #![deny(single_use_lifetimes)]
11
12 // OK: used only in return type
13 fn b<'a>() -> &'a u32 {
14     &22
15 }
16
17 pub trait Tfv<'a> {}
18 impl Tfv<'_> for () {}
19
20 // Do NOT lint if used in return type.
21 pub fn i<'a>() -> impl Tfv<'a> {}
22
23 fn main() {}