Open
Description
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 calledfoo
and implements it forVec<u32>
my code stops compiling due to an ambiguity error - if the
std
library adds an inherent method toVec<u32>
calledfoo
that has the same signature asFoo::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.