]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / associated_type_bound / check-trait-object-bounds-3.rs
1 // Check that we validate associated type bounds for trait objects
2
3 trait X<'a> {
4     type Y: Into<&'static str> + From<&'a str>;
5 }
6
7 fn f<'a, T: X<'a> + ?Sized>(s: &'a str) -> &'static str {
8     T::Y::from(s).into()
9 }
10
11 pub fn main() {
12     let z;
13     {
14         let s = String::from("abcdef");
15         z = f::<dyn X<Y = &str>>(&s);
16         //~^ ERROR `s` does not live long enough
17     }
18
19     println!("{}", z)
20 }