Closed
Description
This program fails to compile:
use std::ops::Add;
struct BigFloat;
impl Add<BigFloat> for f64 {
type Output = BigFloat;
fn add(self, rhs: BigFloat) -> BigFloat {
BigFloat
}
}
fn main() {}
The error:
test7.rs:5:1: 11:2 error: the type `f64` does not reference any types defined in this crate; only traits defined in the current crate can be implemented for arbitrary types [E0117]
test7.rs:5 impl Add<BigFloat> for f64 {
test7.rs:6 type Output = BigFloat;
test7.rs:7
test7.rs:8 fn add(self, rhs: BigFloat) -> BigFloat {
test7.rs:9 BigFloat
test7.rs:10 }
...
error: aborting due to previous error
I would expect that this should work because Add
's parameter is "local" type. Associated types and multidispatch RFC agrees with me.