Open
Description
STR
#![feature(specialization)]
struct My<T>(T);
trait Conv<T> {
fn conv(self) -> T;
}
impl<T> Conv<T> for My<T> {
default fn conv(self) -> T { self.0 }
}
#[cfg(broken)]
impl Conv<u32> for My<u32> {
default fn conv(self) -> u32 { self.0 }
}
fn main() {
let x = My(0);
x.conv() + 0i32;
}
Expected Result
Adding a specialized impl will not affect type inference.
Actual Result
After adding the specialized impl, inference is guided to take it:
error[E0308]: mismatched types
--> <anon>:20:16
|
20 | x.conv() + 0i32;
| ^^^^ expected u32, found i32
error[E0277]: the trait bound `u32: std::ops::Add<i32>` is not satisfied
--> <anon>:20:5
|
20 | x.conv() + 0i32;
| ^^^^^^^^^^^^^^^ trait `u32: std::ops::Add<i32>` not satisfied
|
= help: the following implementations were found:
= help: <u32 as std::ops::Add>
= help: <&'a u32 as std::ops::Add<u32>>
= help: <u32 as std::ops::Add<&'a u32>>
= help: <&'b u32 as std::ops::Add<&'a u32>>
error: aborting due to 2 previous errors