fix ui tests

This commit is contained in:
Christoph Walcher 2020-08-05 03:37:29 +02:00
parent d635b76eaf
commit c87d999fa2
No known key found for this signature in database
GPG Key ID: A193164A4D05EE44
13 changed files with 134 additions and 64 deletions

View File

@ -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)] #![warn(clippy::extra_unused_lifetimes)]
fn empty() {} fn empty() {}

View File

@ -1,5 +1,5 @@
error: this lifetime isn't used in the function definition 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) {} 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` = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings`
error: this lifetime isn't used in the function definition 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) { LL | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
| ^^ | ^^
error: this lifetime isn't used in the function definition 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) {} LL | fn x<'a>(&self) {}
| ^^ | ^^
error: this lifetime isn't used in the function definition 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) {} LL | fn unused_lt<'a>(x: u8) {}
| ^^ | ^^

View File

@ -4,14 +4,14 @@
pub struct PubOne; pub struct PubOne;
impl PubOne { impl PubOne {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
} }
impl PubOne { impl PubOne {
// A second impl for this struct -- the error span shouldn't mention this. // 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 false
} }
} }
@ -21,7 +21,7 @@ pub struct PubAllowed;
#[allow(clippy::len_without_is_empty)] #[allow(clippy::len_without_is_empty)]
impl PubAllowed { impl PubAllowed {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 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 // No `allow` attribute on this impl block, but that doesn't matter -- we only require one on the
// impl containing `len`. // impl containing `len`.
impl PubAllowed { impl PubAllowed {
pub fn irrelevant(self: &Self) -> bool { pub fn irrelevant(&self) -> bool {
false false
} }
} }
pub trait PubTraitsToo { pub trait PubTraitsToo {
fn len(self: &Self) -> isize; fn len(&self) -> isize;
} }
impl PubTraitsToo for One { impl PubTraitsToo for One {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
0 0
} }
} }
@ -47,11 +47,11 @@ impl PubTraitsToo for One {
pub struct HasIsEmpty; pub struct HasIsEmpty;
impl HasIsEmpty { impl HasIsEmpty {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
fn is_empty(self: &Self) -> bool { fn is_empty(&self) -> bool {
false false
} }
} }
@ -59,11 +59,11 @@ impl HasIsEmpty {
pub struct HasWrongIsEmpty; pub struct HasWrongIsEmpty;
impl HasWrongIsEmpty { impl HasWrongIsEmpty {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
pub fn is_empty(self: &Self, x: u32) -> bool { pub fn is_empty(&self, x: u32) -> bool {
false false
} }
} }
@ -71,7 +71,7 @@ impl HasWrongIsEmpty {
struct NotPubOne; struct NotPubOne;
impl 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. // No error; `len` is pub but `NotPubOne` is not exported anyway.
1 1
} }
@ -80,19 +80,19 @@ impl NotPubOne {
struct One; struct One;
impl One { impl One {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
// No error; `len` is private; see issue #1085. // No error; `len` is private; see issue #1085.
1 1
} }
} }
trait TraitsToo { trait TraitsToo {
fn len(self: &Self) -> isize; fn len(&self) -> isize;
// No error; `len` is private; see issue #1085. // No error; `len` is private; see issue #1085.
} }
impl TraitsToo for One { impl TraitsToo for One {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
0 0
} }
} }
@ -100,11 +100,11 @@ impl TraitsToo for One {
struct HasPrivateIsEmpty; struct HasPrivateIsEmpty;
impl HasPrivateIsEmpty { impl HasPrivateIsEmpty {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
fn is_empty(self: &Self) -> bool { fn is_empty(&self) -> bool {
false false
} }
} }
@ -112,16 +112,16 @@ impl HasPrivateIsEmpty {
struct Wither; struct Wither;
pub trait WithIsEmpty { pub trait WithIsEmpty {
fn len(self: &Self) -> isize; fn len(&self) -> isize;
fn is_empty(self: &Self) -> bool; fn is_empty(&self) -> bool;
} }
impl WithIsEmpty for Wither { impl WithIsEmpty for Wither {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
1 1
} }
fn is_empty(self: &Self) -> bool { fn is_empty(&self) -> bool {
false false
} }
} }

View File

