summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-09-28 21:15:18 +0200
committerRalf Jung <post@ralfj.de>2024-09-28 21:15:18 +0200
commit921a5ef6d7d2f965dab5b1f8b896dfe042db231b (patch)
tree9663672b2c3ef3e22b83c4ebd1b4409e5a774e61
parente6eb45143cc4dd236dacd6fd8dc74eb1ee6852b2 (diff)
try to get rid of mir::Const::normalize
-rw-r--r--compiler/rustc_middle/src/mir/consts.rs12
-rw-r--r--compiler/rustc_mir_build/src/thir/cx/expr.rs6
-rw-r--r--compiler/rustc_mir_transform/src/jump_threading.rs4
3 files changed, 3 insertions, 19 deletions
diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs
index 89d4c460160..4e5d11831a4 100644
--- a/compiler/rustc_middle/src/mir/consts.rs
+++ b/compiler/rustc_middle/src/mir/consts.rs
@@ -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]
pub fn try_eval_scalar(
self,
diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs
index fbd45f59a4f..f83c7852568 100644
--- a/compiler/rustc_mir_build/src/thir/cx/expr.rs
+++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs
@@ -703,8 +703,7 @@ impl<'tcx> Cx<'tcx> {
tcx,
anon_const.def_id.to_def_id(),
)
- .instantiate_identity()
- .normalize(tcx, self.param_env);
+ .instantiate_identity();
let span = tcx.def_span(anon_const.def_id);
InlineAsmOperand::Const { value, span }
@@ -714,8 +713,7 @@ impl<'tcx> Cx<'tcx> {
tcx,
anon_const.def_id.to_def_id(),
)
- .instantiate_identity()
- .normalize(tcx, self.param_env);
+ .instantiate_identity();
let span = tcx.def_span(anon_const.def_id);
InlineAsmOperand::SymFn { value, span }
diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs
index 9d85b5ba5a7..91fbc91e1e7 100644
--- a/compiler/rustc_mir_transform/src/jump_threading.rs
+++ b/compiler/rustc_mir_transform/src/jump_threading.rs
@@ -516,9 +516,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> {
// Avoid handling them, though this could be extended in the future.
return;
}
- let Some(value) =
- value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()
- else {
+ let Some(value) = value.const_.try_eval_scalar_int(self.tcx, self.param_env) else {
return;
};
let conds = conditions.map(self.arena, |c| Condition {