File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
src/test/ui/associated-type-bounds Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ // check-pass
2+
3+ // From https://github.com/rust-lang/rust/issues/54121/
4+ //
5+ // Whether the code compiled depended on the order of the trait bounds in
6+ // `type T: Tr<u8, u8> + Tr<u16, u16>`
7+ // But both should compile as order shouldn't matter.
8+
9+ trait Tr < A , B > {
10+ fn exec ( a : A , b : B ) ;
11+ }
12+
13+ trait P {
14+ // This compiled successfully
15+ type T : Tr < u16 , u16 > + Tr < u8 , u8 > ;
16+ }
17+
18+ trait Q {
19+ // This didn't compile
20+ type T : Tr < u8 , u8 > + Tr < u16 , u16 > ;
21+ }
22+
23+ #[ allow( dead_code) ]
24+ fn f < S : P > ( ) {
25+ <S as P >:: T :: exec ( 0u8 , 0u8 )
26+ }
27+
28+ #[ allow( dead_code) ]
29+ fn g < S : Q > ( ) {
30+ // A mismatched types error was emitted on this line.
31+ <S as Q >:: T :: exec ( 0u8 , 0u8 )
32+ }
33+
34+ // Another reproduction of the same issue
35+ trait Trait {
36+ type Type : Into < Self :: Type1 > + Into < Self :: Type2 > + Copy ;
37+ type Type1 ;
38+ type Type2 ;
39+ }
40+
41+ #[ allow( dead_code) ]
42+ fn foo < T : Trait > ( x : T :: Type ) {
43+ let _1: T :: Type1 = x. into ( ) ;
44+ let _2: T :: Type2 = x. into ( ) ;
45+ }
46+
47+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments