try to get rid of mir::Const::normalize
This commit is contained in:
parent
e6eb45143c
commit
921a5ef6d7
3 changed files with 3 additions and 19 deletions
|
@ -329,18 +329,6 @@ impl<'tcx> Const<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Normalizes the constant to a value or an error if possible.
|
|
||||||
#[inline]
|
|
||||||
pub fn normalize(self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Self {
|
|
||||||
match self.eval(tcx, param_env, DUMMY_SP) {
|
|
||||||
Ok(val) => Self::Val(val, self.ty()),
|
|
||||||
Err(ErrorHandled::Reported(guar, _span)) => {
|
|
||||||
Self::Ty(Ty::new_error(tcx, guar.into()), ty::Const::new_error(tcx, guar.into()))
|
|
||||||
}
|
|
||||||
Err(ErrorHandled::TooGeneric(_span)) => self,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_eval_scalar(
|
pub fn try_eval_scalar(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -703,8 +703,7 @@ impl<'tcx> Cx<'tcx> {
|
||||||
tcx,
|
tcx,
|
||||||
anon_const.def_id.to_def_id(),
|
anon_const.def_id.to_def_id(),
|
||||||
)
|
)
|
||||||
.instantiate_identity()
|
.instantiate_identity();
|
||||||
.normalize(tcx, self.param_env);
|
|
||||||
let span = tcx.def_span(anon_const.def_id);
|
let span = tcx.def_span(anon_const.def_id);
|
||||||
|
|
||||||
InlineAsmOperand::Const { value, span }
|
InlineAsmOperand::Const { value, span }
|
||||||
|
@ -714,8 +713,7 @@ impl<'tcx> Cx<'tcx> {
|
||||||
tcx,
|
tcx,
|
||||||
anon_const.def_id.to_def_id(),
|
anon_const.def_id.to_def_id(),
|
||||||
)
|
)
|
||||||
.instantiate_identity()
|
.instantiate_identity();
|
||||||
.normalize(tcx, self.param_env);
|
|
||||||
let span = tcx.def_span(anon_const.def_id);
|
let span = tcx.def_span(anon_const.def_id);
|
||||||
|
|
||||||
InlineAsmOperand::SymFn { value, span }
|
InlineAsmOperand::SymFn { value, span }
|
||||||
|
|
|
@ -516,9 +516,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> {
|
||||||
// Avoid handling them, though this could be extended in the future.
|
// Avoid handling them, though this could be extended in the future.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let Some(value) =
|
let Some(value) = value.const_.try_eval_scalar_int(self.tcx, self.param_env) else {
|
||||||
value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()
|
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let conds = conditions.map(self.arena, |c| Condition {
|
let conds = conditions.map(self.arena, |c| Condition {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue