1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that we are imposing the requirement that every associated
12 // type of a bound that appears in the where clause on a struct must
13 // outlive the location in which the type appears, even when the
14 // constraint is in a where clause not a bound. Issue #22246.
18 use std::mem::transmute;
21 ///////////////////////////////////////////////////////////////////////////
29 pub struct TheType<'b> {
33 impl<'b> TheTrait for TheType<'b> {
34 type TheAssocType = &'b ();
37 ///////////////////////////////////////////////////////////////////////////
39 pub struct WithAssoc<T> where T : TheTrait {
43 fn with_assoc<'a,'b>() {
44 // For this type to be valid, the rules require that all
45 // associated types of traits that appear in `WithAssoc` must
46 // outlive 'a. In this case, that means TheType<'b>::TheAssocType,
47 // which is &'b (), must outlive 'a.
49 let _: &'a WithAssoc<TheType<'b>> = loop { }; //~ ERROR cannot infer