@@ -81,7 +81,7 @@ struct Hir2Qmm<'a, 'tcx, 'v> {
81
81
impl < ' a , ' tcx , ' v > Hir2Qmm < ' a , ' tcx , ' v > {
82
82
fn extract ( & mut self , op : BinOpKind , a : & [ & ' v Expr ] , mut v : Vec < Bool > ) -> Result < Vec < Bool > , String > {
83
83
for a in a {
84
- if let ExprKind :: Binary ( binop, lhs, rhs) = & a. node {
84
+ if let ExprKind :: Binary ( binop, lhs, rhs) = & a. kind {
85
85
if binop. node == op {
86
86
v = self . extract ( op, & [ lhs, rhs] , v) ?;
87
87
continue ;
@@ -107,7 +107,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
107
107
108
108
// prevent folding of `cfg!` macros and the like
109
109
if !e. span . from_expansion ( ) {
110
- match & e. node {
110
+ match & e. kind {
111
111
ExprKind :: Unary ( UnNot , inner) => return Ok ( Bool :: Not ( box self . run ( inner) ?) ) ,
112
112
ExprKind :: Binary ( binop, lhs, rhs) => match & binop. node {
113
113
BinOpKind :: Or => return Ok ( Bool :: Or ( self . extract ( BinOpKind :: Or , & [ lhs, rhs] , Vec :: new ( ) ) ?) ) ,
@@ -129,9 +129,9 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
129
129
}
130
130
131
131
if_chain ! {
132
- if let ExprKind :: Binary ( e_binop, e_lhs, e_rhs) = & e. node ;
132
+ if let ExprKind :: Binary ( e_binop, e_lhs, e_rhs) = & e. kind ;
133
133
if implements_ord( self . cx, e_lhs) ;
134
- if let ExprKind :: Binary ( expr_binop, expr_lhs, expr_rhs) = & expr. node ;
134
+ if let ExprKind :: Binary ( expr_binop, expr_lhs, expr_rhs) = & expr. kind ;
135
135
if negate( e_binop. node) == Some ( expr_binop. node) ;
136
136
if SpanlessEq :: new( self . cx) . ignore_fn( ) . eq_expr( e_lhs, expr_lhs) ;
137
137
if SpanlessEq :: new( self . cx) . ignore_fn( ) . eq_expr( e_rhs, expr_rhs) ;
@@ -156,7 +156,6 @@ struct SuggestContext<'a, 'tcx, 'v> {
156
156
terminals : & ' v [ & ' v Expr ] ,
157
157
cx : & ' a LateContext < ' a , ' tcx > ,
158
158
output : String ,
159
- simplified : bool ,
160
159
}
161
160
162
161
impl < ' a , ' tcx , ' v > SuggestContext < ' a , ' tcx , ' v > {
@@ -179,7 +178,6 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
179
178
Term ( n) => {
180
179
let terminal = self . terminals [ n as usize ] ;
181
180
if let Some ( str) = simplify_not ( self . cx , terminal) {
182
- self . simplified = true ;
183
181
self . output . push_str ( & str)
184
182
} else {
185
183
self . output . push ( '!' ) ;
@@ -224,7 +222,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
224
222
}
225
223
226
224
fn simplify_not ( cx : & LateContext < ' _ , ' _ > , expr : & Expr ) -> Option < String > {
227
- match & expr. node {
225
+ match & expr. kind {
228
226
ExprKind :: Binary ( binop, lhs, rhs) => {
229
227
if !implements_ord ( cx, lhs) {
230
228
return None ;
@@ -264,16 +262,14 @@ fn simplify_not(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<String> {
264
262
}
265
263
}
266
264
267
- // The boolean part of the return indicates whether some simplifications have been applied.
268
- fn suggest ( cx : & LateContext < ' _ , ' _ > , suggestion : & Bool , terminals : & [ & Expr ] ) -> ( String , bool ) {
265
+ fn suggest ( cx : & LateContext < ' _ , ' _ > , suggestion : & Bool , terminals : & [ & Expr ] ) -> String {
269
266
let mut suggest_context = SuggestContext {
270
267
terminals,
271
268
cx,
272
269
output : String :: new ( ) ,
273
- simplified : false ,
274
270
} ;
275
271
suggest_context. recurse ( suggestion) ;
276
- ( suggest_context. output , suggest_context . simplified )
272
+ suggest_context. output
277
273
}
278
274
279
275
fn simple_negate ( b : Bool ) -> Bool {
@@ -383,7 +379,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
383
379
db. span_suggestion (
384
380
e. span ,
385
381
"it would look like the following" ,
386
- suggest ( self . cx , suggestion, & h2q. terminals ) . 0 ,
382
+ suggest ( self . cx , suggestion, & h2q. terminals ) ,
387
383
// nonminimal_bool can produce minimal but
388
384
// not human readable expressions (#3141)
389
385
Applicability :: Unspecified ,
@@ -428,7 +424,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
428
424
nonminimal_bool_lint (
429
425
improvements
430
426
. into_iter ( )
431
- . map ( |suggestion| suggest ( self . cx , suggestion, & h2q. terminals ) . 0 )
427
+ . map ( |suggestion| suggest ( self . cx , suggestion, & h2q. terminals ) )
432
428
. collect ( ) ,
433
429
) ;
434
430
}
@@ -441,7 +437,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
441
437
if in_macro ( e. span ) {
442
438
return ;
443
439
}
444
- match & e. node {
440
+ match & e. kind {
445
441
ExprKind :: Binary ( binop, _, _) if binop. node == BinOpKind :: Or || binop. node == BinOpKind :: And => {
446
442
self . bool_expr ( e)
447
443
} ,
@@ -471,7 +467,7 @@ struct NotSimplificationVisitor<'a, 'tcx> {
471
467
472
468
impl < ' a , ' tcx > Visitor < ' tcx > for NotSimplificationVisitor < ' a , ' tcx > {
473
469
fn visit_expr ( & mut self , expr : & ' tcx Expr ) {
474
- if let ExprKind :: Unary ( UnNot , inner) = & expr. node {
470
+ if let ExprKind :: Unary ( UnNot , inner) = & expr. kind {
475
471
if let Some ( suggestion) = simplify_not ( self . cx , inner) {
476
472
span_lint_and_sugg (
477
473
self . cx ,
0 commit comments