From 9e00fb0d8911dfdf9cb9583adcc05d55bef4d34f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 4 Jun 2022 11:15:36 -0400 Subject: [PATCH] tweak some bug!s --- compiler/rustc_const_eval/src/interpret/intrinsics.rs | 6 +++--- .../src/interpret/intrinsics/caller_location.rs | 2 +- compiler/rustc_const_eval/src/interpret/operator.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index bf1cf816ddd..c5770f50526 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -169,7 +169,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { sym::needs_drop => self.tcx.types.bool, sym::type_id => self.tcx.types.u64, sym::type_name => self.tcx.mk_static_str(), - _ => bug!("already checked for nullary intrinsics"), + _ => bug!(), }; let val = self.tcx.const_eval_global_id(self.param_env, gid, Some(self.tcx.span))?; @@ -215,7 +215,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { sym::add_with_overflow => BinOp::Add, sym::sub_with_overflow => BinOp::Sub, sym::mul_with_overflow => BinOp::Mul, - _ => bug!("Already checked for int ops"), + _ => bug!(), }; self.binop_with_overflow(bin_op, &lhs, &rhs, dest)?; } @@ -251,7 +251,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { sym::unchecked_mul => BinOp::Mul, sym::unchecked_div => BinOp::Div, sym::unchecked_rem => BinOp::Rem, - _ => bug!("Already checked for int ops"), + _ => bug!(), }; let (val, overflowed, _ty) = self.overflowing_binary_op(bin_op, &l, &r)?; if overflowed { diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs index e66cb9837c9..23ae2db6438 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs @@ -70,7 +70,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } - bug!("no non-`#[track_caller]` frame found") + span_bug!(self.cur_span(), "no non-`#[track_caller]` frame found") } /// Allocate a `const core::panic::Location` with the provided filename and line/column numbers. diff --git a/compiler/rustc_const_eval/src/interpret/operator.rs b/compiler/rustc_const_eval/src/interpret/operator.rs index 6dae9dc72b7..85ee88e9e47 100644 --- a/compiler/rustc_const_eval/src/interpret/operator.rs +++ b/compiler/rustc_const_eval/src/interpret/operator.rs @@ -154,14 +154,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let result = match bin_op { Shl => l.checked_shl(r).unwrap(), Shr => l.checked_shr(r).unwrap(), - _ => bug!("it has already been checked that this is a shift op"), + _ => bug!(), }; result as u128 } else { match bin_op { Shl => l.checked_shl(r).unwrap(), Shr => l.checked_shr(r).unwrap(), - _ => bug!("it has already been checked that this is a shift op"), + _ => bug!(), } }; let truncated = self.truncate(result, left_layout);