Closed
Description
What it does
What does this lint do?
A struct has two methods with the same name:
one defined in impl trait
, another in normal impl
.
We shouldn't lint two method in two traits.This may break a lot. (I'm not sure)
Categories
clippy::all
, clippy::style
What is the advantage of the recommended code over the original code
- Remove confusing method call.
Drawbacks
Maybe meet difficulty in renaming the methods.
Example
trait T1 {
fn foo(&self) {}
}
struct S;
impl S {
fn foo(&self) {
dbg!("impl");
}
}
impl T1 for S {
fn foo(&self) {
dbg!("T1");
}
}
fn bar<T: T1>(x: T) {
x.foo(); // which foo?
}
fn main() {
bar(S);
let s = S;
s.foo(); // which foo?
}