File tree 4 files changed +148
-117
lines changed
4 files changed +148
-117
lines changed Original file line number Diff line number Diff line change @@ -194,14 +194,15 @@ fn assignment_suggestions<'tcx>(
194
194
} ) )
195
195
. collect :: < Option < Vec < ( Span , String ) > > > ( ) ?;
196
196
197
- let applicability = if suggestions. len ( ) > 1 {
197
+ match suggestions. len ( ) {
198
+ // All of `exprs` are never types
199
+ // https://github.com/rust-lang/rust-clippy/issues/8911
200
+ 0 => None ,
201
+ 1 => Some ( ( Applicability :: MachineApplicable , suggestions) ) ,
198
202
// multiple suggestions don't work with rustfix in multipart_suggest
199
203
// https://github.com/rust-lang/rustfix/issues/141
200
- Applicability :: Unspecified
201
- } else {
202
- Applicability :: MachineApplicable
203
- } ;
204
- Some ( ( applicability, suggestions) )
204
+ _ => Some ( ( Applicability :: Unspecified , suggestions) ) ,
205
+ }
205
206
}
206
207
207
208
struct Usage < ' tcx > {
Original file line number Diff line number Diff line change 3
3
#![allow(
4
4
unused,
5
5
clippy::assign_op_pattern,
6
+ clippy::blocks_in_if_conditions,
6
7
clippy::let_and_return,
7
8
clippy::let_unit_value,
8
9
clippy::nonminimal_bool
@@ -18,6 +19,22 @@ impl std::ops::Drop for SignificantDrop {
18
19
}
19
20
}
20
21
22
+ fn simple() {
23
+
24
+ let a = "zero";
25
+
26
+
27
+
28
+ let b = 1;
29
+ let c = 2;
30
+
31
+
32
+ let d: usize = 1;
33
+
34
+
35
+ let e = format!("{}", d);
36
+ }
37
+
21
38
fn main() {
22
39
23
40
let n = 1;
@@ -237,22 +254,20 @@ fn does_not_lint() {
237
254
x = SignificantDrop;
238
255
}
239
256
240
- mod fixable {
241
- #![allow(dead_code)]
242
-
243
- fn main() {
244
-
245
- let a = "zero";
246
-
247
-
248
-
249
- let b = 1;
250
- let c = 2;
251
-
252
-
253
- let d: usize = 1;
257
+ #[rustfmt::skip]
258
+ fn issue8911() -> u32 {
259
+ let x;
260
+ match 1 {
261
+ _ if { x = 1; false } => return 1,
262
+ _ => return 2,
263
+ }
254
264
255
-
256
- let e = format!("{}", d);
265
+ let x;
266
+ if { x = 1; true } {
267
+ return 1;
268
+ } else {
269
+ return 2;
257
270
}
271
+
272
+ 3
258
273
}
Original file line number Diff line number Diff line change 3
3
#![ allow(
4
4
unused,
5
5
clippy:: assign_op_pattern,
6
+ clippy:: blocks_in_if_conditions,
6
7
clippy:: let_and_return,
7
8
clippy:: let_unit_value,
8
9
clippy:: nonminimal_bool
@@ -18,6 +19,22 @@ impl std::ops::Drop for SignificantDrop {
18
19
}
19
20
}
20
21
22
+ fn simple ( ) {
23
+ let a;
24
+ a = "zero" ;
25
+
26
+ let b;
27
+ let c;
28
+ b = 1 ;
29
+ c = 2 ;
30
+
31
+ let d: usize ;
32
+ d = 1 ;
33
+
34
+ let e;
35
+ e = format ! ( "{}" , d) ;
36
+ }
37
+
21
38
fn main ( ) {
22
39
let a;
23
40
let n = 1 ;
@@ -237,22 +254,20 @@ fn does_not_lint() {
237
254
x = SignificantDrop ;
238
255
}
239
256
240
- mod fixable {
241
- #![ allow( dead_code) ]
242
-
243
- fn main ( ) {
244
- let a;
245
- a = "zero" ;
246
-
247
- let b;
248
- let c;
249
- b = 1 ;
250
- c = 2 ;
251
-
252
- let d: usize ;
253
- d = 1 ;
257
+ #[ rustfmt:: skip]
258
+ fn issue8911 ( ) -> u32 {
259
+ let x;
260
+ match 1 {
261
+ _ if { x = 1 ; false } => return 1 ,
262
+ _ => return 2 ,
263
+ }
254
264
255
- let e;
256
- e = format ! ( "{}" , d) ;
265
+ let x;
266
+ if { x = 1 ; true } {
267
+ return 1 ;
268
+ } else {
269
+ return 2 ;
257
270
}
271
+
272
+ 3
258
273
}
You can’t perform that action at this time.
0 commit comments