]> git.lizzy.rs Git - rust.git/blob - src/test/ui/fn/implied-bounds-unnorm-associated-type-5.rs
Rollup merge of #100291 - WaffleLapkin:cstr_const_methods, r=oli-obk
[rust.git] / src / test / ui / fn / implied-bounds-unnorm-associated-type-5.rs
1 trait Trait<'a>: 'a {
2     type Type;
3 }
4
5 // if the `T: 'a` bound gets implied we would probably get ub here again
6 impl<'a, T> Trait<'a> for T {
7     //~^ ERROR the parameter type `T` may not live long enough
8     type Type = ();
9 }
10
11 fn f<'a, 'b>(s: &'b str, _: <&'b () as Trait<'a>>::Type) -> &'a str
12 where
13     &'b (): Trait<'a>,
14 {
15     s
16 }
17
18 fn main() {
19     let x = String::from("Hello World!");
20     let y = f(&x, ());
21     drop(x);
22     println!("{}", y);
23 }