simplify alignment_check_failed a bit
This commit is contained in:
parent
2b2170384d
commit
5a06b1e67c
1 changed files with 5 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::{LangItem, CRATE_HIR_ID};
|
use rustc_hir::{LangItem, CRATE_HIR_ID};
|
||||||
use rustc_middle::mir;
|
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::layout::FnAbiOf;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_session::lint::builtin::INVALID_ALIGNMENT;
|
use rustc_session::lint::builtin::INVALID_ALIGNMENT;
|
||||||
|
@ -345,24 +345,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
required: Align,
|
required: Align,
|
||||||
check: CheckAlignment,
|
check: CheckAlignment,
|
||||||
) -> InterpResult<'tcx, ()> {
|
) -> InterpResult<'tcx, ()> {
|
||||||
|
let err = err_ub!(AlignmentCheckFailed { has, required }).into();
|
||||||
match check {
|
match check {
|
||||||
CheckAlignment::Error => {
|
CheckAlignment::Error => Err(err),
|
||||||
throw_ub!(AlignmentCheckFailed { has, required })
|
|
||||||
}
|
|
||||||
CheckAlignment::No => span_bug!(
|
CheckAlignment::No => span_bug!(
|
||||||
ecx.cur_span(),
|
ecx.cur_span(),
|
||||||
"`alignment_check_failed` called when no alignment check requested"
|
"`alignment_check_failed` called when no alignment check requested"
|
||||||
),
|
),
|
||||||
CheckAlignment::FutureIncompat => {
|
CheckAlignment::FutureIncompat => {
|
||||||
let err = ConstEvalErr::new(
|
let err = ConstEvalErr::new(ecx, err, None);
|
||||||
ecx,
|
|
||||||
InterpError::UndefinedBehavior(UndefinedBehaviorInfo::AlignmentCheckFailed {
|
|
||||||
has,
|
|
||||||
required,
|
|
||||||
})
|
|
||||||
.into(),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
ecx.tcx.struct_span_lint_hir(
|
ecx.tcx.struct_span_lint_hir(
|
||||||
INVALID_ALIGNMENT,
|
INVALID_ALIGNMENT,
|
||||||
ecx.stack().iter().find_map(|frame| frame.lint_root()).unwrap_or(CRATE_HIR_ID),
|
ecx.stack().iter().find_map(|frame| frame.lint_root()).unwrap_or(CRATE_HIR_ID),
|
||||||
|
@ -373,10 +364,10 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
db
|
db
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn load_mir(
|
fn load_mir(
|
||||||
ecx: &InterpCx<'mir, 'tcx, Self>,
|
ecx: &InterpCx<'mir, 'tcx, Self>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue