Skip to content

Commit 53c6d9b

Browse files
authored
Don't check interpret_interner when accessing a static to fix miri mutable statics
1 parent 75af15e commit 53c6d9b

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

src/librustc_mir/interpret/place.rs

+10-22
Original file line numberDiff line numberDiff line change
@@ -197,29 +197,17 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
197197
},
198198

199199
Static(ref static_) => {
200-
let alloc = self
201-
.tcx
202-
.interpret_interner
203-
.get_cached(static_.def_id);
204200
let layout = self.layout_of(self.place_ty(mir_place))?;
205-
if let Some(alloc) = alloc {
206-
Place::Ptr {
207-
ptr: MemoryPointer::new(alloc, 0).into(),
208-
align: layout.align,
209-
extra: PlaceExtra::None,
210-
}
211-
} else {
212-
let instance = ty::Instance::mono(*self.tcx, static_.def_id);
213-
let cid = GlobalId {
214-
instance,
215-
promoted: None
216-
};
217-
let alloc = Machine::init_static(self, cid)?;
218-
Place::Ptr {
219-
ptr: MemoryPointer::new(alloc, 0).into(),
220-
align: layout.align,
221-
extra: PlaceExtra::None,
222-
}
201+
let instance = ty::Instance::mono(*self.tcx, static_.def_id);
202+
let cid = GlobalId {
203+
instance,
204+
promoted: None
205+
};
206+
let alloc = Machine::init_static(self, cid)?;
207+
Place::Ptr {
208+
ptr: MemoryPointer::new(alloc, 0).into(),
209+
align: layout.align,
210+
extra: PlaceExtra::None,
223211
}
224212
}
225213

0 commit comments

Comments
 (0)