]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
Rollup merge of #106766 - GuillaumeGomez:rm-stripper-dead-code, r=notriddle
[rust.git] / tests / ui / type-alias-impl-trait / implied_lifetime_wf_check3.rs
1 #![feature(type_alias_impl_trait)]
2
3 mod test_lifetime_param {
4     type Ty<'a> = impl Sized + 'a;
5     fn defining(a: &str) -> Ty<'_> { a }
6     fn assert_static<'a: 'static>() {}
7     //~^ WARN: unnecessary lifetime parameter `'a`
8     fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
9     //~^ ERROR: lifetime may not live long enough
10 }
11
12 mod test_higher_kinded_lifetime_param {
13     type Ty<'a> = impl Sized + 'a;
14     fn defining(a: &str) -> Ty<'_> { a }
15     fn assert_static<'a: 'static>() {}
16     //~^ WARN: unnecessary lifetime parameter `'a`
17     fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
18     //~^ ERROR: lifetime may not live long enough
19 }
20
21 mod test_higher_kinded_lifetime_param2 {
22     fn assert_static<'a: 'static>() {}
23     //~^ WARN: unnecessary lifetime parameter `'a`
24     fn test<'a>() { assert_static::<'a>() }
25     //~^ ERROR: lifetime may not live long enough
26 }
27
28 mod test_type_param {
29     type Ty<A> = impl Sized;
30     fn defining<A>(s: A) -> Ty<A> { s }
31     fn assert_static<A: 'static>() {}
32     fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
33     //~^ ERROR: parameter type `A` may not live long enough
34 }
35
36 mod test_implied_from_fn_sig {
37     type Opaque<T: 'static> = impl Sized;
38     fn defining<T: 'static>() -> Opaque<T> {}
39     fn assert_static<T: 'static>() {}
40     fn test<T>(_: Opaque<T>) { assert_static::<T>(); }
41 }
42
43 fn main() {}