Skip to content

Commit 502416f

Browse files
authored
Merge pull request #1301 from devonhollowood/wrong-self-convention-fix
Fix false positive for `wrong_self_convention`
2 parents 49c2c2c + 3a0d342 commit 502416f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clippy_lints/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ impl Convention {
12561256
fn check(&self, other: &str) -> bool {
12571257
match *self {
12581258
Convention::Eq(this) => this == other,
1259-
Convention::StartsWith(this) => other.starts_with(this),
1259+
Convention::StartsWith(this) => other.starts_with(this) && this != other,
12601260
}
12611261
}
12621262
}

tests/compile-fail/wrong_self_convention.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,10 @@ impl Bar {
4545
pub fn to_i64(self) {} //~ERROR: methods called `to_*` usually take self by reference
4646
pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self
4747

48+
// test for false positives
49+
fn as_(self) {}
50+
fn into_(&self) {}
51+
fn is_(self) {}
52+
fn to_(self) {}
53+
fn from_(self) {}
4854
}

0 commit comments

Comments
 (0)