@ -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 --> $DIR/len_without_is_empty.rs:6:1
| |
LL | / impl PubOne { LL | / impl PubOne {
LL | | pub fn len(self: &Self) -> isize { LL | | pub fn len(&self) -> isize {
LL | | 1 LL | | 1
LL | | } LL | | }
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 --> $DIR/len_without_is_empty.rs:37:1
| |
LL | / pub trait PubTraitsToo { LL | / pub trait PubTraitsToo {
LL | | fn len(self: &Self) -> isize; LL | | fn len(&self) -> isize;
LL | | } 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 --> $DIR/len_without_is_empty.rs:49:1
| |
LL | / impl HasIsEmpty { LL | / impl HasIsEmpty {
LL | | pub fn len(self: &Self) -> isize { LL | | pub fn len(&self) -> isize {
LL | | 1 LL | | 1
LL | | } 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 --> $DIR/len_without_is_empty.rs:61:1
| |
LL | / impl HasWrongIsEmpty { LL | / impl HasWrongIsEmpty {
LL | | pub fn len(self: &Self) -> isize { LL | | pub fn len(&self) -> isize {
LL | | 1 LL | | 1
LL | | } LL | | }
... | ... |

View File

@ -7,12 +7,12 @@ pub struct One;
struct Wither; struct Wither;
trait TraitsToo { trait TraitsToo {
fn len(self: &Self) -> isize; fn len(&self) -> isize;
// No error; `len` is private; see issue #1085. // No error; `len` is private; see issue #1085.
} }
impl TraitsToo for One { impl TraitsToo for One {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
0 0
} }
} }
@ -20,11 +20,11 @@ impl TraitsToo for One {
pub struct HasIsEmpty; pub struct HasIsEmpty;
impl HasIsEmpty { impl HasIsEmpty {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
fn is_empty(self: &Self) -> bool { fn is_empty(&self) -> bool {
false false
} }
} }
@ -32,26 +32,26 @@ impl HasIsEmpty {
pub struct HasWrongIsEmpty; pub struct HasWrongIsEmpty;
impl HasWrongIsEmpty { impl HasWrongIsEmpty {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
pub fn is_empty(self: &Self, x: u32) -> bool { pub fn is_empty(&self, x: u32) -> bool {
false false
} }
} }
pub trait WithIsEmpty { pub trait WithIsEmpty {
fn len(self: &Self) -> isize; fn len(&self) -> isize;
fn is_empty(self: &Self) -> bool; fn is_empty(&self) -> bool;
} }
impl WithIsEmpty for Wither { impl WithIsEmpty for Wither {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
1 1
} }
fn is_empty(self: &Self) -> bool { fn is_empty(&self) -> bool {
false false
} }
} }

View File

@ -7,12 +7,12 @@ pub struct One;
struct Wither; struct Wither;
trait TraitsToo { trait TraitsToo {
fn len(self: &Self) -> isize; fn len(&self) -> isize;
// No error; `len` is private; see issue #1085. // No error; `len` is private; see issue #1085.
} }
impl TraitsToo for One { impl TraitsToo for One {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
0 0
} }
} }
@ -20,11 +20,11 @@ impl TraitsToo for One {
pub struct HasIsEmpty; pub struct HasIsEmpty;
impl HasIsEmpty { impl HasIsEmpty {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
fn is_empty(self: &Self) -> bool { fn is_empty(&self) -> bool {
false false
} }
} }
@ -32,26 +32,26 @@ impl HasIsEmpty {
pub struct HasWrongIsEmpty; pub struct HasWrongIsEmpty;
impl HasWrongIsEmpty { impl HasWrongIsEmpty {
pub fn len(self: &Self) -> isize { pub fn len(&self) -> isize {
1 1
} }
pub fn is_empty(self: &Self, x: u32) -> bool { pub fn is_empty(&self, x: u32) -> bool {
false false
} }
} }
pub trait WithIsEmpty { pub trait WithIsEmpty {
fn len(self: &Self) -> isize; fn len(&self) -> isize;
fn is_empty(self: &Self) -> bool; fn is_empty(&self) -> bool;
} }
impl WithIsEmpty for Wither { impl WithIsEmpty for Wither {
fn len(self: &Self) -> isize { fn len(&self) -> isize {
1 1
} }
fn is_empty(self: &Self) -> bool { fn is_empty(&self) -> bool {
false false
} }
} }

View 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() {}

View File

@ -1,4 +1,7 @@
// run-rustfix
#![warn(clippy::needless_arbitrary_self_type)] #![warn(clippy::needless_arbitrary_self_type)]
#![allow(unused_mut, clippy::needless_lifetimes)]
pub enum ValType { pub enum ValType {
A, A,

View File

@ -1,5 +1,5 @@
error: the type of the `self` parameter is arbitrary 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) { LL | pub fn bad(self: Self) {
| ^^^^^^^^^^ help: consider to change this parameter to: `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` = note: `-D clippy::needless-arbitrary-self-type` implied by `-D warnings`
error: the type of the `self` parameter is arbitrary 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) { LL | pub fn mut_bad(mut self: Self) {
| ^^^^^^^^^^^^^^ help: consider to change this parameter to: `mut self` | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `mut self`
error: the type of the `self` parameter is arbitrary 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) { LL | pub fn ref_bad(self: &Self) {
| ^^^^^^^^^^^ help: consider to change this parameter to: `&self` | ^^^^^^^^^^^ help: consider to change this parameter to: `&self`
error: the type of the `self` parameter is arbitrary 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) { LL | pub fn ref_bad_with_lifetime<'a>(self: &'a Self) {
| ^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a self` | ^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a self`
error: the type of the `self` parameter is arbitrary 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) { LL | pub fn mut_ref_bad(self: &mut Self) {
| ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` | ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self`
error: the type of the `self` parameter is arbitrary 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) { LL | pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) {
| ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self` | ^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'a mut self`
error: the type of the `self` parameter is arbitrary 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) { LL | pub fn mut_ref_mut_bad(mut self: &mut Self) {
| ^^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self` | ^^^^^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&mut self`

View File

@ -22,9 +22,9 @@ struct HasOption {
} }
impl 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 value + 1
} }
} }

View File

@ -22,9 +22,9 @@ struct HasOption {
} }
impl 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 value + 1
} }
} }

View File

@ -18,9 +18,9 @@ struct HasResult {
} }
impl 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 value + 1
} }
} }

View File

@ -18,9 +18,9 @@ struct HasResult {
} }
impl 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 value + 1
} }
} }