Open
Description
The current nightly compiler gives the error "overflow evaluating requirement" when a type is used as a trait with a default impl. For example:
#![feature(specialization)]
fn main() {
println!("{}", <(usize) as TypeString>::type_string());
}
trait TypeString {
fn type_string() -> &'static str;
}
default impl<T> TypeString for T {
fn type_string() -> &'static str {
"unknown type"
}
}
impl TypeString for () {
fn type_string() -> &'static str {
"()"
}
}
...gives the following error:
error[E0275]: overflow evaluating the requirement `usize: TypeString`
--> src/main.rs:4:20
|
4 | println!("{}", <(usize) as TypeString>::type_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: required by `TypeString::type_string`
--> src/main.rs:8:5
|
8 | fn type_string() -> &'static str;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note that if we change <(usize) as TypeString>::type_string()
to <() as TypeString>::type_string()
- ()
has a specialized impl - it compiles and runs correctly.