2023-11-12 06:48:47 -06:00
|
|
|
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));
|
2024-09-10 12:20:27 -05:00
|
|
|
//~^ NOTE coercion requires that `local` is borrowed for `'static`
|
2023-11-12 06:48:47 -06:00
|
|
|
|
|
|
|
let _ = 0;
|
|
|
|
} //~ NOTE `local` dropped here while still borrowed
|
|
|
|
|
|
|
|
fn require_box(_a: Box<dyn A>) {}
|