Skip to content

Commit e23a424

Browse files
james9909flip1995
authored andcommitted
Change lint to be pedantic
1 parent e64b275 commit e23a424

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+176
-191
lines changed

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
685685
types::LINKEDLIST,
686686
unicode::NON_ASCII_LITERAL,
687687
unicode::UNICODE_NOT_NFC,
688+
unused_self::UNUSED_SELF,
688689
use_self::USE_SELF,
689690
]);
690691

@@ -928,7 +929,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
928929
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
929930
unused_io_amount::UNUSED_IO_AMOUNT,
930931
unused_label::UNUSED_LABEL,
931-
unused_self::UNUSED_SELF,
932932
unwrap::PANICKING_UNWRAP,
933933
unwrap::UNNECESSARY_UNWRAP,
934934
vec::USELESS_VEC,
@@ -1107,7 +1107,6 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry<'_>, conf: &Con
11071107
types::UNNECESSARY_CAST,
11081108
types::VEC_BOX,
11091109
unused_label::UNUSED_LABEL,
1110-
unused_self::UNUSED_SELF,
11111110
unwrap::UNNECESSARY_UNWRAP,
11121111
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
11131112
]);

clippy_lints/src/unused_self.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ declare_clippy_lint! {
3232
/// }
3333
/// ```
3434
pub UNUSED_SELF,
35-
complexity,
35+
pedantic,
3636
"methods that contain a `self` argument but don't use it"
3737
}
3838

