Skip to content

Commit 921a5ef

Browse files
committed
try to get rid of mir::Const::normalize
1 parent e6eb451 commit 921a5ef

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

compiler/rustc_middle/src/mir/consts.rs

-12
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,6 @@ impl<'tcx> Const<'tcx> {
329329
}
330330
}
331331

332-
/// Normalizes the constant to a value or an error if possible.
333-
#[inline]
334-
pub fn normalize(self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Self {
335-
match self.eval(tcx, param_env, DUMMY_SP) {
336-
Ok(val) => Self::Val(val, self.ty()),
337-
Err(ErrorHandled::Reported(guar, _span)) => {
338-
Self::Ty(Ty::new_error(tcx, guar.into()), ty::Const::new_error(tcx, guar.into()))
339-
}
340-
Err(ErrorHandled::TooGeneric(_span)) => self,
341-
}
342-
}
343-
344332
#[inline]
345333
pub fn try_eval_scalar(
346334
self,

compiler/rustc_mir_build/src/thir/cx/expr.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,7 @@ impl<'tcx> Cx<'tcx> {
703703
tcx,
704704
anon_const.def_id.to_def_id(),
705705
)
706-
.instantiate_identity()
707-
.normalize(tcx, self.param_env);
706+
.instantiate_identity();
708707
let span = tcx.def_span(anon_const.def_id);
709708

710709
InlineAsmOperand::Const { value, span }
@@ -714,8 +713,7 @@ impl<'tcx> Cx<'tcx> {
714713
tcx,
715714
anon_const.def_id.to_def_id(),
716715
)
717-
.instantiate_identity()
718-
.normalize(tcx, self.param_env);
716+
.instantiate_identity();
719717
let span = tcx.def_span(anon_const.def_id);
720718

721719
InlineAsmOperand::SymFn { value, span }

compiler/rustc_mir_transform/src/jump_threading.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> {
516516
// Avoid handling them, though this could be extended in the future.
517517
return;
518518
}
519-
let Some(value) =
520-
value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()
521-
else {
519+
let Some(value) = value.const_.try_eval_scalar_int(self.tcx, self.param_env) else {
522520
return;
523521
};
524522
let conds = conditions.map(self.arena, |c| Condition {

0 commit comments

Comments
 (0)