mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
fix ui tests
This commit is contained in:
parent
d635b76eaf
commit
c87d999fa2
13 changed files with 134 additions and 64 deletions
|
@ -1,4 +1,10 @@
|
|||
#![allow(unused, dead_code, clippy::needless_lifetimes, clippy::needless_pass_by_value)]
|
||||
#![allow(
|
||||
unused,
|
||||
dead_code,
|
||||
clippy::needless_lifetimes,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::needless_arbitrary_self_type
|
||||
)]
|
||||
#![warn(clippy::extra_unused_lifetimes)]
|
||||
|
||||
fn empty() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: this lifetime isn't used in the function definition
|
||||
--> $DIR/extra_unused_lifetimes.rs:8:14
|
||||
--> $DIR/extra_unused_lifetimes.rs:14:14
|
||||
|
|
||||
LL | fn unused_lt<'a>(x: u8) {}
|
||||
| ^^
|
||||
|
@ -7,19 +7,19 @@ LL | fn unused_lt<'a>(x: u8) {}
|
|||
= note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings`
|
||||
|
||||
error: this lifetime isn't used in the function definition
|
||||
--> $DIR/extra_unused_lifetimes.rs:10:25
|
||||
--> $DIR/extra_unused_lifetimes.rs:16:25
|
||||
|
|
||||
LL | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
|
||||
| ^^
|
||||
|
||||
error: this lifetime isn't used in the function definition
|
||||
--> $DIR/extra_unused_lifetimes.rs:35:10
|
||||
--> $DIR/extra_unused_lifetimes.rs:41:10
|
||||
|
|
||||
LL | fn x<'a>(&self) {}
|
||||
| ^^
|
||||
|
||||
error: this lifetime isn't used in the function definition
|
||||
--> $DIR/extra_unused_lifetimes.rs:61:22
|
||||
--> $DIR/extra_unused_lifetimes.rs:67:22
|
||||
|
|
||||
LL | fn unused_lt<'a>(x: u8) {}
|
||||
| ^^
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
pub struct PubOne;
|
||||
|
||||
impl PubOne {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
impl PubOne {
|
||||
// A second impl for this struct -- the error span shouldn't mention this.
|
||||
pub fn irrelevant(self: &Self) -> bool {
|
||||
pub fn irrelevant(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ pub struct PubAllowed;
|
|||
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
impl PubAllowed {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
@ -29,17 +29,17 @@ impl PubAllowed {
|
|||
// No `allow` attribute on this impl block, but that doesn't matter -- we only require one on the
|
||||
// impl containing `len`.
|
||||
impl PubAllowed {
|
||||
pub fn irrelevant(self: &Self) -> bool {
|
||||
pub fn irrelevant(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PubTraitsToo {
|
||||
fn len(self: &Self) -> isize;
|
||||
fn len(&self) -> isize;
|
||||
}
|
||||
|
||||
impl PubTraitsToo for One {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ impl PubTraitsToo for One {
|
|||
pub struct HasIsEmpty;
|
||||
|
||||
impl HasIsEmpty {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
fn is_empty(self: &Self) -> bool {
|
||||
fn is_empty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ impl HasIsEmpty {
|
|||
pub struct HasWrongIsEmpty;
|
||||
|
||||
impl HasWrongIsEmpty {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
pub fn is_empty(self: &Self, x: u32) -> bool {
|
||||
pub fn is_empty(&self, x: u32) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ impl HasWrongIsEmpty {
|
|||
struct NotPubOne;
|
||||
|
||||
impl NotPubOne {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
// No error; `len` is pub but `NotPubOne` is not exported anyway.
|
||||
1
|
||||
}
|
||||
|
@ -80,19 +80,19 @@ impl NotPubOne {
|
|||
struct One;
|
||||
|
||||
impl One {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
// No error; `len` is private; see issue #1085.
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
trait TraitsToo {
|
||||
fn len(self: &Self) -> isize;
|
||||
fn len(&self) -> isize;
|
||||
// No error; `len` is private; see issue #1085.
|
||||
}
|
||||
|
||||
impl TraitsToo for One {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
@ -100,11 +100,11 @@ impl TraitsToo for One {
|
|||
struct HasPrivateIsEmpty;
|
||||
|
||||
impl HasPrivateIsEmpty {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
fn is_empty(self: &Self) -> bool {
|
||||
fn is_empty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -112,16 +112,16 @@ impl HasPrivateIsEmpty {
|
|||
struct Wither;
|
||||
|
||||
pub trait WithIsEmpty {
|
||||
fn len(self: &Self) -> isize;
|
||||
fn is_empty(self: &Self) -> bool;
|
||||
fn len(&self) -> isize;
|
||||
fn is_empty(&self) -> bool;
|
||||
}
|
||||
|
||||
impl WithIsEmpty for Wither {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
fn is_empty(self: &Self) -> bool {
|
||||
fn is_empty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` m
|
|||
--> $DIR/len_without_is_empty.rs:6:1
|
||||
|
|
||||
LL | / impl PubOne {
|
||||
LL | | pub fn len(self: &Self) -> isize {
|
||||
LL | | pub fn len(&self) -> isize {
|
||||
LL | | 1
|
||||
LL | | }
|
||||
LL | | }
|
||||
|
@ -14,7 +14,7 @@ error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_e
|
|||
--> $DIR/len_without_is_empty.rs:37:1
|
||||
|
|
||||
LL | / pub trait PubTraitsToo {
|
||||
LL | | fn len(self: &Self) -> isize;
|
||||
LL | | fn len(&self) -> isize;
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
|
@ -22,7 +22,7 @@ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` meth
|
|||
--> $DIR/len_without_is_empty.rs:49:1
|
||||
|
|
||||
LL | / impl HasIsEmpty {
|
||||
LL | | pub fn len(self: &Self) -> isize {
|
||||
LL | | pub fn len(&self) -> isize {
|
||||
LL | | 1
|
||||
LL | | }
|
||||
... |
|
||||
|
@ -34,7 +34,7 @@ error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is
|
|||
--> $DIR/len_without_is_empty.rs:61:1
|
||||
|
|
||||
LL | / impl HasWrongIsEmpty {
|
||||
LL | | pub fn len(self: &Self) -> isize {
|
||||
LL | | pub fn len(&self) -> isize {
|
||||
LL | | 1
|
||||
LL | | }
|
||||
... |
|
||||
|
|
|
@ -7,12 +7,12 @@ pub struct One;
|
|||
struct Wither;
|
||||
|
||||
trait TraitsToo {
|
||||
fn len(self: &Self) -> isize;
|
||||
fn len(&self) -> isize;
|
||||
// No error; `len` is private; see issue #1085.
|
||||
}
|
||||
|
||||
impl TraitsToo for One {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ impl TraitsToo for One {
|
|||
pub struct HasIsEmpty;
|
||||
|
||||
impl HasIsEmpty {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
fn is_empty(self: &Self) -> bool {
|
||||
fn is_empty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -32,26 +32,26 @@ impl HasIsEmpty {
|
|||
pub struct HasWrongIsEmpty;
|
||||
|
||||
impl HasWrongIsEmpty {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
pub fn is_empty(self: &Self, x: u32) -> bool {
|
||||
pub fn is_empty(&self, x: u32) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub trait WithIsEmpty {
|
||||
fn len(self: &Self) -> isize;
|
||||
fn is_empty(self: &Self) -> bool;
|
||||
fn len(&self) -> isize;
|
||||
fn is_empty(&self) -> bool;
|
||||
}
|
||||
|
||||
impl WithIsEmpty for Wither {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
fn is_empty(self: &Self) -> bool {
|
||||
fn is_empty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ pub struct One;
|
|||
struct Wither;
|
||||
|
||||
trait TraitsToo {
|
||||
fn len(self: &Self) -> isize;
|
||||
fn len(&self) -> isize;
|
||||
// No error; `len` is private; see issue #1085.
|
||||
}
|
||||
|
||||
impl TraitsToo for One {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ impl TraitsToo for One {
|
|||
pub struct HasIsEmpty;
|
||||
|
||||
impl HasIsEmpty {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
fn is_empty(self: &Self) -> bool {
|
||||
fn is_empty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -32,26 +32,26 @@ impl HasIsEmpty {
|
|||
pub struct HasWrongIsEmpty;
|
||||
|
||||
impl HasWrongIsEmpty {
|
||||
pub fn len(self: &Self) -> isize {
|
||||
pub fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
pub fn is_empty(self: &Self, x: u32) -> bool {
|
||||
pub fn is_empty(&self, x: u32) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub trait WithIsEmpty {
|
||||
fn len(self: &Self) -> isize;
|
||||
fn is_empty(self: &Self) -> bool;
|
||||
fn len(&self) -> isize;
|
||||
fn is_empty(&self) -> bool;
|
||||
}
|
||||
|
||||
impl WithIsEmpty for Wither {
|
||||
fn len(self: &Self) -> isize {
|
||||
fn len(&self) -> isize {
|
||||
1
|
||||
}
|
||||
|
||||
fn is_empty(self: &Self) -> bool {
|
||||
fn is_empty(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
61
tests/ui/needless_arbitrary_self_type.fixed
Normal file
61
tests/ui/needless_arbitrary_self_type.fixed
Normal file
|
@ -0,0 +1,61 @@
|
|||
// run-rustfix
|
||||
|
||||
#![warn(clippy::needless_arbitrary_self_type)]
|
||||
#![allow(unused_mut, clippy::needless_lifetimes)]
|
||||
|
||||
pub enum ValType {
|
||||
A,
|
||||
B,
|
||||
}
|
||||
|
||||
impl ValType {
|
||||
pub fn bad(self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn good(self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_bad(mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_good(mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn ref_bad(&self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn ref_bad_with_lifetime<'a>(&'a self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn ref_good(&self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_ref_bad(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_ref_bad_with_lifetime<'a>(&'a mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_ref_good(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_ref_mut_bad(&mut self) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn mut_ref_mut_ref_good(self: &&mut &mut Self) {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -1,4 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![warn(clippy::needless_arbitrary_self_type)]
|
||||
#![allow(unused_mut, clippy::needless_lifetimes)]
|
||||
|
||||
pub enum ValType {
|
||||
A,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: the type of the `self` parameter is arbitrary
|
||||
--> $DIR/needless_arbitrary_self_type.rs:9:16
|
||||
--> $DIR/needless_arbitrary_self_type.rs:12:16
|
||||
|
|
||||
LL | pub fn bad(self: Self) {
|
||||
| ^^^^^^^^^^ help: consider to change this parameter to: `self`
|
||||
|
@ -7,37 +7,37 @@ LL | pub fn bad(self: Self) {
|
|||
= note: `-D clippy::needless-arbitrary-self-type` implied by `-D warnings`
|
||||
|
||||
error: the type of the `self` parameter is arbitrary
|
||||
--> $DIR/needless_arbitrary_self_type.rs:17:20
|
||||
--> $DIR/needless_arbitrary_self_type.rs:20:20
|
||||
|
|
||||
LL | pub fn mut_bad(mut self: Self) {
|
||||
| ^^^^^^^^^^^^^^ help: consider to change this parameter to: `mut self`
|
||||
|
||||
error: the type of the `self` parameter is arbitrary
|
||||
--> $DIR/needless_arbitrary_self_type.rs:25:20
|
||||
--> $DIR/needless_arbitrary_self_type.rs:28:20
|
||||
|
|
||||
LL | pub fn ref_bad(self: &Self) {
|
||||
| ^^^^^^^^^^^ help: consider to change this parameter to: `&self`
|
||||
|
||||
error: the type of the `self` parameter is arbitrary
|
||||
--> $DIR/needless_arbitrary_self_type.rs:29:38
|
||||
--> $DIR/needless_arbitrary_self_type.rs:32:38
|
||||
|
|
||||
LL | pub fn ref_bad_with_lifetime<'a>(self: &'a Self) {
|
||||
| ^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a self`
|
||||
|
||||
error: the type of the `self` parameter is arbitrary
|
||||
--> $DIR/needless_arbitrary_self_type.rs:37:24
|
||||
--> $DIR/needless_arbitrary_self_type.rs:40:24
|
||||
|
|
||||
LL | pub fn mut_ref_bad(self: &mut Self) {
|
||||
| ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self`
|
||||
|
||||
error: the type of the `self` parameter is arbitrary
|
||||
--> $DIR/needless_arbitrary_self_type.rs:41:42
|
||||
--> $DIR/needless_arbitrary_self_type.rs:44:42
|
||||
|
|
||||
LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) {
|
||||
| ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self`
|
||||
|
||||
error: the type of the `self` parameter is arbitrary
|
||||
--> $DIR/needless_arbitrary_self_type.rs:49:28
|
||||
--> $DIR/needless_arbitrary_self_type.rs:52:28
|
||||
|
|
||||
LL | pub fn mut_ref_mut_bad(mut self: &mut Self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self`
|
||||
|
|
|
@ -22,9 +22,9 @@ struct HasOption {
|
|||
}
|
||||
|
||||
impl HasOption {
|
||||
fn do_option_nothing(self: &Self, value: usize) {}
|
||||
fn do_option_nothing(&self, value: usize) {}
|
||||
|
||||
fn do_option_plus_one(self: &Self, value: usize) -> usize {
|
||||
fn do_option_plus_one(&self, value: usize) -> usize {
|
||||
value + 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ struct HasOption {
|
|||
}
|
||||
|
||||
impl HasOption {
|
||||
fn do_option_nothing(self: &Self, value: usize) {}
|
||||
fn do_option_nothing(&self, value: usize) {}
|
||||
|
||||
fn do_option_plus_one(self: &Self, value: usize) -> usize {
|
||||
fn do_option_plus_one(&self, value: usize) -> usize {
|
||||
value + 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ struct HasResult {
|
|||
}
|
||||
|
||||
impl HasResult {
|
||||
fn do_result_nothing(self: &Self, value: usize) {}
|
||||
fn do_result_nothing(&self, value: usize) {}
|
||||
|
||||
fn do_result_plus_one(self: &Self, value: usize) -> usize {
|
||||
fn do_result_plus_one(&self, value: usize) -> usize {
|
||||
value + 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ struct HasResult {
|
|||
}
|
||||
|
||||
impl HasResult {
|
||||
fn do_result_nothing(self: &Self, value: usize) {}
|
||||
fn do_result_nothing(&self, value: usize) {}
|
||||
|
||||
fn do_result_plus_one(self: &Self, value: usize) -> usize {
|
||||
fn do_result_plus_one(&self, value: usize) -> usize {
|
||||
value + 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue