diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 4bf8e806b7b..26679e11fc1 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1256,7 +1256,7 @@ impl Convention { fn check(&self, other: &str) -> bool { match *self { Convention::Eq(this) => this == other, - Convention::StartsWith(this) => other.starts_with(this), + Convention::StartsWith(this) => other.starts_with(this) && this != other, } } } diff --git a/tests/compile-fail/wrong_self_convention.rs b/tests/compile-fail/wrong_self_convention.rs index 682f522b363..f20b3d2d17b 100644 --- a/tests/compile-fail/wrong_self_convention.rs +++ b/tests/compile-fail/wrong_self_convention.rs @@ -45,4 +45,10 @@ impl Bar { pub fn to_i64(self) {} //~ERROR: methods called `to_*` usually take self by reference pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self + // test for false positives + fn as_(self) {} + fn into_(&self) {} + fn is_(self) {} + fn to_(self) {} + fn from_(self) {} }