Skip to content

Commit 59809bc

Browse files
authored
Rollup merge of #70614 - RalfJung:cons-prop-reloc, r=wesleywiser
remove unnecessary relocation check in const_prop Unnecessary as per #70356 (comment) Fixes #70356 r? @oli-obk Cc @wesleywiser
2 parents 6248b59 + afe1ffb commit 59809bc

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/librustc_mir/transform/const_prop.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -274,19 +274,16 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
274274
_memory_extra: &(),
275275
_alloc_id: AllocId,
276276
allocation: &Allocation<Self::PointerTag, Self::AllocExtra>,
277-
static_def_id: Option<DefId>,
277+
_static_def_id: Option<DefId>,
278278
is_write: bool,
279279
) -> InterpResult<'tcx> {
280280
if is_write {
281281
throw_machine_stop_str!("can't write to global");
282282
}
283-
// If the static allocation is mutable or if it has relocations (it may be legal to mutate
284-
// the memory behind that in the future), then we can't const prop it.
283+
// If the static allocation is mutable, then we can't const prop it as its content
284+
// might be different at runtime.
285285
if allocation.mutability == Mutability::Mut {
286-
throw_machine_stop_str!("can't eval mutable globals in ConstProp");
287-
}
288-
if static_def_id.is_some() && allocation.relocations().len() > 0 {
289-
throw_machine_stop_str!("can't eval statics with pointers in ConstProp");
286+
throw_machine_stop_str!("can't access mutable globals in ConstProp");
290287
}
291288

292289
Ok(())

0 commit comments

Comments
 (0)