@@ -45,10 +45,10 @@ impl ArithmeticSideEffects {
4545 let ast:: LitKind :: Int ( value, _) = lit. node
4646 {
4747 match ( & op. node , value) {
48- ( hir:: BinOpKind :: Add | hir:: BinOpKind :: Sub , 0 ) |
49- ( hir:: BinOpKind :: Mul , 0 | 1 ) => true ,
5048 ( 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 ,
5252 _ => false ,
5353 }
5454 } else {
@@ -74,7 +74,7 @@ impl ArithmeticSideEffects {
7474 self . expr_span = Some ( expr. span ) ;
7575 }
7676
77- /// If `expr` does not match any variant of [ LiteralIntegerTy] , returns `None`.
77+ /// If `expr` does not match any variant of ` LiteralIntegerTy` , returns `None`.
7878 fn literal_integer < ' expr , ' tcx > ( expr : & ' expr hir:: Expr < ' tcx > ) -> Option < LiteralIntegerTy < ' expr , ' tcx > > {
7979 if matches ! ( expr. kind, hir:: ExprKind :: Lit ( _) ) {
8080 return Some ( LiteralIntegerTy :: Value ( expr) ) ;
@@ -118,11 +118,9 @@ impl ArithmeticSideEffects {
118118 }
119119 let has_valid_op = if Self :: is_integral ( lhs_ty) && Self :: is_integral ( rhs_ty) {
120120 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 ( ) ) ,
124122 ( Some ( LiteralIntegerTy :: Value ( _) ) , Some ( LiteralIntegerTy :: Value ( _) ) ) => true ,
125- ( Some ( _) , Some ( _) ) => false ,
123+ ( None , None ) | ( Some ( _) , Some ( _) ) => false ,
126124 }
127125 } else {
128126 false
@@ -180,9 +178,9 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
180178 }
181179}
182180
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.
184182///
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
186184/// than `hirExprKind::Addr`.
187185enum LiteralIntegerTy < ' expr , ' tcx > {
188186 /// For example, `&199`
@@ -194,8 +192,7 @@ enum LiteralIntegerTy<'expr, 'tcx> {
194192impl < ' expr , ' tcx > From < LiteralIntegerTy < ' expr , ' tcx > > for & ' expr hir:: Expr < ' tcx > {
195193 fn from ( from : LiteralIntegerTy < ' expr , ' tcx > ) -> Self {
196194 match from {
197- LiteralIntegerTy :: Ref ( elem) => elem,
198- LiteralIntegerTy :: Value ( elem) => elem,
195+ LiteralIntegerTy :: Ref ( elem) | LiteralIntegerTy :: Value ( elem) => elem,
199196 }
200197 }
201198}
0 commit comments