fix
This commit is contained in:
parent
cef882cc9d
commit
51db157fb4
@ -296,15 +296,15 @@
|
|||||||
/// Checks for methods with certain name prefixes and which
|
/// Checks for methods with certain name prefixes and which
|
||||||
/// doesn't match how self is taken. The actual rules are:
|
/// doesn't match how self is taken. The actual rules are:
|
||||||
///
|
///
|
||||||
/// |Prefix |Postfix |`self` taken | `self` type |
|
/// |Prefix |Postfix |`self` taken | `self` type |
|
||||||
/// |-------|------------|-----------------------|--------------|
|
/// |-------|------------|-------------------------------|--------------|
|
||||||
/// |`as_` | none |`&self` or `&mut self` | any |
|
/// |`as_` | none |`&self` or `&mut self` | any |
|
||||||
/// |`from_`| none | none | any |
|
/// |`from_`| none | none | any |
|
||||||
/// |`into_`| none |`self` | any |
|
/// |`into_`| none |`self` | any |
|
||||||
/// |`is_` | none |`&self` or none | any |
|
/// |`is_` | none |`&mut self` or `&self` or none | any |
|
||||||
/// |`to_` | `_mut` |`&mut self` | any |
|
/// |`to_` | `_mut` |`&mut self` | any |
|
||||||
/// |`to_` | not `_mut` |`self` | `Copy` |
|
/// |`to_` | not `_mut` |`self` | `Copy` |
|
||||||
/// |`to_` | not `_mut` |`&self` | not `Copy` |
|
/// |`to_` | not `_mut` |`&self` | not `Copy` |
|
||||||
///
|
///
|
||||||
/// Note: Clippy doesn't trigger methods with `to_` prefix in:
|
/// Note: Clippy doesn't trigger methods with `to_` prefix in:
|
||||||
/// - Traits definition.
|
/// - Traits definition.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
(&[Convention::StartsWith("as_")], &[SelfKind::Ref, SelfKind::RefMut]),
|
(&[Convention::StartsWith("as_")], &[SelfKind::Ref, SelfKind::RefMut]),
|
||||||
(&[Convention::StartsWith("from_")], &[SelfKind::No]),
|
(&[Convention::StartsWith("from_")], &[SelfKind::No]),
|
||||||
(&[Convention::StartsWith("into_")], &[SelfKind::Value]),
|
(&[Convention::StartsWith("into_")], &[SelfKind::Value]),
|
||||||
(&[Convention::StartsWith("is_")], &[SelfKind::Ref, SelfKind::No]),
|
(&[Convention::StartsWith("is_")], &[SelfKind::RefMut, SelfKind::Ref, SelfKind::No]),
|
||||||
(&[Convention::Eq("to_mut")], &[SelfKind::RefMut]),
|
(&[Convention::Eq("to_mut")], &[SelfKind::RefMut]),
|
||||||
(&[Convention::StartsWith("to_"), Convention::EndsWith("_mut")], &[SelfKind::RefMut]),
|
(&[Convention::StartsWith("to_"), Convention::EndsWith("_mut")], &[SelfKind::RefMut]),
|
||||||
|
|
||||||
|
@ -193,11 +193,6 @@ pub mod issue8142 {
|
|||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
impl S {
|
impl S {
|
||||||
// Should lint: is_ methods should only take &self, or no self at all.
|
|
||||||
fn is_still_buggy(&mut self) -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should not lint: "no self at all" is allowed.
|
// Should not lint: "no self at all" is allowed.
|
||||||
fn is_forty_two(x: u32) -> bool {
|
fn is_forty_two(x: u32) -> bool {
|
||||||
x == 42
|
x == 42
|
||||||
|
@ -31,7 +31,7 @@ LL | fn into_i32(&self) {}
|
|||||||
|
|
|
|
||||||
= help: consider choosing a less ambiguous name
|
= help: consider choosing a less ambiguous name
|
||||||
|
|
||||||
error: methods called `is_*` usually take `self` by reference or no `self`
|
error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self`
|
||||||
--> $DIR/wrong_self_convention.rs:38:15
|
--> $DIR/wrong_self_convention.rs:38:15
|
||||||
|
|
|
|
||||||
LL | fn is_i32(self) {}
|
LL | fn is_i32(self) {}
|
||||||
@ -71,7 +71,7 @@ LL | pub fn into_i64(&self) {}
|
|||||||
|
|
|
|
||||||
= help: consider choosing a less ambiguous name
|
= help: consider choosing a less ambiguous name
|
||||||
|
|
||||||
error: methods called `is_*` usually take `self` by reference or no `self`
|
error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self`
|
||||||
--> $DIR/wrong_self_convention.rs:46:19
|
--> $DIR/wrong_self_convention.rs:46:19
|
||||||
|
|
|
|
||||||
LL | pub fn is_i64(self) {}
|
LL | pub fn is_i64(self) {}
|
||||||
@ -111,7 +111,7 @@ LL | fn into_i32_ref(&self) {}
|
|||||||
|
|
|
|
||||||
= help: consider choosing a less ambiguous name
|
= help: consider choosing a less ambiguous name
|
||||||
|
|
||||||
error: methods called `is_*` usually take `self` by reference or no `self`
|
error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self`
|
||||||
--> $DIR/wrong_self_convention.rs:98:19
|
--> $DIR/wrong_self_convention.rs:98:19
|
||||||
|
|
|
|
||||||
LL | fn is_i32(self) {}
|
LL | fn is_i32(self) {}
|
||||||
@ -143,7 +143,7 @@ LL | fn into_i32_ref(&self);
|
|||||||
|
|
|
|
||||||
= help: consider choosing a less ambiguous name
|
= help: consider choosing a less ambiguous name
|
||||||
|
|
||||||
error: methods called `is_*` usually take `self` by reference or no `self`
|
error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self`
|
||||||
--> $DIR/wrong_self_convention.rs:122:19
|
--> $DIR/wrong_self_convention.rs:122:19
|
||||||
|
|
|
|
||||||
LL | fn is_i32(self);
|
LL | fn is_i32(self);
|
||||||
@ -191,13 +191,5 @@ LL | fn to_u64(self) -> u64 {
|
|||||||
|
|
|
|
||||||
= help: consider choosing a less ambiguous name
|
= help: consider choosing a less ambiguous name
|
||||||
|
|
||||||
error: methods called `is_*` usually take `self` by reference or no `self`
|
error: aborting due to 24 previous errors
|
||||||
--> $DIR/wrong_self_convention.rs:197:27
|
|
||||||
|
|
|
||||||
LL | fn is_still_buggy(&mut self) -> bool {
|
|
||||||
| ^^^^^^^^^
|
|
||||||
|
|
|
||||||
= help: consider choosing a less ambiguous name
|
|
||||||
|
|
||||||
error: aborting due to 25 previous errors
|
|
||||||
|
|
||||||
|
@ -104,3 +104,13 @@ pub fn to_mut(self: Pin<&mut Self>) {}
|
|||||||
pub fn to_other_thingy(self: Pin<&Self>) {}
|
pub fn to_other_thingy(self: Pin<&Self>) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod issue_8480_8513 {
|
||||||
|
struct Cat(String);
|
||||||
|
|
||||||
|
impl Cat {
|
||||||
|
fn is_animal(&mut self) -> bool {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user