summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/trait-object-lifetime-default-note.rs
blob: 31e3eb4ba41556ee93a20644da9b771ef3883973 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
trait A {}

impl<T> A for T {}

fn main() {
    let local = 0; //~ NOTE binding `local` declared here
    let r = &local; //~ ERROR `local` does not live long enough
    //~| NOTE borrowed value does not live long enough
    //~| NOTE due to object lifetime defaults, `Box<dyn A>` actually means `Box<(dyn A + 'static)>`
    require_box(Box::new(r));
    //~^ NOTE cast requires that `local` is borrowed for `'static`

    let _ = 0;
} //~ NOTE `local` dropped here while still borrowed

fn require_box(_a: Box<dyn A>) {}