@@ -45,10 +45,10 @@ impl ArithmeticSideEffects {
45
45
let ast:: LitKind :: Int ( value, _) = lit. node
46
46
{
47
47
match ( & op. node , value) {
48
- ( hir:: BinOpKind :: Add | hir:: BinOpKind :: Sub , 0 ) |
49
- ( hir:: BinOpKind :: Mul , 0 | 1 ) => true ,
50
48
( hir:: BinOpKind :: Div | hir:: BinOpKind :: Rem , 0 ) => false ,
51
- ( hir:: BinOpKind :: Div | hir:: BinOpKind :: Rem , _) => true ,
49
+ ( hir:: BinOpKind :: Add | hir:: BinOpKind :: Sub , 0 )
50
+ | ( hir:: BinOpKind :: Div | hir:: BinOpKind :: Rem , _)
51
+ | ( hir:: BinOpKind :: Mul , 0 | 1 ) => true ,
52
52
_ => false ,
53
53
}
54
54
} else {
@@ -74,7 +74,7 @@ impl ArithmeticSideEffects {
74
74
self . expr_span = Some ( expr. span ) ;
75
75
}
76
76
77
- /// If `expr` does not match any variant of [ LiteralIntegerTy] , returns `None`.
77
+ /// If `expr` does not match any variant of ` LiteralIntegerTy` , returns `None`.
78
78
fn literal_integer < ' expr , ' tcx > ( expr : & ' expr hir:: Expr < ' tcx > ) -> Option < LiteralIntegerTy < ' expr , ' tcx > > {
79
79
if matches ! ( expr. kind, hir:: ExprKind :: Lit ( _) ) {
80
80
return Some ( LiteralIntegerTy :: Value ( expr) ) ;
@@ -118,11 +118,9 @@ impl ArithmeticSideEffects {
118
118
}
119
119
let has_valid_op = if Self :: is_integral ( lhs_ty) && Self :: is_integral ( rhs_ty) {
120
120
match ( Self :: literal_integer ( lhs) , Self :: literal_integer ( rhs) ) {
121
- ( None , None ) => false ,
122
- ( None , Some ( lit_int_ty) ) => Self :: has_valid_op ( op, lit_int_ty. into ( ) ) ,
123
- ( Some ( lit_int_ty) , None ) => Self :: has_valid_op ( op, lit_int_ty. into ( ) ) ,
121
+ ( None , Some ( lit_int_ty) ) | ( Some ( lit_int_ty) , None ) => Self :: has_valid_op ( op, lit_int_ty. into ( ) ) ,
124
122
( Some ( LiteralIntegerTy :: Value ( _) ) , Some ( LiteralIntegerTy :: Value ( _) ) ) => true ,
125
- ( Some ( _) , Some ( _) ) => false ,
123
+ ( None , None ) | ( Some ( _) , Some ( _) ) => false ,
126
124
}
127
125
} else {
128
126
false
@@ -180,9 +178,9 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
180
178
}
181
179
}
182
180
183
- /// Tells if an expression is a integer passed by value or by reference.
181
+ /// Tells if an expression is a integer declared by value or by reference.
184
182
///
185
- /// If [ LiteralIntegerTy::Ref] , then the contained value will be `hir::ExprKind::Lit` rather
183
+ /// If ` LiteralIntegerTy::Ref` , then the contained value will be `hir::ExprKind::Lit` rather
186
184
/// than `hirExprKind::Addr`.
187
185
enum LiteralIntegerTy < ' expr , ' tcx > {
188
186
/// For example, `&199`
@@ -194,8 +192,7 @@ enum LiteralIntegerTy<'expr, 'tcx> {
194
192
impl < ' expr , ' tcx > From < LiteralIntegerTy < ' expr , ' tcx > > for & ' expr hir:: Expr < ' tcx > {
195
193
fn from ( from : LiteralIntegerTy < ' expr , ' tcx > ) -> Self {
196
194
match from {
197
- LiteralIntegerTy :: Ref ( elem) => elem,
198
- LiteralIntegerTy :: Value ( elem) => elem,
195
+ LiteralIntegerTy :: Ref ( elem) | LiteralIntegerTy :: Value ( elem) => elem,
199
196
}
200
197
}
201
198
}
0 commit comments