@@ -15,7 +15,7 @@ use rustc_apfloat::ieee::{Half, Quad};
1515use rustc_ast:: ast:: { self , LitFloatType , LitKind } ;
1616use rustc_hir:: def:: { DefKind , Res } ;
1717use rustc_hir:: {
18- BinOp , BinOpKind , Block , ConstBlock , Expr , ExprKind , HirId , Item , ItemKind , Node , PatExpr , PatExprKind , QPath , UnOp ,
18+ BinOpKind , Block , ConstBlock , Expr , ExprKind , HirId , Item , ItemKind , Node , PatExpr , PatExprKind , QPath , UnOp ,
1919} ;
2020use rustc_lexer:: tokenize;
2121use rustc_lint:: LateContext ;
@@ -506,7 +506,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
506506 UnOp :: Deref => Some ( if let Constant :: Ref ( r) = o { * r } else { o } ) ,
507507 } ) ,
508508 ExprKind :: If ( cond, then, ref otherwise) => self . ifthenelse ( cond, then, * otherwise) ,
509- ExprKind :: Binary ( op, left, right) => self . binop ( op, left, right) ,
509+ ExprKind :: Binary ( op, left, right) => self . binop ( op. node , left, right) ,
510510 ExprKind :: Call ( callee, [ ] ) => {
511511 // We only handle a few const functions for now.
512512 if let ExprKind :: Path ( qpath) = & callee. kind
@@ -744,7 +744,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
744744 }
745745 }
746746
747- fn binop ( & self , op : BinOp , left : & Expr < ' _ > , right : & Expr < ' _ > ) -> Option < Constant < ' tcx > > {
747+ fn binop ( & self , op : BinOpKind , left : & Expr < ' _ > , right : & Expr < ' _ > ) -> Option < Constant < ' tcx > > {
748748 let l = self . expr ( left) ?;
749749 let r = self . expr ( right) ;
750750 match ( l, r) {
@@ -757,15 +757,15 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
757757
758758 // Using / or %, where the left-hand argument is the smallest integer of a signed integer type and
759759 // the right-hand argument is -1 always panics, even with overflow-checks disabled
760- if let BinOpKind :: Div | BinOpKind :: Rem = op. node
760+ if let BinOpKind :: Div | BinOpKind :: Rem = op
761761 && l == ty_min_value
762762 && r == -1
763763 {
764764 return None ;
765765 }
766766
767767 let zext = |n : i128 | Constant :: Int ( unsext ( self . tcx , n, ity) ) ;
768- match op. node {
768+ match op {
769769 // When +, * or binary - create a value greater than the maximum value, or less than
770770 // the minimum value that can be stored, it panics.
771771 BinOpKind :: Add => l. checked_add ( r) . and_then ( |n| ity. ensure_fits ( n) ) . map ( zext) ,
@@ -792,7 +792,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
792792 ty:: Uint ( ity) => {
793793 let bits = ity. bits ( ) ;
794794
795- match op. node {
795+ match op {
796796 BinOpKind :: Add => l. checked_add ( r) . and_then ( |n| ity. ensure_fits ( n) ) . map ( Constant :: Int ) ,
797797 BinOpKind :: Sub => l. checked_sub ( r) . and_then ( |n| ity. ensure_fits ( n) ) . map ( Constant :: Int ) ,
798798 BinOpKind :: Mul => l. checked_mul ( r) . and_then ( |n| ity. ensure_fits ( n) ) . map ( Constant :: Int ) ,
@@ -815,7 +815,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
815815 _ => None ,
816816 } ,
817817 // FIXME(f16_f128): add these types when binary operations are available on all platforms
818- ( Constant :: F32 ( l) , Some ( Constant :: F32 ( r) ) ) => match op. node {
818+ ( Constant :: F32 ( l) , Some ( Constant :: F32 ( r) ) ) => match op {
819819 BinOpKind :: Add => Some ( Constant :: F32 ( l + r) ) ,
820820 BinOpKind :: Sub => Some ( Constant :: F32 ( l - r) ) ,
821821 BinOpKind :: Mul => Some ( Constant :: F32 ( l * r) ) ,
@@ -829,7 +829,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
829829 BinOpKind :: Gt => Some ( Constant :: Bool ( l > r) ) ,
830830 _ => None ,
831831 } ,
832- ( Constant :: F64 ( l) , Some ( Constant :: F64 ( r) ) ) => match op. node {
832+ ( Constant :: F64 ( l) , Some ( Constant :: F64 ( r) ) ) => match op {
833833 BinOpKind :: Add => Some ( Constant :: F64 ( l + r) ) ,
834834 BinOpKind :: Sub => Some ( Constant :: F64 ( l - r) ) ,
835835 BinOpKind :: Mul => Some ( Constant :: F64 ( l * r) ) ,
@@ -843,7 +843,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
843843 BinOpKind :: Gt => Some ( Constant :: Bool ( l > r) ) ,
844844 _ => None ,
845845 } ,
846- ( l, r) => match ( op. node , l, r) {
846+ ( l, r) => match ( op, l, r) {
847847 ( BinOpKind :: And , Constant :: Bool ( false ) , _) => Some ( Constant :: Bool ( false ) ) ,
848848 ( BinOpKind :: Or , Constant :: Bool ( true ) , _) => Some ( Constant :: Bool ( true ) ) ,
849849 ( BinOpKind :: And , Constant :: Bool ( true ) , Some ( r) ) | ( BinOpKind :: Or , Constant :: Bool ( false ) , Some ( r) ) => {
0 commit comments