2022-05-21 15:14:11 -04:00
|
|
|
// ignore-compare-mode-nll
|
|
|
|
// revisions: base nll
|
|
|
|
// [nll]compile-flags: -Zborrowck=mir
|
|
|
|
|
2018-03-21 17:12:39 -04:00
|
|
|
// Test that `impl MyTrait<'_> for &i32` is equivalent to `impl<'a,
|
|
|
|
// 'b> MyTrait<'a> for &'b i32`.
|
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
// Equivalent to `Box<dyn Debug + 'static>`:
|
|
|
|
trait StaticTrait { }
|
|
|
|
impl StaticTrait for Box<dyn Debug> { }
|
|
|
|
|
|
|
|
// Equivalent to `Box<dyn Debug + 'static>`:
|
|
|
|
trait NotStaticTrait { }
|
|
|
|
impl NotStaticTrait for Box<dyn Debug + '_> { }
|
|
|
|
|
|
|
|
fn static_val<T: StaticTrait>(_: T) {
|
|
|
|
}
|
|
|
|
|
|
|
|
fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
|
2022-05-21 15:14:11 -04:00
|
|
|
static_val(x);
|
|
|
|
//[base]~^ ERROR E0759
|
|
|
|
//[nll]~^^ ERROR borrowed data escapes outside of function
|
2018-03-21 17:12:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn not_static_val<T: NotStaticTrait>(_: T) {
|
|
|
|
}
|
|
|
|
|
|
|
|
fn with_dyn_debug_not_static<'a>(x: Box<dyn Debug + 'a>) {
|
|
|
|
not_static_val(x); // OK
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|