@@ -96,7 +96,7 @@ struct Hir2Qmm<'a, 'tcx: 'a, 'v> {
96
96
impl < ' a , ' tcx , ' v > Hir2Qmm < ' a , ' tcx , ' v > {
97
97
fn extract ( & mut self , op : BinOpKind , a : & [ & ' v Expr ] , mut v : Vec < Bool > ) -> Result < Vec < Bool > , String > {
98
98
for a in a {
99
- if let ExprKind :: Binary ( binop, ref lhs, ref rhs) = a. node {
99
+ if let ExprKind :: Binary ( binop, lhs, rhs) = & a. node {
100
100
if binop. node == op {
101
101
v = self . extract ( op, & [ lhs, rhs] , v) ?;
102
102
continue ;
@@ -110,14 +110,14 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
110
110
fn run ( & mut self , e : & ' v Expr ) -> Result < Bool , String > {
111
111
// prevent folding of `cfg!` macros and the like
112
112
if !in_macro ( e. span ) {
113
- match e. node {
114
- ExprKind :: Unary ( UnNot , ref inner) => return Ok ( Bool :: Not ( box self . run ( inner) ?) ) ,
115
- ExprKind :: Binary ( binop, ref lhs, ref rhs) => match binop. node {
113
+ match & e. node {
114
+ ExprKind :: Unary ( UnNot , inner) => return Ok ( Bool :: Not ( box self . run ( inner) ?) ) ,
115
+ ExprKind :: Binary ( binop, lhs, rhs) => match & binop. node {
116
116
BinOpKind :: Or => return Ok ( Bool :: Or ( self . extract ( BinOpKind :: Or , & [ lhs, rhs] , Vec :: new ( ) ) ?) ) ,
117
117
BinOpKind :: And => return Ok ( Bool :: And ( self . extract ( BinOpKind :: And , & [ lhs, rhs] , Vec :: new ( ) ) ?) ) ,
118
118
_ => ( ) ,
119
119
} ,
120
- ExprKind :: Lit ( ref lit) => match lit. node {
120
+ ExprKind :: Lit ( lit) => match lit. node {
121
121
LitKind :: Bool ( true ) => return Ok ( Bool :: True ) ,
122
122
LitKind :: Bool ( false ) => return Ok ( Bool :: False ) ,
123
123
_ => ( ) ,
@@ -130,8 +130,8 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
130
130
#[ allow( clippy:: cast_possible_truncation) ]
131
131
return Ok ( Bool :: Term ( n as u8 ) ) ;
132
132
}
133
- let negated = match e. node {
134
- ExprKind :: Binary ( binop, ref lhs, ref rhs) => {
133
+ let negated = match & e. node {
134
+ ExprKind :: Binary ( binop, lhs, rhs) => {
135
135
if !implements_ord ( self . cx , lhs) {
136
136
continue ;
137
137
}
@@ -184,8 +184,8 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
184
184
}
185
185
186
186
fn simplify_not ( & self , expr : & Expr ) -> Option < String > {
187
- match expr. node {
188
- ExprKind :: Binary ( binop, ref lhs, ref rhs) => {
187
+ match & expr. node {
188
+ ExprKind :: Binary ( binop, lhs, rhs) => {
189
189
if !implements_ord ( self . cx , lhs) {
190
190
return None ;
191
191
}
@@ -201,7 +201,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
201
201
}
202
202
. and_then ( |op| Some ( format ! ( "{}{}{}" , self . snip( lhs) ?, op, self . snip( rhs) ?) ) )
203
203
} ,
204
- ExprKind :: MethodCall ( ref path, _, ref args) if args. len ( ) == 1 => {
204
+ ExprKind :: MethodCall ( path, _, args) if args. len ( ) == 1 => {
205
205
let type_of_receiver = self . cx . tables . expr_ty ( & args[ 0 ] ) ;
206
206
if !match_type ( self . cx , type_of_receiver, & paths:: OPTION )
207
207
&& !match_type ( self . cx , type_of_receiver, & paths:: RESULT )
@@ -221,14 +221,14 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
221
221
222
222
fn recurse ( & mut self , suggestion : & Bool ) -> Option < ( ) > {
223
223
use quine_mc_cluskey:: Bool :: * ;
224
- match * suggestion {
224
+ match suggestion {
225
225
True => {
226
226
self . output . push_str ( "true" ) ;
227
227
} ,
228
228
False => {
229
229
self . output . push_str ( "false" ) ;
230
230
} ,
231
- Not ( ref inner) => match * * inner {
231
+ Not ( inner) => match * * inner {
232
232
And ( _) | Or ( _) => {
233
233
self . output . push ( '!' ) ;
234
234
self . output . push ( '(' ) ;
@@ -251,7 +251,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
251
251
self . recurse ( inner) ?;
252
252
} ,
253
253
} ,
254
- And ( ref v) => {
254
+ And ( v) => {
255
255
for ( index, inner) in v. iter ( ) . enumerate ( ) {
256
256
if index > 0 {
257
257
self . output . push_str ( " && " ) ;
@@ -265,15 +265,15 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
265
265
}
266
266
}
267
267
} ,
268
- Or ( ref v) => {
268
+ Or ( v) => {
269
269
for ( index, inner) in v. iter ( ) . enumerate ( ) {
270
270
if index > 0 {
271
271
self . output . push_str ( " || " ) ;
272
272
}
273
273
self . recurse ( inner) ;
274
274
}
275
275
} ,
276
- Term ( n) => {
276
+ & Term ( n) => {
277
277
let snip = self . snip ( self . terminals [ n as usize ] ) ?;
278
278
self . output . push_str ( & snip) ;
279
279
} ,
@@ -325,22 +325,22 @@ struct Stats {
325
325
326
326
fn terminal_stats ( b : & Bool ) -> Stats {
327
327
fn recurse ( b : & Bool , stats : & mut Stats ) {
328
- match * b {
328
+ match b {
329
329
True | False => stats. ops += 1 ,
330
- Not ( ref inner) => {
330
+ Not ( inner) => {
331
331
match * * inner {
332
332
And ( _) | Or ( _) => stats. ops += 1 , // brackets are also operations
333
333
_ => stats. negations += 1 ,
334
334
}
335
335
recurse ( inner, stats) ;
336
336
} ,
337
- And ( ref v) | Or ( ref v) => {
337
+ And ( v) | Or ( v) => {
338
338
stats. ops += v. len ( ) - 1 ;
339
339
for inner in v {
340
340
recurse ( inner, stats) ;
341
341
}
342
342
} ,
343
- Term ( n) => stats. terminals [ n as usize ] += 1 ,
343
+ & Term ( n) => stats. terminals [ n as usize ] += 1 ,
344
344
}
345
345
}
346
346
use quine_mc_cluskey:: Bool :: * ;
@@ -461,11 +461,11 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
461
461
if in_macro ( e. span ) {
462
462
return ;
463
463
}
464
- match e. node {
464
+ match & e. node {
465
465
ExprKind :: Binary ( binop, _, _) if binop. node == BinOpKind :: Or || binop. node == BinOpKind :: And => {
466
466
self . bool_expr ( e)
467
467
} ,
468
- ExprKind :: Unary ( UnNot , ref inner) => {
468
+ ExprKind :: Unary ( UnNot , inner) => {
469
469
if self . cx . tables . node_types ( ) [ inner. hir_id ] . is_bool ( ) {
470
470
self . bool_expr ( e) ;
471
471
} else {
0 commit comments