Skip to content

Commit 20771ae

Browse files
authored
Rollup merge of #70385 - RalfJung:miri-nits, r=eddyb
Miri nits: comment and var name improvement r? @eddyb
2 parents b0a63cb + b5343d6 commit 20771ae

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/librustc_mir/const_eval/machine.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter {
178178

179179
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
180180

181-
const GLOBAL_KIND: Option<!> = None; // no copying of globals allowed
181+
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
182182

183183
// We do not check for alignment to avoid having to carry an `Align`
184184
// in `ConstValue::ByRef`.
@@ -350,15 +350,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter {
350350
memory_extra: &MemoryExtra,
351351
alloc_id: AllocId,
352352
allocation: &Allocation,
353-
def_id: Option<DefId>,
353+
static_def_id: Option<DefId>,
354354
is_write: bool,
355355
) -> InterpResult<'tcx> {
356356
if is_write && allocation.mutability == Mutability::Not {
357357
Err(err_ub!(WriteToReadOnly(alloc_id)).into())
358358
} else if is_write {
359359
Err(ConstEvalErrKind::ModifiedGlobal.into())
360-
} else if memory_extra.can_access_statics || def_id.is_none() {
361-
// `def_id.is_none()` indicates this is not a static, but a const or so.
360+
} else if memory_extra.can_access_statics || static_def_id.is_none() {
361+
// `static_def_id.is_none()` indicates this is not a static, but a const or so.
362362
Ok(())
363363
} else {
364364
Err(ConstEvalErrKind::ConstAccessesStatic.into())

src/librustc_mir/interpret/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
215215
_memory_extra: &Self::MemoryExtra,
216216
_alloc_id: AllocId,
217217
_allocation: &Allocation,
218-
_def_id: Option<DefId>,
218+
_static_def_id: Option<DefId>,
219219
_is_write: bool,
220220
) -> InterpResult<'tcx> {
221221
Ok(())

src/librustc_mir/transform/const_prop.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
172172

173173
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
174174

175-
const GLOBAL_KIND: Option<!> = None;
175+
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
176176

177177
const CHECK_ALIGN: bool = false;
178178

@@ -274,7 +274,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
274274
_memory_extra: &(),
275275
_alloc_id: AllocId,
276276
allocation: &Allocation<Self::PointerTag, Self::AllocExtra>,
277-
def_id: Option<DefId>,
277+
static_def_id: Option<DefId>,
278278
is_write: bool,
279279
) -> InterpResult<'tcx> {
280280
if is_write {
@@ -285,7 +285,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
285285
if allocation.mutability == Mutability::Mut {
286286
throw_machine_stop_str!("can't eval mutable globals in ConstProp");
287287
}
288-
if def_id.is_some() && allocation.relocations().len() > 0 {
288+
if static_def_id.is_some() && allocation.relocations().len() > 0 {
289289
throw_machine_stop_str!("can't eval statics with pointers in ConstProp");
290290
}
291291

0 commit comments

Comments
 (0)