Skip to content

Commit b2bf37a

Browse files
committed
Burn some invariants we keep up into code
1 parent bd18cc5 commit b2bf37a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/librustc_mir/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn op_to_const<'tcx>(
7676
_ => false,
7777
};
7878
let normalized_op = if normalize {
79-
ecx.try_read_immediate(op)?
79+
Ok(*ecx.read_immediate(op).expect("normalization works on validated constants"))
8080
} else {
8181
match *op {
8282
Operand::Indirect(mplace) => Err(mplace),

src/librustc_mir/interpret/operand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pub(super) fn from_known_layout<'tcx>(
269269
impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
270270
/// Try reading an immediate in memory; this is interesting particularly for ScalarPair.
271271
/// Returns `None` if the layout does not permit loading this as a value.
272-
pub(super) fn try_read_immediate_from_mplace(
272+
fn try_read_immediate_from_mplace(
273273
&self,
274274
mplace: MPlaceTy<'tcx, M::PointerTag>,
275275
) -> EvalResult<'tcx, Option<Immediate<M::PointerTag>>> {
@@ -323,7 +323,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
323323
/// Note that for a given layout, this operation will either always fail or always
324324
/// succeed! Whether it succeeds depends on whether the layout can be represented
325325
/// in a `Immediate`, not on which data is stored there currently.
326-
pub(crate) fn try_read_immediate(
326+
pub(super) fn try_read_immediate(
327327
&self,
328328
src: OpTy<'tcx, M::PointerTag>,
329329
) -> EvalResult<'tcx, Result<Immediate<M::PointerTag>, MemPlace<M::PointerTag>>> {

0 commit comments

Comments
 (0)