mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 21:53:23 +00:00
Auto merge of #6518 - ThibsG:CopyException, r=ebroto
Ensure `Copy` exception in trait definition for `wrong_self_conventio… Add a test case to ensure `Copy` exception is preserved also in trait definition, when passing `self` by value. Follow up of #6316 changelog: none
This commit is contained in:
commit
a02806e00d
2 changed files with 54 additions and 16 deletions
|
@ -94,7 +94,8 @@ mod issue6307 {
|
|||
trait T: Sized {
|
||||
fn as_i32(self) {}
|
||||
fn as_u32(&self) {}
|
||||
fn into_i32(&self) {}
|
||||
fn into_i32(self) {}
|
||||
fn into_i32_ref(&self) {}
|
||||
fn into_u32(self) {}
|
||||
fn is_i32(self) {}
|
||||
fn is_u32(&self) {}
|
||||
|
@ -117,7 +118,32 @@ mod issue6307 {
|
|||
trait U {
|
||||
fn as_i32(self);
|
||||
fn as_u32(&self);
|
||||
fn into_i32(&self);
|
||||
fn into_i32(self);
|
||||
fn into_i32_ref(&self);
|
||||
fn into_u32(self);
|
||||
fn is_i32(self);
|
||||
fn is_u32(&self);
|
||||
fn to_i32(self);
|
||||
fn to_u32(&self);
|
||||
fn from_i32(self);
|
||||
// check whether the lint can be allowed at the function level
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn from_cake(self);
|
||||
|
||||
// test for false positives
|
||||
fn as_(self);
|
||||
fn into_(&self);
|
||||
fn is_(self);
|
||||
fn to_(self);
|
||||
fn from_(self);
|
||||
fn to_mut(&mut self);
|
||||
}
|
||||
|
||||
trait C: Copy {
|
||||
fn as_i32(self);
|
||||
fn as_u32(&self);
|
||||
fn into_i32(self);
|
||||
fn into_i32_ref(&self);
|
||||
fn into_u32(self);
|
||||
fn is_i32(self);
|
||||
fn is_u32(&self);
|
||||
|
|
|
@ -79,58 +79,70 @@ LL | fn as_i32(self) {}
|
|||
| ^^^^
|
||||
|
||||
error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:97:21
|
||||
--> $DIR/wrong_self_convention.rs:98:25
|
||||
|
|
||||
LL | fn into_i32(&self) {}
|
||||
| ^^^^^
|
||||
LL | fn into_i32_ref(&self) {}
|
||||
| ^^^^^
|
||||
|
||||
error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:99:19
|
||||
--> $DIR/wrong_self_convention.rs:100:19
|
||||
|
|
||||
LL | fn is_i32(self) {}
|
||||
| ^^^^
|
||||
|
||||
error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:101:19
|
||||
--> $DIR/wrong_self_convention.rs:102:19
|
||||
|
|
||||
LL | fn to_i32(self) {}
|
||||
| ^^^^
|
||||
|
||||
error: methods called `from_*` usually take no self; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:103:21
|
||||
--> $DIR/wrong_self_convention.rs:104:21
|
||||
|
|
||||
LL | fn from_i32(self) {}
|
||||
| ^^^^
|
||||
|
||||
error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:118:19
|
||||
--> $DIR/wrong_self_convention.rs:119:19
|
||||
|
|
||||
LL | fn as_i32(self);
|
||||
| ^^^^
|
||||
|
||||
error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:120:21
|
||||
--> $DIR/wrong_self_convention.rs:122:25
|
||||
|
|
||||
LL | fn into_i32(&self);
|
||||
| ^^^^^
|
||||
LL | fn into_i32_ref(&self);
|
||||
| ^^^^^
|
||||
|
||||
error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:122:19
|
||||
--> $DIR/wrong_self_convention.rs:124:19
|
||||
|
|
||||
LL | fn is_i32(self);
|
||||
| ^^^^
|
||||
|
||||
error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:124:19
|
||||
--> $DIR/wrong_self_convention.rs:126:19
|
||||
|
|
||||
LL | fn to_i32(self);
|
||||
| ^^^^
|
||||
|
||||
error: methods called `from_*` usually take no self; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:126:21
|
||||
--> $DIR/wrong_self_convention.rs:128:21
|
||||
|
|
||||
LL | fn from_i32(self);
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:146:25
|
||||
|
|
||||
LL | fn into_i32_ref(&self);
|
||||
| ^^^^^
|
||||
|
||||
error: methods called `from_*` usually take no self; consider choosing a less ambiguous name
|
||||
--> $DIR/wrong_self_convention.rs:152:21
|
||||
|
|
||||
LL | fn from_i32(self);
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 24 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue