From 9a2362e5a96d2469d65a64d7b0b422b48fc2b4ee Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 5 Mar 2021 09:32:47 +0000 Subject: [PATCH] Shrink the size of Rvalue by 16 bytes --- compiler/rustc_codegen_cranelift/src/base.rs | 4 ++-- compiler/rustc_codegen_cranelift/src/lib.rs | 1 + compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 4 ++-- compiler/rustc_middle/src/mir/mod.rs | 10 +++++----- compiler/rustc_middle/src/mir/tcx.rs | 4 ++-- compiler/rustc_middle/src/mir/type_foldable.rs | 10 ++++++---- compiler/rustc_middle/src/mir/visit.rs | 4 ++-- .../rustc_mir/src/borrow_check/invalidation.rs | 4 ++-- compiler/rustc_mir/src/borrow_check/mod.rs | 4 ++-- .../rustc_mir/src/borrow_check/type_check/mod.rs | 3 +-- .../rustc_mir/src/dataflow/move_paths/builder.rs | 4 ++-- compiler/rustc_mir/src/interpret/step.rs | 4 ++-- compiler/rustc_mir/src/shim.rs | 8 +++----- .../src/transform/check_consts/qualifs.rs | 2 +- .../src/transform/check_consts/validation.rs | 4 ++-- compiler/rustc_mir/src/transform/const_prop.rs | 9 +++++---- .../src/transform/early_otherwise_branch.rs | 6 ++++-- compiler/rustc_mir/src/transform/instcombine.rs | 2 +- .../rustc_mir/src/transform/lower_intrinsics.rs | 2 +- compiler/rustc_mir/src/transform/match_branches.rs | 3 +-- compiler/rustc_mir/src/transform/promote_consts.rs | 2 +- .../src/transform/simplify_comparison_integral.rs | 9 ++++++--- compiler/rustc_mir/src/util/elaborate_drops.rs | 14 ++++++++++---- .../rustc_mir_build/src/build/expr/as_place.rs | 5 ++++- .../rustc_mir_build/src/build/expr/as_rvalue.rs | 14 +++++++------- compiler/rustc_mir_build/src/build/matches/test.rs | 2 +- .../src/traits/const_evaluatable.rs | 6 ++++-- .../clippy/clippy_lints/src/redundant_clone.rs | 4 ++-- .../clippy_utils/src/qualify_min_const_fn.rs | 2 +- 29 files changed, 83 insertions(+), 67 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 4842628a99d..db65c38ced1 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -494,14 +494,14 @@ fn codegen_stmt<'tcx>( let val = crate::constant::codegen_tls_ref(fx, def_id, lval.layout()); lval.write_cvalue(fx, val); } - Rvalue::BinaryOp(bin_op, ref lhs, ref rhs) => { + Rvalue::BinaryOp(bin_op, box (ref lhs, ref rhs)) => { let lhs = codegen_operand(fx, lhs); let rhs = codegen_operand(fx, rhs); let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs); lval.write_cvalue(fx, res); } - Rvalue::CheckedBinaryOp(bin_op, ref lhs, ref rhs) => { + Rvalue::CheckedBinaryOp(bin_op, box (ref lhs, ref rhs)) => { let lhs = codegen_operand(fx, lhs); let rhs = codegen_operand(fx, rhs); diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index 1480ab25133..33158d89d30 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -5,6 +5,7 @@ associated_type_bounds, never_type, try_blocks, + box_patterns, hash_drain_filter )] #![warn(rust_2018_idioms)] diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index e3a6cabd600..1795710ff53 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -424,7 +424,7 @@ pub fn codegen_rvalue_operand( (bx, operand) } - mir::Rvalue::BinaryOp(op, ref lhs, ref rhs) => { + mir::Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => { let lhs = self.codegen_operand(&mut bx, lhs); let rhs = self.codegen_operand(&mut bx, rhs); let llresult = match (lhs.val, rhs.val) { @@ -453,7 +453,7 @@ pub fn codegen_rvalue_operand( }; (bx, operand) } - mir::Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => { + mir::Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => { let lhs = self.codegen_operand(&mut bx, lhs); let rhs = self.codegen_operand(&mut bx, rhs); let result = self.codegen_scalar_checked_binop( diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 980f4d5f8ea..b42ebab3a65 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -2076,8 +2076,8 @@ pub enum Rvalue<'tcx> { Cast(CastKind, Operand<'tcx>, Ty<'tcx>), - BinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>), - CheckedBinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>), + BinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>), + CheckedBinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>), NullaryOp(NullOp, Ty<'tcx>), UnaryOp(UnOp, Operand<'tcx>), @@ -2097,7 +2097,7 @@ pub enum Rvalue<'tcx> { } #[cfg(target_arch = "x86_64")] -static_assert_size!(Rvalue<'_>, 56); +static_assert_size!(Rvalue<'_>, 40); #[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] pub enum CastKind { @@ -2201,8 +2201,8 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { Cast(ref kind, ref place, ref ty) => { write!(fmt, "{:?} as {:?} ({:?})", place, ty, kind) } - BinaryOp(ref op, ref a, ref b) => write!(fmt, "{:?}({:?}, {:?})", op, a, b), - CheckedBinaryOp(ref op, ref a, ref b) => { + BinaryOp(ref op, box (ref a, ref b)) => write!(fmt, "{:?}({:?}, {:?})", op, a, b), + CheckedBinaryOp(ref op, box (ref a, ref b)) => { write!(fmt, "Checked{:?}({:?}, {:?})", op, a, b) } UnaryOp(ref op, ref a) => write!(fmt, "{:?}({:?})", op, a), diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 92f46ef6a63..3c7a6aa00c3 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -182,12 +182,12 @@ pub fn ty(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx> } Rvalue::Len(..) => tcx.types.usize, Rvalue::Cast(.., ty) => ty, - Rvalue::BinaryOp(op, ref lhs, ref rhs) => { + Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => { let lhs_ty = lhs.ty(local_decls, tcx); let rhs_ty = rhs.ty(local_decls, tcx); op.ty(tcx, lhs_ty, rhs_ty) } - Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => { + Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => { let lhs_ty = lhs.ty(local_decls, tcx); let rhs_ty = rhs.ty(local_decls, tcx); let ty = op.ty(tcx, lhs_ty, rhs_ty); diff --git a/compiler/rustc_middle/src/mir/type_foldable.rs b/compiler/rustc_middle/src/mir/type_foldable.rs index da8e189ba9d..6fabddbd149 100644 --- a/compiler/rustc_middle/src/mir/type_foldable.rs +++ b/compiler/rustc_middle/src/mir/type_foldable.rs @@ -181,9 +181,11 @@ fn super_fold_with>(self, folder: &mut F) -> Self { AddressOf(mutability, place) => AddressOf(mutability, place.fold_with(folder)), Len(place) => Len(place.fold_with(folder)), Cast(kind, op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)), - BinaryOp(op, rhs, lhs) => BinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder)), - CheckedBinaryOp(op, rhs, lhs) => { - CheckedBinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder)) + BinaryOp(op, box (rhs, lhs)) => { + BinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder))) + } + CheckedBinaryOp(op, box (rhs, lhs)) => { + CheckedBinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder))) } UnaryOp(op, val) => UnaryOp(op, val.fold_with(folder)), Discriminant(place) => Discriminant(place.fold_with(folder)), @@ -227,7 +229,7 @@ fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow op.visit_with(visitor)?; ty.visit_with(visitor) } - BinaryOp(_, ref rhs, ref lhs) | CheckedBinaryOp(_, ref rhs, ref lhs) => { + BinaryOp(_, box (ref rhs, ref lhs)) | CheckedBinaryOp(_, box (ref rhs, ref lhs)) => { rhs.visit_with(visitor)?; lhs.visit_with(visitor) } diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index bb8c5f175b8..0fb1ea4c60d 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -685,8 +685,8 @@ fn super_rvalue(&mut self, self.visit_ty(ty, TyContext::Location(location)); } - Rvalue::BinaryOp(_bin_op, lhs, rhs) - | Rvalue::CheckedBinaryOp(_bin_op, lhs, rhs) => { + Rvalue::BinaryOp(_bin_op, box(lhs, rhs)) + | Rvalue::CheckedBinaryOp(_bin_op, box(lhs, rhs)) => { self.visit_operand(lhs, location); self.visit_operand(rhs, location); } diff --git a/compiler/rustc_mir/src/borrow_check/invalidation.rs b/compiler/rustc_mir/src/borrow_check/invalidation.rs index 8c05e6fd5d0..54ef78137a8 100644 --- a/compiler/rustc_mir/src/borrow_check/invalidation.rs +++ b/compiler/rustc_mir/src/borrow_check/invalidation.rs @@ -326,8 +326,8 @@ fn consume_rvalue(&mut self, location: Location, rvalue: &Rvalue<'tcx>) { ); } - Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2) - | Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => { + Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2)) + | Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => { self.consume_operand(location, operand1); self.consume_operand(location, operand2); } diff --git a/compiler/rustc_mir/src/borrow_check/mod.rs b/compiler/rustc_mir/src/borrow_check/mod.rs index 375d4649171..dcf3093baaf 100644 --- a/compiler/rustc_mir/src/borrow_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/mod.rs @@ -1316,8 +1316,8 @@ fn consume_rvalue( ); } - Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2) - | Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => { + Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2)) + | Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => { self.consume_operand(location, (operand1, span), flow_state); self.consume_operand(location, (operand2, span), flow_state); } diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs index aa946fdafa9..4819e12517d 100644 --- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs @@ -2299,8 +2299,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L Rvalue::BinaryOp( BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge, - left, - right, + box (left, right), ) => { let ty_left = left.ty(body, tcx); match ty_left.kind() { diff --git a/compiler/rustc_mir/src/dataflow/move_paths/builder.rs b/compiler/rustc_mir/src/dataflow/move_paths/builder.rs index ee78ff00c9b..67c3b043262 100644 --- a/compiler/rustc_mir/src/dataflow/move_paths/builder.rs +++ b/compiler/rustc_mir/src/dataflow/move_paths/builder.rs @@ -329,8 +329,8 @@ fn gather_rvalue(&mut self, rvalue: &Rvalue<'tcx>) { | Rvalue::Repeat(ref operand, _) | Rvalue::Cast(_, ref operand, _) | Rvalue::UnaryOp(_, ref operand) => self.gather_operand(operand), - Rvalue::BinaryOp(ref _binop, ref lhs, ref rhs) - | Rvalue::CheckedBinaryOp(ref _binop, ref lhs, ref rhs) => { + Rvalue::BinaryOp(ref _binop, box (ref lhs, ref rhs)) + | Rvalue::CheckedBinaryOp(ref _binop, box (ref lhs, ref rhs)) => { self.gather_operand(lhs); self.gather_operand(rhs); } diff --git a/compiler/rustc_mir/src/interpret/step.rs b/compiler/rustc_mir/src/interpret/step.rs index 64d7c8ef2c7..c22d91fd82a 100644 --- a/compiler/rustc_mir/src/interpret/step.rs +++ b/compiler/rustc_mir/src/interpret/step.rs @@ -165,7 +165,7 @@ pub fn eval_rvalue_into_place( self.copy_op(&op, &dest)?; } - BinaryOp(bin_op, ref left, ref right) => { + BinaryOp(bin_op, box (ref left, ref right)) => { let layout = binop_left_homogeneous(bin_op).then_some(dest.layout); let left = self.read_immediate(&self.eval_operand(left, layout)?)?; let layout = binop_right_homogeneous(bin_op).then_some(left.layout); @@ -173,7 +173,7 @@ pub fn eval_rvalue_into_place( self.binop_ignore_overflow(bin_op, &left, &right, &dest)?; } - CheckedBinaryOp(bin_op, ref left, ref right) => { + CheckedBinaryOp(bin_op, box (ref left, ref right)) => { // Due to the extra boolean in the result, we can never reuse the `dest.layout`. let left = self.read_immediate(&self.eval_operand(left, None)?)?; let layout = binop_right_homogeneous(bin_op).then_some(left.layout); diff --git a/compiler/rustc_mir/src/shim.rs b/compiler/rustc_mir/src/shim.rs index 6aaf27bdcb5..07857c0f59f 100644 --- a/compiler/rustc_mir/src/shim.rs +++ b/compiler/rustc_mir/src/shim.rs @@ -463,7 +463,7 @@ fn loop_header( let cond = self.make_place(Mutability::Mut, tcx.types.bool); let compute_cond = self.make_statement(StatementKind::Assign(box ( cond, - Rvalue::BinaryOp(BinOp::Ne, Operand::Copy(end), Operand::Copy(beg)), + Rvalue::BinaryOp(BinOp::Ne, box (Operand::Copy(end), Operand::Copy(beg))), ))); // `if end != beg { goto loop_body; } else { goto loop_end; }` @@ -536,8 +536,7 @@ fn array_shim( Place::from(beg), Rvalue::BinaryOp( BinOp::Add, - Operand::Copy(Place::from(beg)), - Operand::Constant(self.make_usize(1)), + box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))), ), )))]; self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false); @@ -590,8 +589,7 @@ fn array_shim( Place::from(beg), Rvalue::BinaryOp( BinOp::Add, - Operand::Copy(Place::from(beg)), - Operand::Constant(self.make_usize(1)), + box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))), ), ))); self.block(vec![statement], TerminatorKind::Goto { target: BasicBlock::new(6) }, true); diff --git a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs index 0ce1980f10a..13d7166b4b5 100644 --- a/compiler/rustc_mir/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_mir/src/transform/check_consts/qualifs.rs @@ -168,7 +168,7 @@ pub fn in_rvalue(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, rvalue: &Rvalue | Rvalue::UnaryOp(_, operand) | Rvalue::Cast(_, operand, _) => in_operand::(cx, in_local, operand), - Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => { + Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => { in_operand::(cx, in_local, lhs) || in_operand::(cx, in_local, rhs) } diff --git a/compiler/rustc_mir/src/transform/check_consts/validation.rs b/compiler/rustc_mir/src/transform/check_consts/validation.rs index 2845f27d22b..2922acf4268 100644 --- a/compiler/rustc_mir/src/transform/check_consts/validation.rs +++ b/compiler/rustc_mir/src/transform/check_consts/validation.rs @@ -684,8 +684,8 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { } } - Rvalue::BinaryOp(op, ref lhs, ref rhs) - | Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => { + Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) + | Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => { let lhs_ty = lhs.ty(self.body, self.tcx); let rhs_ty = rhs.ty(self.body, self.tcx); diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index 3b27b544310..8bbd4e170f2 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -676,11 +676,11 @@ fn const_prop( trace!("checking UnaryOp(op = {:?}, arg = {:?})", op, arg); self.check_unary_op(*op, arg, source_info)?; } - Rvalue::BinaryOp(op, left, right) => { + Rvalue::BinaryOp(op, box (left, right)) => { trace!("checking BinaryOp(op = {:?}, left = {:?}, right = {:?})", op, left, right); self.check_binary_op(*op, left, right, source_info)?; } - Rvalue::CheckedBinaryOp(op, left, right) => { + Rvalue::CheckedBinaryOp(op, box (left, right)) => { trace!( "checking CheckedBinaryOp(op = {:?}, left = {:?}, right = {:?})", op, @@ -740,7 +740,8 @@ fn eval_rvalue_with_identities( ) -> Option<()> { self.use_ecx(|this| { match rvalue { - Rvalue::BinaryOp(op, left, right) | Rvalue::CheckedBinaryOp(op, left, right) => { + Rvalue::BinaryOp(op, box (left, right)) + | Rvalue::CheckedBinaryOp(op, box (left, right)) => { let l = this.ecx.eval_operand(left, None); let r = this.ecx.eval_operand(right, None); @@ -772,7 +773,7 @@ fn eval_rvalue_with_identities( } BinOp::Mul => { if const_arg.layout.ty.is_integral() && arg_value == 0 { - if let Rvalue::CheckedBinaryOp(_, _, _) = rvalue { + if let Rvalue::CheckedBinaryOp(_, _) = rvalue { let val = Immediate::ScalarPair( const_arg.to_scalar()?.into(), Scalar::from_bool(false).into(), diff --git a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs index b16a99d7f0d..1128599876c 100644 --- a/compiler/rustc_mir/src/transform/early_otherwise_branch.rs +++ b/compiler/rustc_mir/src/transform/early_otherwise_branch.rs @@ -91,8 +91,10 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { opt_to_apply.infos[0].first_switch_info.discr_used_in_switch; let not_equal_rvalue = Rvalue::BinaryOp( not_equal, - Operand::Copy(Place::from(second_discriminant_temp)), - Operand::Copy(first_descriminant_place), + box ( + Operand::Copy(Place::from(second_discriminant_temp)), + Operand::Copy(first_descriminant_place), + ), ); patch.add_statement( end_of_block_location, diff --git a/compiler/rustc_mir/src/transform/instcombine.rs b/compiler/rustc_mir/src/transform/instcombine.rs index 74dadb25725..bad82fe893e 100644 --- a/compiler/rustc_mir/src/transform/instcombine.rs +++ b/compiler/rustc_mir/src/transform/instcombine.rs @@ -44,7 +44,7 @@ fn should_combine(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> boo /// Transform boolean comparisons into logical operations. fn combine_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) { match rvalue { - Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), a, b) => { + Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => { let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) { // Transform "Eq(a, true)" ==> "a" (BinOp::Eq, _, Some(true)) => Some(a.clone()), diff --git a/compiler/rustc_mir/src/transform/lower_intrinsics.rs b/compiler/rustc_mir/src/transform/lower_intrinsics.rs index f5968532eb3..177b00b00da 100644 --- a/compiler/rustc_mir/src/transform/lower_intrinsics.rs +++ b/compiler/rustc_mir/src/transform/lower_intrinsics.rs @@ -59,7 +59,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { source_info: terminator.source_info, kind: StatementKind::Assign(box ( destination, - Rvalue::BinaryOp(bin_op, lhs, rhs), + Rvalue::BinaryOp(bin_op, box (lhs, rhs)), )), }); terminator.kind = TerminatorKind::Goto { target }; diff --git a/compiler/rustc_mir/src/transform/match_branches.rs b/compiler/rustc_mir/src/transform/match_branches.rs index 92b4ae397ae..5f7df41802f 100644 --- a/compiler/rustc_mir/src/transform/match_branches.rs +++ b/compiler/rustc_mir/src/transform/match_branches.rs @@ -139,8 +139,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let op = if f_b { BinOp::Eq } else { BinOp::Ne }; let rhs = Rvalue::BinaryOp( op, - Operand::Copy(Place::from(discr_local)), - const_cmp, + box (Operand::Copy(Place::from(discr_local)), const_cmp), ); Statement { source_info: f.source_info, diff --git a/compiler/rustc_mir/src/transform/promote_consts.rs b/compiler/rustc_mir/src/transform/promote_consts.rs index 1d4438d80c9..8d58334545c 100644 --- a/compiler/rustc_mir/src/transform/promote_consts.rs +++ b/compiler/rustc_mir/src/transform/promote_consts.rs @@ -643,7 +643,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> { self.validate_operand(operand)?; } - Rvalue::BinaryOp(op, lhs, rhs) | Rvalue::CheckedBinaryOp(op, lhs, rhs) => { + Rvalue::BinaryOp(op, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(op, box (lhs, rhs)) => { let op = *op; let lhs_ty = lhs.ty(self.body, self.tcx); diff --git a/compiler/rustc_mir/src/transform/simplify_comparison_integral.rs b/compiler/rustc_mir/src/transform/simplify_comparison_integral.rs index bd76e118fdf..32df40ebf9e 100644 --- a/compiler/rustc_mir/src/transform/simplify_comparison_integral.rs +++ b/compiler/rustc_mir/src/transform/simplify_comparison_integral.rs @@ -84,10 +84,10 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { use Operand::*; match rhs { - Rvalue::BinaryOp(_, ref mut left @ Move(_), Constant(_)) => { + Rvalue::BinaryOp(_, box (ref mut left @ Move(_), Constant(_))) => { *left = Copy(opt.to_switch_on); } - Rvalue::BinaryOp(_, Constant(_), ref mut right @ Move(_)) => { + Rvalue::BinaryOp(_, box (Constant(_), ref mut right @ Move(_))) => { *right = Copy(opt.to_switch_on); } _ => (), @@ -166,7 +166,10 @@ fn find_optimizations(&self) -> Vec> { if *lhs == place_switched_on => { match rhs { - Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), left, right) => { + Rvalue::BinaryOp( + op @ (BinOp::Eq | BinOp::Ne), + box (left, right), + ) => { let (branch_value_scalar, branch_value_ty, to_switch_on) = find_branch_value_info(left, right)?; diff --git a/compiler/rustc_mir/src/util/elaborate_drops.rs b/compiler/rustc_mir/src/util/elaborate_drops.rs index 0e2d8e5495b..b22dadcd7d2 100644 --- a/compiler/rustc_mir/src/util/elaborate_drops.rs +++ b/compiler/rustc_mir/src/util/elaborate_drops.rs @@ -678,11 +678,14 @@ fn drop_loop( let one = self.constant_usize(1); let (ptr_next, cur_next) = if ptr_based { - (Rvalue::Use(copy(cur.into())), Rvalue::BinaryOp(BinOp::Offset, move_(cur.into()), one)) + ( + Rvalue::Use(copy(cur.into())), + Rvalue::BinaryOp(BinOp::Offset, box (move_(cur.into()), one)), + ) } else { ( Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)), - Rvalue::BinaryOp(BinOp::Add, move_(cur.into()), one), + Rvalue::BinaryOp(BinOp::Add, box (move_(cur.into()), one)), ) }; @@ -700,7 +703,7 @@ fn drop_loop( let loop_block = BasicBlockData { statements: vec![self.assign( can_go, - Rvalue::BinaryOp(BinOp::Eq, copy(Place::from(cur)), copy(length_or_end)), + Rvalue::BinaryOp(BinOp::Eq, box (copy(Place::from(cur)), copy(length_or_end))), )], is_cleanup: unwind.is_cleanup(), terminator: Some(Terminator { @@ -816,7 +819,10 @@ fn drop_loop_pair( self.assign(cur, Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty)), self.assign( length_or_end, - Rvalue::BinaryOp(BinOp::Offset, Operand::Copy(cur), Operand::Move(length)), + Rvalue::BinaryOp( + BinOp::Offset, + box (Operand::Copy(cur), Operand::Move(length)), + ), ), ] } else { diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index 3308a243a3a..89143e24447 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -667,7 +667,10 @@ fn bounds_check( block, source_info, lt, - Rvalue::BinaryOp(BinOp::Lt, Operand::Copy(Place::from(index)), Operand::Copy(len)), + Rvalue::BinaryOp( + BinOp::Lt, + box (Operand::Copy(Place::from(index)), Operand::Copy(len)), + ), ); let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) }; // assert!(lt, "...") diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index e602f4dd71d..fd696f99706 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -81,7 +81,7 @@ fn expr_as_rvalue( block, source_info, is_min, - Rvalue::BinaryOp(BinOp::Eq, arg.to_copy(), minval), + Rvalue::BinaryOp(BinOp::Eq, box (arg.to_copy(), minval)), ); block = this.assert( @@ -291,7 +291,7 @@ fn expr_as_rvalue( block, source_info, result_value, - Rvalue::CheckedBinaryOp(op, lhs.to_copy(), rhs.to_copy()), + Rvalue::CheckedBinaryOp(op, box (lhs.to_copy(), rhs.to_copy())), ); let val_fld = Field::new(0); let of_fld = Field::new(1); @@ -324,7 +324,7 @@ fn expr_as_rvalue( block, source_info, is_zero, - Rvalue::BinaryOp(BinOp::Eq, rhs.to_copy(), zero), + Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), zero)), ); block = self.assert(block, Operand::Move(is_zero), false, zero_err, span); @@ -345,13 +345,13 @@ fn expr_as_rvalue( block, source_info, is_neg_1, - Rvalue::BinaryOp(BinOp::Eq, rhs.to_copy(), neg_1), + Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), neg_1)), ); self.cfg.push_assign( block, source_info, is_min, - Rvalue::BinaryOp(BinOp::Eq, lhs.to_copy(), min), + Rvalue::BinaryOp(BinOp::Eq, box (lhs.to_copy(), min)), ); let is_neg_1 = Operand::Move(is_neg_1); @@ -360,14 +360,14 @@ fn expr_as_rvalue( block, source_info, of, - Rvalue::BinaryOp(BinOp::BitAnd, is_neg_1, is_min), + Rvalue::BinaryOp(BinOp::BitAnd, box (is_neg_1, is_min)), ); block = self.assert(block, Operand::Move(of), false, overflow_err, span); } } - block.and(Rvalue::BinaryOp(op, lhs, rhs)) + block.and(Rvalue::BinaryOp(op, box (lhs, rhs))) } } diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index 126fb957a6a..ec192b47dee 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -335,7 +335,7 @@ fn compare( let result = self.temp(bool_ty, source_info.span); // result = op(left, right) - self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, left, right)); + self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, box (left, right))); // branch based on result self.cfg.terminate( diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 8a1be7ea172..f4983dd7531 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -411,7 +411,7 @@ fn build_statement(&mut self, stmt: &mir::Statement<'tcx>) -> Result<(), ErrorRe self.locals[local] = self.operand_to_node(span, operand)?; Ok(()) } - Rvalue::BinaryOp(op, ref lhs, ref rhs) if Self::check_binop(op) => { + Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) if Self::check_binop(op) => { let lhs = self.operand_to_node(span, lhs)?; let rhs = self.operand_to_node(span, rhs)?; self.locals[local] = self.add_node(Node::Binop(op, lhs, rhs), span); @@ -421,7 +421,9 @@ fn build_statement(&mut self, stmt: &mir::Statement<'tcx>) -> Result<(), ErrorRe Ok(()) } } - Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) if Self::check_binop(op) => { + Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) + if Self::check_binop(op) => + { let lhs = self.operand_to_node(span, lhs)?; let rhs = self.operand_to_node(span, rhs)?; self.locals[local] = self.add_node(Node::Binop(op, lhs, rhs), span); diff --git a/src/tools/clippy/clippy_lints/src/redundant_clone.rs b/src/tools/clippy/clippy_lints/src/redundant_clone.rs index 06adbb523d7..6a4537e6735 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_clone.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_clone.rs @@ -584,10 +584,10 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) { match rvalue { Use(op) | Repeat(op, _) | Cast(_, op, _) | UnaryOp(_, op) => visit_op(op), Aggregate(_, ops) => ops.iter().for_each(visit_op), - BinaryOp(_, lhs, rhs) | CheckedBinaryOp(_, lhs, rhs) => { + BinaryOp(_, box (lhs, rhs)) | CheckedBinaryOp(_, box (lhs, rhs)) => { visit_op(lhs); visit_op(rhs); - }, + } _ => (), } } diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index a482017afeb..2cb9588e13f 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -172,7 +172,7 @@ fn check_rvalue(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, rvalue: &Rv } }, // binops are fine on integers - Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => { + Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => { check_operand(tcx, lhs, span, body)?; check_operand(tcx, rhs, span, body)?; let ty = lhs.ty(body, tcx); -- 2.44.0