diff options
| author | Ralf Jung <post@ralfj.de> | 2022-11-22 22:04:08 +0100 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-15 16:48:30 +0000 |
| commit | 5a06b1e67c746b5cdcaa03116dcc869b7b8fc2dd (patch) | |
| tree | 11979943f2940d099195734523a8535eb8ffc769 /compiler/rustc_const_eval/src/const_eval | |
| parent | 2b2170384d511a613ddd6a4298feab0ed3a5f6ec (diff) | |
| download | rust-5a06b1e67c746b5cdcaa03116dcc869b7b8fc2dd.tar.gz rust-5a06b1e67c746b5cdcaa03116dcc869b7b8fc2dd.zip | |
simplify alignment_check_failed a bit
Diffstat (limited to 'compiler/rustc_const_eval/src/const_eval')
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/machine.rs | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index abe06737def..e006a62feea 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -1,7 +1,7 @@ use rustc_hir::def::DefKind; use rustc_hir::{LangItem, CRATE_HIR_ID}; use rustc_middle::mir; -use rustc_middle::mir::interpret::{InterpError, PointerArithmetic, UndefinedBehaviorInfo}; +use rustc_middle::mir::interpret::PointerArithmetic; use rustc_middle::ty::layout::FnAbiOf; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::lint::builtin::INVALID_ALIGNMENT; @@ -345,24 +345,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, required: Align, check: CheckAlignment, ) -> InterpResult<'tcx, ()> { + let err = err_ub!(AlignmentCheckFailed { has, required }).into(); match check { - CheckAlignment::Error => { - throw_ub!(AlignmentCheckFailed { has, required }) - } + CheckAlignment::Error => Err(err), CheckAlignment::No => span_bug!( ecx.cur_span(), "`alignment_check_failed` called when no alignment check requested" ), CheckAlignment::FutureIncompat => { - let err = ConstEvalErr::new( - ecx, - InterpError::UndefinedBehavior(UndefinedBehaviorInfo::AlignmentCheckFailed { - has, - required, - }) - .into(), - None, - ); + let err = ConstEvalErr::new(ecx, err, None); ecx.tcx.struct_span_lint_hir( INVALID_ALIGNMENT, ecx.stack().iter().find_map(|frame| frame.lint_root()).unwrap_or(CRATE_HIR_ID), @@ -373,9 +364,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, db }, ); + Ok(()) } } - Ok(()) } fn load_mir( |
