99// except according to those terms.
1010
1111// must-compile-successfully
12+ #![ allow( dead_code, non_camel_case_types) ]
1213
1314use std:: rc:: Rc ;
1415
15- type SVec < T : Send > = Vec < T > ;
16- type VVec < ' b , ' a : ' b > = Vec < & ' a i32 > ;
17- type WVec < ' b , T : ' b > = Vec < T > ;
16+ type SVec < T : Send +Send > = Vec < T > ;
17+ //~^ WARN bounds on generic type parameters are ignored in type aliases
18+ type VVec < ' b , ' a : ' b +' b > = Vec < & ' a i32 > ;
19+ //~^ WARN bounds on generic lifetime parameters are ignored in type aliases
20+ type WVec < ' b , T : ' b +' b > = Vec < T > ;
21+ //~^ WARN bounds on generic type parameters are ignored in type aliases
22+ type W2Vec < ' b , T > where T : ' b , T : ' b = Vec < T > ;
23+ //~^ WARN where clauses are ignored in type aliases
1824
1925fn foo < ' a > ( y : & ' a i32 ) {
2026 // If the bounds above would matter, the code below would be rejected.
@@ -26,8 +32,73 @@ fn foo<'a>(y: &'a i32) {
2632
2733 let mut x : WVec < ' static , & ' a i32 > = Vec :: new ( ) ;
2834 x. push ( y) ;
35+
36+ let mut x : W2Vec < ' static , & ' a i32 > = Vec :: new ( ) ;
37+ x. push ( y) ;
38+ }
39+
40+ fn bar1 < ' a , ' b > (
41+ x : & ' a i32 ,
42+ y : & ' b i32 ,
43+ f : for <' xa , ' xb : ' xa> fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 )
44+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked function types
45+ {
46+ // If the bound in f's type would matter, the call below would (have to)
47+ // be rejected.
48+ f ( x, y) ;
2949}
3050
51+ fn bar2 < ' a , ' b , F : for < ' xa , ' xb : ' xa > Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 > (
52+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
53+ x : & ' a i32 ,
54+ y : & ' b i32 ,
55+ f : F )
56+ {
57+ // If the bound in f's type would matter, the call below would (have to)
58+ // be rejected.
59+ f ( x, y) ;
60+ }
61+
62+ fn bar3 < ' a , ' b , F > (
63+ x : & ' a i32 ,
64+ y : & ' b i32 ,
65+ f : F )
66+ where F : for < ' xa , ' xb : ' xa > Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32
67+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
68+ {
69+ // If the bound in f's type would matter, the call below would (have to)
70+ // be rejected.
71+ f ( x, y) ;
72+ }
73+
74+ fn bar4 < ' a , ' b , F > (
75+ x : & ' a i32 ,
76+ y : & ' b i32 ,
77+ f : F )
78+ where for < ' xa , ' xb : ' xa > F : Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32
79+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
80+ {
81+ // If the bound in f's type would matter, the call below would (have to)
82+ // be rejected.
83+ f ( x, y) ;
84+ }
85+
86+ struct S1 < F : for < ' xa , ' xb : ' xa > Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 > ( F ) ;
87+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
88+ struct S2 < F > ( F ) where F : for < ' xa , ' xb : ' xa > Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 ;
89+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
90+ struct S3 < F > ( F ) where for < ' xa , ' xb : ' xa > F : Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 ;
91+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
92+
93+ struct S_fnty ( for <' xa , ' xb : ' xa> fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 ) ;
94+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked function types
95+
96+ type T1 = Box < for <' xa , ' xb : ' xa> Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 > ;
97+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
98+
3199fn main ( ) {
32- foo ( & 42 ) ;
100+ let _ : Option < for <' xa , ' xb : ' xa> fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 > = None ;
101+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked function types
102+ let _ : Option < Box < for <' xa , ' xb : ' xa> Fn ( & ' xa i32 , & ' xb i32 ) -> & ' xa i32 > > = None ;
103+ //~^ WARN bounds on generic lifetime parameters are ignored in higher-ranked trait bounds
33104}
0 commit comments