diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-03-31 19:29:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-31 19:29:35 +0200 |
| commit | 59809bc4c1b41071ae8c0c6d20000b838fbcbf8e (patch) | |
| tree | d793f0eda3ceec892d2cf975e98cfc47af601cbd /src | |
| parent | 6248b59316ee25e00ed9ae4f3a823dad1801361e (diff) | |
| parent | afe1ffb19004fc472294b8cacc34c64d28dd9abc (diff) | |
| download | rust-59809bc4c1b41071ae8c0c6d20000b838fbcbf8e.tar.gz rust-59809bc4c1b41071ae8c0c6d20000b838fbcbf8e.zip | |
Rollup merge of #70614 - RalfJung:cons-prop-reloc, r=wesleywiser
remove unnecessary relocation check in const_prop Unnecessary as per https://github.com/rust-lang/rust/issues/70356#issuecomment-606615292 Fixes https://github.com/rust-lang/rust/issues/70356 r? @oli-obk Cc @wesleywiser
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/transform/const_prop.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 8e004e45b7a..f1ddf3c635f 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -274,19 +274,16 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine { _memory_extra: &(), _alloc_id: AllocId, allocation: &Allocation<Self::PointerTag, Self::AllocExtra>, - static_def_id: Option<DefId>, + _static_def_id: Option<DefId>, is_write: bool, ) -> InterpResult<'tcx> { if is_write { throw_machine_stop_str!("can't write to global"); } - // 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. + // If the static allocation is mutable, then we can't const prop it as its content + // might be different at runtime. if allocation.mutability == Mutability::Mut { - throw_machine_stop_str!("can't eval mutable globals in ConstProp"); - } - if static_def_id.is_some() && allocation.relocations().len() > 0 { - throw_machine_stop_str!("can't eval statics with pointers in ConstProp"); + throw_machine_stop_str!("can't access mutable globals in ConstProp"); } Ok(()) |
