File tree Expand file tree Collapse file tree 6 files changed +127
-0
lines changed
tests/ui/traits/winnowing Expand file tree Collapse file tree 6 files changed +127
-0
lines changed Original file line number Diff line number Diff line change
1
+ // A regression test for an edge case of candidate selection
2
+ // in the old trait solver, see #124592 for more details.
3
+
4
+ //@ revisions: current next
5
+ //@ ignore-compare-mode-next-solver (explicit revisions)
6
+ //@[next] compile-flags: -Znext-solver
7
+ //@ check-pass
8
+
9
+ trait Trait < T > { }
10
+ impl < T > Trait < T > for ( ) { }
11
+
12
+ fn impls_trait < T : Trait < U > , U > ( _: T ) -> U { todo ! ( ) }
13
+ fn foo < T > ( ) -> u32
14
+ where
15
+ ( ) : Trait < u32 > ,
16
+ ( ) : Trait < T > ,
17
+ {
18
+ impls_trait ( ( ) )
19
+ }
20
+
21
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/global-non-global-env-2.rs:20:5
3
+ |
4
+ LL | fn foo<T>() -> u32
5
+ | - --- expected `u32` because of return type
6
+ | |
7
+ | found this type parameter
8
+ ...
9
+ LL | impls_trait(())
10
+ | ^^^^^^^^^^^^^^^ expected `u32`, found type parameter `T`
11
+ |
12
+ = note: expected type `u32`
13
+ found type parameter `T`
14
+
15
+ error: aborting due to 1 previous error
16
+
17
+ For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
1
+ // A regression test for an edge case of candidate selection
2
+ // in the old trait solver, see #124592 for more details. Unlike
3
+ // the first test, this one has two impl candidates.
4
+
5
+ //@ revisions: current next
6
+ //@ ignore-compare-mode-next-solver (explicit revisions)
7
+ //@[next] compile-flags: -Znext-solver
8
+ //@[next] check-pass
9
+
10
+ trait Trait < T > { }
11
+ impl Trait < u32 > for ( ) { }
12
+ impl Trait < u64 > for ( ) { }
13
+
14
+ fn impls_trait < T : Trait < U > , U > ( _: T ) -> U { todo ! ( ) }
15
+ fn foo < T > ( ) -> u32
16
+ where
17
+ ( ) : Trait < u32 > ,
18
+ ( ) : Trait < T > ,
19
+ {
20
+ impls_trait ( ( ) )
21
+ //[current]~^ ERROR mismatched types
22
+ }
23
+
24
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // A regression test for an edge case of candidate selection
2
+ // in the old trait solver, see #124592 for more details. Unlike
3
+ // the second test, the where-bounds are in a different order.
4
+
5
+ //@ revisions: current next
6
+ //@ ignore-compare-mode-next-solver (explicit revisions)
7
+ //@[next] compile-flags: -Znext-solver
8
+ //@ check-pass
9
+
10
+ trait Trait < T > { }
11
+ impl Trait < u32 > for ( ) { }
12
+ impl Trait < u64 > for ( ) { }
13
+
14
+ fn impls_trait < T : Trait < U > , U > ( _: T ) -> U { todo ! ( ) }
15
+ fn foo < T > ( ) -> u32
16
+ where
17
+ ( ) : Trait < T > ,
18
+ ( ) : Trait < u32 > ,
19
+ {
20
+ impls_trait ( ( ) )
21
+ }
22
+
23
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/global-non-global-env-4.rs:21:5
3
+ |
4
+ LL | fn foo<T>() -> u32
5
+ | - --- expected `u32` because of return type
6
+ | |
7
+ | found this type parameter
8
+ ...
9
+ LL | impls_trait(())
10
+ | ^^^^^^^^^^^^^^^ expected `u32`, found type parameter `T`
11
+ |
12
+ = note: expected type `u32`
13
+ found type parameter `T`
14
+
15
+ error: aborting due to 1 previous error
16
+
17
+ For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
1
+ // A regression test for an edge case of candidate selection
2
+ // in the old trait solver, see #124592 for more details. Unlike
3
+ // the third test, this one has 3 impl candidates.
4
+
5
+ //@ revisions: current next
6
+ //@ ignore-compare-mode-next-solver (explicit revisions)
7
+ //@[next] compile-flags: -Znext-solver
8
+ //@[next] check-pass
9
+
10
+ trait Trait < T > { }
11
+ impl Trait < u32 > for ( ) { }
12
+ impl Trait < u64 > for ( ) { }
13
+ impl Trait < u128 > for ( ) { }
14
+
15
+ fn impls_trait < T : Trait < U > , U > ( _: T ) -> U { todo ! ( ) }
16
+ fn foo < T > ( ) -> u32
17
+ where
18
+ ( ) : Trait < T > ,
19
+ ( ) : Trait < u32 > ,
20
+ {
21
+ impls_trait ( ( ) )
22
+ //[current]~^ ERROR mismatched types
23
+ }
24
+
25
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments