File tree 2 files changed +62
-0
lines changed
src/test/ui/specialization
2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( specialization) ]
2
+
3
+ // Regression test for a specialization-related ICE (#39448).
4
+
5
+ trait A : Sized {
6
+ fn foo ( self , _: Self ) -> Self {
7
+ self
8
+ }
9
+ }
10
+
11
+ impl A for u8 { }
12
+ impl A for u16 { }
13
+
14
+ impl FromA < u8 > for u16 {
15
+ fn from ( x : u8 ) -> u16 {
16
+ x as u16
17
+ }
18
+ }
19
+
20
+ trait FromA < T > {
21
+ fn from ( T ) -> Self ;
22
+ }
23
+
24
+ impl < T : A , U : A + FromA < T > > FromA < T > for U {
25
+ default fn from ( x : T ) -> Self {
26
+ ToA :: to ( x)
27
+ }
28
+ }
29
+
30
+ trait ToA < T > {
31
+ fn to ( self ) -> T ;
32
+ }
33
+
34
+ impl < T , U > ToA < U > for T
35
+ where
36
+ U : FromA < T > ,
37
+ {
38
+ fn to ( self ) -> U {
39
+ U :: from ( self )
40
+ }
41
+ }
42
+
43
+ #[ allow( dead_code) ]
44
+ fn foo < T : A , U : A > ( x : T , y : U ) -> U {
45
+ x. foo ( y. to ( ) ) . to ( ) //~ ERROR overflow evaluating the requirement
46
+ }
47
+
48
+ fn main ( ) {
49
+ let z = foo ( 8u8 , 1u16 ) ;
50
+ }
Original file line number Diff line number Diff line change
1
+ error[E0275]: overflow evaluating the requirement `T: FromA<U>`
2
+ --> $DIR/issue-39448.rs:45:13
3
+ |
4
+ LL | x.foo(y.to()).to() //~ ERROR overflow evaluating the requirement
5
+ | ^^
6
+ |
7
+ = note: required because of the requirements on the impl of `FromA<U>` for `T`
8
+ = note: required because of the requirements on the impl of `ToA<T>` for `U`
9
+
10
+ error: aborting due to previous error
11
+
12
+ For more information about this error, try `rustc --explain E0275`.
You can’t perform that action at this time.
0 commit comments