1 // Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
2 // 'b> MyTrait<'a> for &'b i32`.
8 // Equivalent to `Box<dyn Debug + 'static>`:
10 impl StaticTrait for Box<dyn Debug> { }
12 // Equivalent to `Box<dyn Debug + 'static>`:
13 trait NotStaticTrait { }
14 impl NotStaticTrait for Box<dyn Debug + '_> { }
16 // Check that we don't err when the trait has a lifetime parameter.
17 trait TraitWithLifetime<'a> { }
18 impl NotStaticTrait for &dyn TraitWithLifetime<'_> { }
20 fn static_val<T: StaticTrait>(_: T) {
23 fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
25 //~^ ERROR borrowed data escapes outside of function
28 fn not_static_val<T: NotStaticTrait>(_: T) {
31 fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) {
32 not_static_val(x); // OK