I'd like rustc to warn me when I use a trait method on a std (or liballoc, core, ...) type without using the full trait path.
That is, if I implement my own trait for a std library type:
trait Foo { fn bar(&self); }
impl Foo for Vec<u32> {
fn bar(&self) { }
}
fn main() {
let v = Vec::new();
v.bar(); // Warning
Foo::bar(&v); // OK
}
The motivation is that:
- if the
std library adds a new trait with a method called foo and implements it for Vec<u32> my code stops compiling due to an ambiguity error
- if the
std library adds an inherent method to Vec<u32> called foothat has the same signature as Foo::foo, my code continues to compile but might silently change behavior
I don't know whether this warning should apply exclusively to the std library or to types defined in external crates as well.