@@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedSelf {
5656
let body = cx.tcx.hir().body(*body_id);
5757
let self_param = &body.params[0];
5858
let self_hir_id = self_param.pat.hir_id;
59-
let visitor = &mut UnusedSelfVisitor {
59+
let mut visitor = UnusedSelfVisitor {
6060
cx,
6161
uses_self: false,
6262
self_hir_id: &self_hir_id,

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ pub const ALL_LINTS: [Lint; 325] = [
20882088
},
20892089
Lint {
20902090
name: "unused_self",
2091-
group: "complexity",
2091+
group: "pedantic",
20922092
desc: "methods that contain a `self` argument but don\'t use it",
20932093
deprecation: None,
20942094
module: "unused_self",

tests/ui/booleans.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![warn(clippy::nonminimal_bool, clippy::logic_bug)]
2-
#![allow(clippy::unused_self)]
32

43
#[allow(unused, clippy::many_single_char_names)]
54
fn main() {

tests/ui/booleans.stderr

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
11
error: this boolean expression contains a logic bug
2-
--> $DIR/booleans.rs:11:13
2+
--> $DIR/booleans.rs:10:13
33
|
44
LL | let _ = a && b || a;
55
| ^^^^^^^^^^^ help: it would look like the following: `a`
66
|
77
= note: `-D clippy::logic-bug` implied by `-D warnings`
88
help: this expression can be optimized out by applying boolean operations to the outer expression
9-
--> $DIR/booleans.rs:11:18
9+
--> $DIR/booleans.rs:10:18
1010
|
1111
LL | let _ = a && b || a;
1212
| ^
1313

1414
error: this boolean expression can be simplified
15-
--> $DIR/booleans.rs:13:13
15+
--> $DIR/booleans.rs:12:13
1616
|
1717
LL | let _ = !true;
1818
| ^^^^^ help: try: `false`
1919
|
2020
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
2121

2222
error: this boolean expression can be simplified
23-
--> $DIR/booleans.rs:14:13
23+
--> $DIR/booleans.rs:13:13
2424
|
2525
LL | let _ = !false;
2626
| ^^^^^^ help: try: `true`
2727

2828
error: this boolean expression can be simplified
29-
--> $DIR/booleans.rs:15:13
29+
--> $DIR/booleans.rs:14:13
3030
|
3131
LL | let _ = !!a;
3232
| ^^^ help: try: `a`
3333

3434
error: this boolean expression contains a logic bug
35-
--> $DIR/booleans.rs:16:13
35+
--> $DIR/booleans.rs:15:13
3636
|
3737
LL | let _ = false && a;
3838
| ^^^^^^^^^^ help: it would look like the following: `false`
3939
|
4040
help: this expression can be optimized out by applying boolean operations to the outer expression
41-
--> $DIR/booleans.rs:16:22
41+
--> $DIR/booleans.rs:15:22
4242
|
4343
LL | let _ = false && a;
4444
| ^
4545

4646
error: this boolean expression can be simplified
47-
--> $DIR/booleans.rs:17:13
47+
--> $DIR/booleans.rs:16:13
4848
|
4949
LL | let _ = false || a;
5050
| ^^^^^^^^^^ help: try: `a`
5151

5252
error: this boolean expression can be simplified
53-
--> $DIR/booleans.rs:22:13
53+
--> $DIR/booleans.rs:21:13
5454
|
5555
LL | let _ = !(!a && b);
5656
| ^^^^^^^^^^ help: try: `!b || a`
5757

5858
error: this boolean expression contains a logic bug
59-
--> $DIR/booleans.rs:32:13
59+
--> $DIR/booleans.rs:31:13
6060
|
6161
LL | let _ = a == b && a != b;
6262
| ^^^^^^^^^^^^^^^^ help: it would look like the following: `false`
6363
|
6464
help: this expression can be optimized out by applying boolean operations to the outer expression
65-
--> $DIR/booleans.rs:32:13
65+
--> $DIR/booleans.rs:31:13
6666
|
6767
LL | let _ = a == b && a != b;
6868
| ^^^^^^
6969

7070
error: this boolean expression can be simplified
71-
--> $DIR/booleans.rs:33:13
71+
--> $DIR/booleans.rs:32:13
7272
|
7373
LL | let _ = a == b && c == 5 && a == b;
7474
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -80,7 +80,7 @@ LL | let _ = !(c != 5 || a != b);
8080
| ^^^^^^^^^^^^^^^^^^^
8181

8282
error: this boolean expression can be simplified
83-
--> $DIR/booleans.rs:34:13
83+
--> $DIR/booleans.rs:33:13
8484
|
8585
LL | let _ = a == b && c == 5 && b == a;
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -92,31 +92,31 @@ LL | let _ = !(c != 5 || a != b);
9292
| ^^^^^^^^^^^^^^^^^^^
9393

9494
error: this boolean expression contains a logic bug
95-
--> $DIR/booleans.rs:35:13
95+
--> $DIR/booleans.rs:34:13
9696
|
9797
LL | let _ = a < b && a >= b;
9898
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
9999
|
100100
help: this expression can be optimized out by applying boolean operations to the outer expression
101-
--> $DIR/booleans.rs:35:13
101+
--> $DIR/booleans.rs:34:13
102102
|
103103
LL | let _ = a < b && a >= b;
104104
| ^^^^^
105105

106106
error: this boolean expression contains a logic bug
107-
--> $DIR/booleans.rs:36:13
107+
--> $DIR/booleans.rs:35:13
108108
|
109109
LL | let _ = a > b && a <= b;
110110
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
111111
|
112112
help: this expression can be optimized out by applying boolean operations to the outer expression
113-
--> $DIR/booleans.rs:36:13
113+
--> $DIR/booleans.rs:35:13
114114
|
115115
LL | let _ = a > b && a <= b;
116116
| ^^^^^
117117

118118
error: this boolean expression can be simplified
119-
--> $DIR/booleans.rs:38:13
119+
--> $DIR/booleans.rs:37:13
120120
|
121121
LL | let _ = a != b || !(a != b || c == d);
122122
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -128,73 +128,73 @@ LL | let _ = !(a == b && c == d);
128128
| ^^^^^^^^^^^^^^^^^^^
129129

130130
error: this boolean expression can be simplified
131-
--> $DIR/booleans.rs:46:13
131+
--> $DIR/booleans.rs:45:13
132132
|
133133
LL | let _ = !a.is_some();
134134
| ^^^^^^^^^^^^ help: try: `a.is_none()`
135135

136136
error: this boolean expression can be simplified
137-
--> $DIR/booleans.rs:48:13
137+
--> $DIR/booleans.rs:47:13
138138
|
139139
LL | let _ = !a.is_none();
140140
| ^^^^^^^^^^^^ help: try: `a.is_some()`
141141

142142
error: this boolean expression can be simplified
143-
--> $DIR/booleans.rs:50:13
143+
--> $DIR/booleans.rs:49:13
144144
|
145145
LL | let _ = !b.is_err();
146146
| ^^^^^^^^^^^ help: try: `b.is_ok()`
147147

148148
error: this boolean expression can be simplified
149-
--> $DIR/booleans.rs:52:13
149+
--> $DIR/booleans.rs:51:13
150150
|
151151
LL | let _ = !b.is_ok();
152152
| ^^^^^^^^^^ help: try: `b.is_err()`
153153

154154
error: this boolean expression can be simplified
155-
--> $DIR/booleans.rs:54:13
155+
--> $DIR/booleans.rs:53:13
156156
|
157157
LL | let _ = !(a.is_some() && !c);
158158
| ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()`
159159

160160
error: this boolean expression can be simplified
161-
--> $DIR/booleans.rs:55:26
161+
--> $DIR/booleans.rs:54:26
162162
|
163163
LL | let _ = !(!c ^ c) || !a.is_some();
164164
| ^^^^^^^^^^^^ help: try: `a.is_none()`
165165

166166
error: this boolean expression can be simplified
167-
--> $DIR/booleans.rs:56:25
167+
--> $DIR/booleans.rs:55:25
168168
|
169169
LL | let _ = (!c ^ c) || !a.is_some();
170170
| ^^^^^^^^^^^^ help: try: `a.is_none()`
171171

172172
error: this boolean expression can be simplified
173-
--> $DIR/booleans.rs:57:23
173+
--> $DIR/booleans.rs:56:23
174174
|
175175
LL | let _ = !c ^ c || !a.is_some();
176176
| ^^^^^^^^^^^^ help: try: `a.is_none()`
177177

178178
error: this boolean expression can be simplified
179-
--> $DIR/booleans.rs:129:8
179+
--> $DIR/booleans.rs:128:8
180180
|
181181
LL | if !res.is_ok() {}
182182
| ^^^^^^^^^^^^ help: try: `res.is_err()`
183183

184184
error: this boolean expression can be simplified
185-
--> $DIR/booleans.rs:130:8
185+
--> $DIR/booleans.rs:129:8
186186
|
187187
LL | if !res.is_err() {}
188188
| ^^^^^^^^^^^^^ help: try: `res.is_ok()`
189189

190190
error: this boolean expression can be simplified
191-
--> $DIR/booleans.rs:133:8
191+
--> $DIR/booleans.rs:132:8
192192
|
193193
LL | if !res.is_some() {}
194194
| ^^^^^^^^^^^^^^ help: try: `res.is_none()`
195195

196196
error: this boolean expression can be simplified
197-
--> $DIR/booleans.rs:134:8
197+
--> $DIR/booleans.rs:133:8
198198
|
199199
LL | if !res.is_none() {}
200200
| ^^^^^^^^^^^^^^ help: try: `res.is_some()`

tests/ui/complex_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::all)]
2-
#![allow(unused, clippy::needless_pass_by_value, clippy::vec_box, clippy::unused_self)]
2+
#![allow(unused, clippy::needless_pass_by_value, clippy::vec_box)]
33
#![feature(associated_type_defaults)]
44

55
type Alias = Vec<Vec<Box<(u32, u32, u32, u32)>>>; // no warning here

tests/ui/def_id_nocore.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
2222

2323
pub struct A;
2424

25-
#[allow(clippy::unused_self)]
2625
impl A {
2726
pub fn as_ref(self) -> &'static str {
2827
"A"

tests/ui/def_id_nocore.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name
2-
--> $DIR/def_id_nocore.rs:27:19
2+
--> $DIR/def_id_nocore.rs:26:19
33
|
44
LL | pub fn as_ref(self) -> &'static str {
55
| ^^^^

tests/ui/diverging_sub_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(never_type)]
22
#![warn(clippy::diverging_sub_expression)]
3-
#![allow(clippy::match_same_arms, clippy::logic_bug, clippy::unused_self)]
3+
#![allow(clippy::match_same_arms, clippy::logic_bug)]
44

55
#[allow(clippy::empty_loop)]
66
fn diverge() -> ! {

tests/ui/eta.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
clippy::many_single_char_names,
88
clippy::needless_pass_by_value,
99
clippy::option_map_unit_fn,
10-
clippy::trivially_copy_pass_by_ref,
11-
clippy::unused_self
10+
clippy::trivially_copy_pass_by_ref
1211
)]
1312
#![warn(
1413
clippy::redundant_closure,

tests/ui/eta.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
clippy::many_single_char_names,
88
clippy::needless_pass_by_value,
99
clippy::option_map_unit_fn,
10-
clippy::trivially_copy_pass_by_ref,
11-
clippy::unused_self
10+
clippy::trivially_copy_pass_by_ref
1211
)]
1312
#![warn(
1413
clippy::redundant_closure,

0 commit comments

Comments
 (0)