From 3a0d342a331d367e495a64ba364fe3336d8adbd3 Mon Sep 17 00:00:00 2001 From: Devon Hollowood Date: Thu, 27 Oct 2016 01:11:34 -0700 Subject: [PATCH] Fix false positive for `wrong_self_convention` --- clippy_lints/src/methods.rs | 2 +- tests/compile-fail/wrong_self_convention.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index 4bf8e806b7bf..26679e11fc16 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 682f522b363d..f20b3d2d17b4 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) {} }