diff options
| author | Ralf Jung <post@ralfj.de> | 2023-09-12 23:28:25 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-09-13 07:29:34 +0200 |
| commit | 6e4779ab1775d0901408c08d64dc12c735069701 (patch) | |
| tree | c9b26f901b489aa15840a10b12556ea3a7b87b7a /compiler/rustc_mir_transform/src | |
| parent | e5fedceabf4e0564231db592b6d1f35e1ca27908 (diff) | |
| download | rust-6e4779ab1775d0901408c08d64dc12c735069701.tar.gz rust-6e4779ab1775d0901408c08d64dc12c735069701.zip | |
make the eval() functions on our const types return the resulting value
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/dataflow_const_prop.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index 13550672ecc..11da9612f2f 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -209,7 +209,7 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> { && let operand_ty = operand.ty(self.local_decls, self.tcx) && let Some(operand_ty) = operand_ty.builtin_deref(true) && let ty::Array(_, len) = operand_ty.ty.kind() - && let Some(len) = ConstantKind::Ty(*len).eval(self.tcx, self.param_env).try_to_scalar_int() + && let Some(len) = ConstantKind::Ty(*len).try_eval_scalar_int(self.tcx, self.param_env) { state.insert_value_idx(target_len, FlatSet::Elem(len.into()), self.map()); } @@ -228,8 +228,7 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> { let place_ty = place.ty(self.local_decls, self.tcx); if let ty::Array(_, len) = place_ty.ty.kind() { ConstantKind::Ty(*len) - .eval(self.tcx, self.param_env) - .try_to_scalar() + .try_eval_scalar(self.tcx, self.param_env) .map_or(FlatSet::Top, FlatSet::Elem) } else if let [ProjectionElem::Deref] = place.projection[..] { state.get_len(place.local.into(), self.map()) @@ -304,8 +303,7 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> { ) -> Self::Value { constant .literal - .eval(self.tcx, self.param_env) - .try_to_scalar() + .try_eval_scalar(self.tcx, self.param_env) .map_or(FlatSet::Top, FlatSet::Elem) } |
