summaryrefslogtreecommitdiffstats
path: root/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
blob: ba04fd93accec2e8b417517f7b6ff36787c7207b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Check that we validate associated type bounds for trait objects

trait X<'a> {
    type Y: Into<&'static str> + From<&'a str>;
}

fn f<'a, T: X<'a> + ?Sized>(s: &'a str) -> &'static str {
    T::Y::from(s).into()
}

pub fn main() {
    let z;
    {
        let s = String::from("abcdef");
        z = f::<dyn X<Y = &str>>(&s);
        //~^ ERROR `s` does not live long enough
    }

    println!("{}", z)
}