Skip to content

Commit 70d029b

Browse files
committed
Fix tests after no_effect update
1 parent cdba2ca commit 70d029b

Some content is hidden

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

45 files changed

+599
-102
lines changed

clippy_lints/src/no_effect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ declare_lint_pass!(NoEffect => [NO_EFFECT, UNNECESSARY_OPERATION]);
4949
impl<'tcx> LateLintPass<'tcx> for NoEffect {
5050
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
5151
if check_no_effect(cx, stmt) {
52-
return
52+
return;
5353
}
5454
check_reduce_expression(cx, stmt);
5555
}
5656
}
5757

58-
fn check_no_effect(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) -> bool{
58+
fn check_no_effect(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) -> bool {
5959
if let StmtKind::Semi(expr) = stmt.kind {
6060
if has_no_effect(cx, expr) {
6161
span_lint_hir(cx, NO_EFFECT, expr.hir_id, stmt.span, "statement with no effect");

tests/ui/async_yields_async.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// edition:2018
33

44
#![feature(async_closure)]
5+
#![allow(clippy::no_effect)]
56
#![warn(clippy::async_yields_async)]
67

78
use core::future::Future;

tests/ui/async_yields_async.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// edition:2018
33

44
#![feature(async_closure)]
5+
#![allow(clippy::no_effect)]
56
#![warn(clippy::async_yields_async)]
67

78
use core::future::Future;

tests/ui/async_yields_async.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: an async construct yields a type which is itself awaitable
2-
--> $DIR/async_yields_async.rs:40:9
2+
--> $DIR/async_yields_async.rs:41:9
33
|
44
LL | let _h = async {
55
| ____________________-
@@ -20,7 +20,7 @@ LL + }.await
2020
|
2121

2222
error: an async construct yields a type which is itself awaitable
23-
--> $DIR/async_yields_async.rs:45:9
23+
--> $DIR/async_yields_async.rs:46:9
2424
|
2525
LL | let _i = async {
2626
| ____________________-
@@ -33,7 +33,7 @@ LL | | };
3333
| |_____- outer async construct
3434

3535
error: an async construct yields a type which is itself awaitable
36-
--> $DIR/async_yields_async.rs:51:9
36+
--> $DIR/async_yields_async.rs:52:9
3737
|
3838
LL | let _j = async || {
3939
| _______________________-
@@ -53,7 +53,7 @@ LL + }.await
5353
|
5454

5555
error: an async construct yields a type which is itself awaitable
56-
--> $DIR/async_yields_async.rs:56:9
56+
--> $DIR/async_yields_async.rs:57:9
5757
|
5858
LL | let _k = async || {
5959
| _______________________-
@@ -66,7 +66,7 @@ LL | | };
6666
| |_____- outer async construct
6767

6868
error: an async construct yields a type which is itself awaitable
69-
--> $DIR/async_yields_async.rs:58:23
69+
--> $DIR/async_yields_async.rs:59:23
7070
|
7171
LL | let _l = async || CustomFutureType;
7272
| ^^^^^^^^^^^^^^^^
@@ -76,7 +76,7 @@ LL | let _l = async || CustomFutureType;
7676
| help: consider awaiting this value: `CustomFutureType.await`
7777

7878
error: an async construct yields a type which is itself awaitable
79-
--> $DIR/async_yields_async.rs:64:9
79+
--> $DIR/async_yields_async.rs:65:9
8080
|
8181
LL | let _m = async || {
8282
| _______________________-

tests/ui/auxiliary/proc_macro_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![crate_type = "proc-macro"]
55
#![feature(repr128, proc_macro_hygiene, proc_macro_quote, box_patterns)]
66
#![allow(incomplete_features)]
7-
#![allow(clippy::useless_conversion)]
7+
#![allow(clippy::useless_conversion, clippy::no_effect)]
88

99
extern crate proc_macro;
1010
extern crate quote;

tests/ui/auxiliary/proc_macro_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![crate_type = "proc-macro"]
55
#![feature(repr128, proc_macro_quote)]
66
#![allow(incomplete_features)]
7-
#![allow(clippy::field_reassign_with_default)]
7+
#![allow(clippy::field_reassign_with_default, clippy::no_effect)]
88
#![allow(clippy::eq_op)]
99

1010
extern crate proc_macro;

tests/ui/borrow_interior_mutable_const/others.stderr

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutabi
1515
|
1616
= help: assign this const to a local or static variable, and use the variable here
1717

18+
error: statement with no effect
19+
--> $DIR/others.rs:61:5
20+
|
21+
LL | let _once = ONCE_INIT;
22+
| ^^^^^^^^^^^^^^^^^^^^^^
23+
|
24+
= note: `-D clippy::no-effect` implied by `-D warnings`
25+
26+
error: statement with no effect
27+
--> $DIR/others.rs:62:5
28+
|
29+
LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
1832
error: a `const` item with interior mutability should not be borrowed
1933
--> $DIR/others.rs:62:22
2034
|
@@ -23,6 +37,12 @@ LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
2337
|
2438
= help: assign this const to a local or static variable, and use the variable here
2539

40+
error: statement with no effect
41+
--> $DIR/others.rs:63:5
42+
|
43+
LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
44+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45+
2646
error: a `const` item with interior mutability should not be borrowed
2747
--> $DIR/others.rs:63:25
2848
|
@@ -31,6 +51,12 @@ LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
3151
|
3252
= help: assign this const to a local or static variable, and use the variable here
3353

54+
error: statement with no effect
55+
--> $DIR/others.rs:64:5
56+
|
57+
LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
58+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59+
3460
error: a `const` item with interior mutability should not be borrowed
3561
--> $DIR/others.rs:64:27
3662
|
@@ -39,6 +65,12 @@ LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
3965
|
4066
= help: assign this const to a local or static variable, and use the variable here
4167

68+
error: statement with no effect
69+
--> $DIR/others.rs:65:5
70+
|
71+
LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
72+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73+
4274
error: a `const` item with interior mutability should not be borrowed
4375
--> $DIR/others.rs:65:26
4476
|
@@ -47,6 +79,42 @@ LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
4779
|
4880
= help: assign this const to a local or static variable, and use the variable here
4981

82+
error: statement with no effect
83+
--> $DIR/others.rs:68:5
84+
|
85+
LL | let _twice = (ONCE_INIT, ONCE_INIT);
86+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87+
88+
error: statement with no effect
89+
--> $DIR/others.rs:69:5
90+
|
91+
LL | let _ref_twice = &(ONCE_INIT, ONCE_INIT);
92+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93+
94+
error: statement with no effect
95+
--> $DIR/others.rs:70:5
96+
|
97+
LL | let _ref_once = &(ONCE_INIT, ONCE_INIT).0;
98+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99+
100+
error: statement with no effect
101+
--> $DIR/others.rs:71:5
102+
|
103+
LL | let _array_twice = [ONCE_INIT, ONCE_INIT];
104+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105+
106+
error: statement with no effect
107+
--> $DIR/others.rs:72:5
108+
|
109+
LL | let _ref_array_twice = &[ONCE_INIT, ONCE_INIT];
110+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
111+
112+
error: statement with no effect
113+
--> $DIR/others.rs:73:5
114+
|
115+
LL | let _ref_array_once = &[ONCE_INIT, ONCE_INIT][0];
116+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117+
50118
error: a `const` item with interior mutability should not be borrowed
51119
--> $DIR/others.rs:76:14
52120
|
@@ -111,5 +179,5 @@ LL | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability
111179
|
112180
= help: assign this const to a local or static variable, and use the variable here
113181

114-
error: aborting due to 14 previous errors
182+
error: aborting due to 25 previous errors
115183

tests/ui/branches_sharing_code/shared_at_top.stderr

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ LL + let _z = y;
3434
LL + if x == 0 {
3535
|
3636

37+
error: statement with no effect
38+
--> $DIR/shared_at_top.rs:22:9
39+
|
40+
LL | let _z = y;
41+
| ^^^^^^^^^^^
42+
|
43+
= note: `-D clippy::no-effect` implied by `-D warnings`
44+
45+
error: statement with no effect
46+
--> $DIR/shared_at_top.rs:28:9
47+
|
48+
LL | let _z = y;
49+
| ^^^^^^^^^^^
50+
51+
error: statement with no effect
52+
--> $DIR/shared_at_top.rs:34:9
53+
|
54+
LL | let _z = y;
55+
| ^^^^^^^^^^^
56+
3757
error: all if blocks contain the same code at the start
3858
--> $DIR/shared_at_top.rs:40:5
3959
|
@@ -117,5 +137,5 @@ LL | | println!("This should trigger `IS_SAME_THAN_ELSE` as usual");
117137
LL | | }
118138
| |_____^
119139

120-
error: aborting due to 7 previous errors
140+
error: aborting due to 10 previous errors
121141

tests/ui/branches_sharing_code/shared_at_top_and_bottom.stderr

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,56 @@ LL ~ }
3131
LL + let _u = 9;
3232
|
3333

34+
error: statement with no effect
35+
--> $DIR/shared_at_top_and_bottom.rs:18:9
36+
|
37+
LL | let _overlap_start = t * 2;
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
39+
|
40+
= note: `-D clippy::no-effect` implied by `-D warnings`
41+
42+
error: statement with no effect
43+
--> $DIR/shared_at_top_and_bottom.rs:19:9
44+
|
45+
LL | let _overlap_end = 2 * t;
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
47+
48+
error: statement with no effect
49+
--> $DIR/shared_at_top_and_bottom.rs:20:9
50+
|
51+
LL | let _u = 9;
52+
| ^^^^^^^^^^^
53+
54+
error: statement with no effect
55+
--> $DIR/shared_at_top_and_bottom.rs:23:9
56+
|
57+
LL | let _overlap_start = t * 2;
58+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
59+
60+
error: statement with no effect
61+
--> $DIR/shared_at_top_and_bottom.rs:24:9
62+
|
63+
LL | let _overlap_end = 2 * t;
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
65+
66+
error: statement with no effect
67+
--> $DIR/shared_at_top_and_bottom.rs:26:9
68+
|
69+
LL | let _overlap_start = t * 2;
70+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
71+
72+
error: statement with no effect
73+
--> $DIR/shared_at_top_and_bottom.rs:27:9
74+
|
75+
LL | let _overlap_end = 2 * t;
76+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
77+
78+
error: statement with no effect
79+
--> $DIR/shared_at_top_and_bottom.rs:28:9
80+
|
81+
LL | let _u = 9;
82+
| ^^^^^^^^^^^
83+
3484
error: all if blocks contain the same code at the start and the end. Here at the start
3585
--> $DIR/shared_at_top_and_bottom.rs:32:5
3686
|
@@ -62,6 +112,48 @@ LL + let _overlap_end = r * r * r;
62112
LL + let z = "end";
63113
|
64114

115+
error: statement with no effect
116+
--> $DIR/shared_at_top_and_bottom.rs:34:9
117+
|
118+
LL | let _overlap_start = r;
119+
| ^^^^^^^^^^^^^^^^^^^^^^^
120+
121+
error: statement with no effect
122+
--> $DIR/shared_at_top_and_bottom.rs:35:9
123+
|
124+
LL | let _overlap_middle = r * r;
125+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126+
127+
error: statement with no effect
128+
--> $DIR/shared_at_top_and_bottom.rs:36:9
129+
|
130+
LL | let _overlap_end = r * r * r;
131+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
132+
133+
error: statement with no effect
134+
--> $DIR/shared_at_top_and_bottom.rs:40:9
135+
|
136+
LL | let _overlap_start = r;
137+
| ^^^^^^^^^^^^^^^^^^^^^^^
138+
139+
error: statement with no effect
140+
--> $DIR/shared_at_top_and_bottom.rs:41:9
141+
|
142+
LL | let _overlap_middle = r * r;
143+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144+
145+
error: statement with no effect
146+
--> $DIR/shared_at_top_and_bottom.rs:42:9
147+
|
148+
LL | let _overlap_middle = r * r;
149+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150+
151+
error: statement with no effect
152+
--> $DIR/shared_at_top_and_bottom.rs:43:9
153+
|
154+
LL | let _overlap_end = r * r * r;
155+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
156+
65157
error: all if blocks contain the same code at the start and the end. Here at the start
66158
--> $DIR/shared_at_top_and_bottom.rs:61:5
67159
|
@@ -125,6 +217,12 @@ LL ~ }
125217
LL ~ x << 2;
126218
|
127219

220+
error: statement with no effect
221+
--> $DIR/shared_at_top_and_bottom.rs:97:9
222+
|
223+
LL | let _splitter = 6;
224+
| ^^^^^^^^^^^^^^^^^^
225+
128226
error: all if blocks contain the same code at the start and the end. Here at the start
129227
--> $DIR/shared_at_top_and_bottom.rs:106:5
130228
|
@@ -150,5 +248,11 @@ LL ~ }
150248
LL + x * 4
151249
|
152250

153-
error: aborting due to 5 previous errors
251+
error: statement with no effect
252+
--> $DIR/shared_at_top_and_bottom.rs:109:9
253+
|
254+
LL | let _splitter = 6;
255+
| ^^^^^^^^^^^^^^^^^^
256+
257+
error: aborting due to 22 previous errors
154258

0 commit comments

Comments
 (0)