1 // Test cases where we constrain `<T as Anything<'b>>::AssocType` to
2 // outlive `'static`. In this case, we don't get any errors, and in fact
3 // we don't even propagate constraints from the closures to the callers.
5 // compile-flags:-Zverbose
9 #![feature(rustc_attrs)]
14 type AssocType: 'static;
17 fn with_signature<'a, T, F>(cell: Cell<&'a ()>, t: T, op: F)
19 F: FnOnce(Cell<&'a ()>, T),
24 fn require<'a, 'b, T>(_cell: Cell<&'a ()>, _t: T)
32 fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
36 with_signature(cell, t, |cell, t| require(cell, t));
40 fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
45 with_signature(cell, t, |cell, t| require(cell, t));
49 fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
54 // This error is unfortunate. This code ought to type-check: we
55 // are projecting `<T as Anything<'b>>::AssocType`, and we know
56 // that this outlives `'a` because of the where-clause. However,
57 // the way the region checker works, we don't register this
58 // outlives obligation, and hence we get an error: this is because
59 // what we see is a projection like `<T as
60 // Anything<'?0>>::AssocType`, and we don't yet know if `?0` will
61 // equal `'b` or not, so we ignore the where-clause. Obviously we
62 // can do better here with a more involved verification step.
64 with_signature(cell, t, |cell, t| require(cell, t));
68 fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T)
73 with_signature(cell, t, |cell, t| require(cell, t));
77 fn one_region<'a, T>(cell: Cell<&'a ()>, t: T)
81 // Note that in this case the closure still propagates an external
82 // requirement between two variables in its signature, but the
83 // creator maps both those two region variables to `'a` on its
85 with_signature(cell, t, |cell, t| require(cell, t));