1 // This test used to be part of a run-pass test, but revised outlives
2 // rule means that it no longer compiles.
4 #![allow(unused_variables)]
7 fn long(&'a self) -> isize;
8 fn short<'b>(&'b self) -> isize;
11 fn object_invoke1<'d>(x: &'d dyn Trait<'d>) -> (isize, isize) { loop { } }
17 fn make_val<T:MakerTrait>() -> T {
21 impl<'t> MakerTrait for Box<dyn Trait<'t>+'static> {
22 fn mk() -> Box<dyn Trait<'t>+'static> { loop { } }
26 let m : Box<dyn Trait+'static> = make_val();
27 assert_eq!(object_invoke1(&*m), (4,5));
28 //~^ ERROR `*m` does not live long enough
30 // the problem here is that the full type of `m` is
32 // Box<Trait<'m>+'static>
34 // Here `'m` must be exactly the lifetime of the variable `m`.
35 // This is because of two requirements:
36 // 1. First, the basic type rules require that the
37 // type of `m`'s value outlives the lifetime of `m`. This puts a lower
40 // 2. Meanwhile, the signature of `object_invoke1` requires that
41 // we create a reference of type `&'d Trait<'d>` for some `'d`.
42 // `'d` cannot outlive `'m`, so that forces the lifetime to be `'m`.
44 // This then conflicts with the dropck rules, which require that
45 // the type of `m` *strictly outlives* `'m`. Hence we get an