Skip to content

Commit

Permalink
Don't check interpret_interner when accessing a static to fix miri mu…
Browse files Browse the repository at this point in the history
…table statics
  • Loading branch information
bjorn3 committed Mar 20, 2018
1 parent 75af15e commit 53c6d9b
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/librustc_mir/interpret/place.rs
Expand Up @@ -197,29 +197,17 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
},

Static(ref static_) => {
let alloc = self
.tcx
.interpret_interner
.get_cached(static_.def_id);
let layout = self.layout_of(self.place_ty(mir_place))?;
if let Some(alloc) = alloc {
Place::Ptr {
ptr: MemoryPointer::new(alloc, 0).into(),
align: layout.align,
extra: PlaceExtra::None,
}
} else {
let instance = ty::Instance::mono(*self.tcx, static_.def_id);
let cid = GlobalId {
instance,
promoted: None
};
let alloc = Machine::init_static(self, cid)?;
Place::Ptr {
ptr: MemoryPointer::new(alloc, 0).into(),
align: layout.align,
extra: PlaceExtra::None,
}
let instance = ty::Instance::mono(*self.tcx, static_.def_id);
let cid = GlobalId {
instance,
promoted: None
};
let alloc = Machine::init_static(self, cid)?;
Place::Ptr {
ptr: MemoryPointer::new(alloc, 0).into(),
align: layout.align,
extra: PlaceExtra::None,
}
}

Expand Down

0 comments on commit 53c6d9b

Please sign in to comment.