1 // Test that we are imposing the requirement that every associated
2 // type of a bound that appears in the where clause on a struct must
3 // outlive the location in which the type appears, even when the
4 // constraint is in a where clause not a bound. Issue #22246.
8 ///////////////////////////////////////////////////////////////////////////
14 pub struct TheType<'b> {
18 impl<'b> TheTrait for TheType<'b> {
19 type TheAssocType = &'b ();
22 ///////////////////////////////////////////////////////////////////////////
24 pub struct WithAssoc<T> where T : TheTrait {
28 fn with_assoc<'a,'b>() {
29 // For this type to be valid, the rules require that all
30 // associated types of traits that appear in `WithAssoc` must
31 // outlive 'a. In this case, that means TheType<'b>::TheAssocType,
32 // which is &'b (), must outlive 'a.
34 let _: &'a WithAssoc<TheType<'b>> = loop { };
35 //~^ ERROR reference has a longer lifetime