1 // Test cases where we constrain `<T as Anything<'b>>::AssocType` to
2 // outlive `'a` and there are no bounds in the trait definition of
3 // `Anything`. This means that the constraint can only be satisfied in two
6 // - by ensuring that `T: 'a` and `'b: 'a`, or
7 // - by something in the where clauses.
9 // As of this writing, the where clause option does not work because
10 // of limitations in our region inferencing system (this is true both
11 // with and without NLL). See `projection_outlives`.
13 // Ensuring that both `T: 'a` and `'b: 'a` holds does work (`elements_outlive`).
15 // compile-flags:-Zverbose
18 #![feature(rustc_attrs)]
26 fn with_signature<'a, T, F>(cell: Cell<&'a ()>, t: T, op: F)
28 F: FnOnce(Cell<&'a ()>, T),
33 fn require<'a, 'b, T>(_cell: Cell<&'a ()>, _t: T)
41 fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
45 with_signature(cell, t, |cell, t| require(cell, t));
46 //~^ ERROR the parameter type `T` may not live long enough
51 fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
56 with_signature(cell, t, |cell, t| require(cell, t));
57 //~^ ERROR the parameter type `T` may not live long enough
62 fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
67 // We are projecting `<T as Anything<'b>>::AssocType`, and we know
68 // that this outlives `'a` because of the where-clause.
70 with_signature(cell, t, |cell, t| require(cell, t));
74 fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
80 with_signature(cell, t, |cell, t| require(cell, t));