mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-01 09:33:26 +00:00
actually we can reject all reads from mutable allocs in const-prop
This commit is contained in:
parent
7a73b879cb
commit
1939b4c940
@ -282,12 +282,11 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
|
||||
}
|
||||
// If the static allocation is mutable or if it has relocations (it may be legal to mutate
|
||||
// the memory behind that in the future), then we can't const prop it.
|
||||
// FIXME: we only check statics here (that have a `DefId`), not other mutable allocations.
|
||||
// Why that?
|
||||
if def_id.is_some()
|
||||
&& (allocation.mutability == Mutability::Mut || allocation.relocations().len() > 0)
|
||||
{
|
||||
throw_machine_stop_str!("can't eval mutable statics in ConstProp");
|
||||
if allocation.mutability == Mutability::Mut {
|
||||
throw_machine_stop_str!("can't eval mutable globals in ConstProp");
|
||||
}
|
||||
if def_id.is_some() && allocation.relocations().len() > 0 {
|
||||
throw_machine_stop_str!("can't eval statics with pointers in ConstProp");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user