File tree Expand file tree Collapse file tree 4 files changed +148
-117
lines changed Expand file tree Collapse file tree 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>(
194194 } ) )
195195 . collect :: < Option < Vec < ( Span , String ) > > > ( ) ?;
196196
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) ) ,
198202 // multiple suggestions don't work with rustfix in multipart_suggest
199203 // 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+ }
205206}
206207
207208struct Usage < ' tcx > {
Original file line number Diff line number Diff line change 33#![allow(
44 unused,
55 clippy::assign_op_pattern,
6+ clippy::blocks_in_if_conditions,
67 clippy::let_and_return,
78 clippy::let_unit_value,
89 clippy::nonminimal_bool
@@ -18,6 +19,22 @@ impl std::ops::Drop for SignificantDrop {
1819 }
1920}
2021
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+
2138fn main() {
2239
2340 let n = 1;
@@ -237,22 +254,20 @@ fn does_not_lint() {
237254 x = SignificantDrop;
238255}
239256
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+ }
254264
255-
256- let e = format!("{}", d);
265+ let x;
266+ if { x = 1; true } {
267+ return 1;
268+ } else {
269+ return 2;
257270 }
271+
272+ 3
258273}
Original file line number Diff line number Diff line change 33#![ allow(
44 unused,
55 clippy:: assign_op_pattern,
6+ clippy:: blocks_in_if_conditions,
67 clippy:: let_and_return,
78 clippy:: let_unit_value,
89 clippy:: nonminimal_bool
@@ -18,6 +19,22 @@ impl std::ops::Drop for SignificantDrop {
1819 }
1920}
2021
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+
2138fn main ( ) {
2239 let a;
2340 let n = 1 ;
@@ -237,22 +254,20 @@ fn does_not_lint() {
237254 x = SignificantDrop ;
238255}
239256
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+ }
254264
255- let e;
256- e = format ! ( "{}" , d) ;
265+ let x;
266+ if { x = 1 ; true } {
267+ return 1 ;
268+ } else {
269+ return 2 ;
257270 }
271+
272+ 3
258273}
You can’t perform that action at this time.
0 commit comments