Skip to content

Commit b85178a

Browse files
committed
no alignment check during interning
1 parent 983f4da commit b85178a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ fn eval_body_using_ecx<'mir, 'tcx>(
7474
None => InternKind::Constant,
7575
}
7676
};
77+
ecx.machine.check_alignment = false; // interning doesn't need to respect alignment
7778
intern_const_alloc_recursive(ecx, intern_kind, &ret)?;
79+
// we leave alignment checks off, since this `ecx` will not be used for further evaluation anyway
7880

7981
debug!("eval_body_using_ecx done: {:?}", *ret);
8082
Ok(ret)

compiler/rustc_const_eval/src/const_eval/machine.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ pub struct CompileTimeInterpreter<'mir, 'tcx> {
8989
/// exhaustion error.
9090
///
9191
/// Setting this to `0` disables the limit and allows the interpreter to run forever.
92-
pub steps_remaining: usize,
92+
pub(super) steps_remaining: usize,
9393

9494
/// The virtual call stack.
95-
pub(crate) stack: Vec<Frame<'mir, 'tcx, AllocId, ()>>,
95+
pub(super) stack: Vec<Frame<'mir, 'tcx, AllocId, ()>>,
9696

9797
/// We need to make sure consts never point to anything mutable, even recursively. That is
9898
/// relied on for pattern matching on consts with references.
@@ -103,7 +103,7 @@ pub struct CompileTimeInterpreter<'mir, 'tcx> {
103103
pub(super) can_access_statics: bool,
104104

105105
/// Whether to check alignment during evaluation.
106-
check_alignment: bool,
106+
pub(super) check_alignment: bool,
107107
}
108108

109109
impl<'mir, 'tcx> CompileTimeInterpreter<'mir, 'tcx> {

0 commit comments

Comments
 (0)