// Make sure we honor region constraints when normalizing type annotations. // check-fail #![feature(more_qualified_paths)] trait Trait { type Assoc; } impl Trait for T where T: 'static, { type Assoc = MyTy<()>; } enum MyTy { Unit, Tuple(), Struct {}, Dumb(T), } impl MyTy { const CONST: () = (); fn method() {} fn method2(&self) {} } trait TraitAssoc { const TRAIT_CONST: (); fn trait_method(&self); } impl TraitAssoc for T { const TRAIT_CONST: () = (); fn trait_method(&self) {} } type Ty<'a> = <&'a () as Trait>::Assoc; fn test_local<'a>() { let _: Ty<'a> = MyTy::Unit; //~^ ERROR lifetime may not live long enough } fn test_closure_sig<'a, 'b>() { |_: Ty<'a>| {}; //~^ ERROR lifetime may not live long enough || -> Option> { None }; //~^ ERROR lifetime may not live long enough } fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() { >::method::>; //~^ ERROR lifetime may not live long enough >::method::>; //~^ ERROR lifetime may not live long enough >::trait_method::>; //~^ ERROR lifetime may not live long enough >::trait_method::>; //~^ ERROR lifetime may not live long enough >::CONST; //~^ ERROR lifetime may not live long enough >::TRAIT_CONST; //~^ ERROR lifetime may not live long enough >::method::>; >::trait_method::>; >::CONST; >::TRAIT_CONST; MyTy::Unit::>; //~^ ERROR lifetime may not live long enough MyTy::>::Unit; //~^ ERROR lifetime may not live long enough } fn test_call<'a, 'b, 'c>() { >::method::>(); //~^ ERROR lifetime may not live long enough >::method::>(); //~^ ERROR lifetime may not live long enough } fn test_variants<'a, 'b, 'c>() { >::Struct {}; //~^ ERROR lifetime may not live long enough >::Tuple(); //~^ ERROR lifetime may not live long enough >::Unit; //~^ ERROR lifetime may not live long enough } fn test_method_call<'a, 'b>(x: MyTy<()>) { x.method2::>(); //~^ ERROR lifetime may not live long enough x.trait_method::>(); //~^ ERROR lifetime may not live long enough } fn test_struct_path<'a, 'b, 'c, 'd>() { struct Struct { x: Option, } trait Project { type Struct; type Enum; } impl Project for T { type Struct = Struct<()>; type Enum = MyTy<()>; } // Resolves to enum variant MyTy::>::Struct {}; // without SelfTy //~^ ERROR lifetime may not live long enough as Project>::Enum::Struct {}; // with SelfTy //~^ ERROR lifetime may not live long enough // Resolves to struct and associated type respectively Struct::> { x: None, }; // without SelfTy //~^ ERROR lifetime may not live long enough as Project>::Struct { x: None, }; // with SelfTy //~^ ERROR lifetime may not live long enough } fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() { use MyTy::*; match MyTy::Unit { Struct::> {..} => {}, //~^ ERROR lifetime may not live long enough Tuple::> (..) => {}, //~^ ERROR lifetime may not live long enough Unit::> => {}, //~^ ERROR lifetime may not live long enough Dumb(_) => {}, }; match MyTy::Unit { >::Struct {..} => {}, //~^ ERROR lifetime may not live long enough >::Tuple (..) => {}, //~^ ERROR lifetime may not live long enough >::Unit => {}, //~^ ERROR lifetime may not live long enough Dumb(_) => {}, }; } fn main() {}