Skip to content

Commit 844eead

Browse files
author
Vytautas Astrauskas
committed
Rename Machine::eval_maybe_thread_local_static_const to adjust_global_const and add an additional comment.
1 parent 738ebcf commit 844eead

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/librustc_mir/interpret/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
251251
/// `canonical_alloc_id` would result in pointer pointing to `t2`'s thread
252252
/// local and not `t1` as it should.
253253
#[inline]
254-
fn eval_maybe_thread_local_static_const(
254+
fn adjust_global_const(
255255
_ecx: &InterpCx<'mir, 'tcx, Self>,
256256
val: mir::interpret::ConstValue<'tcx>,
257257
) -> InterpResult<'tcx, mir::interpret::ConstValue<'tcx>> {

src/librustc_mir/interpret/operand.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
537537
}
538538
ty::ConstKind::Value(val_val) => val_val,
539539
};
540-
let val_val = M::eval_maybe_thread_local_static_const(self, val_val)?;
540+
// This call allows the machine to create fresh allocation ids for
541+
// thread-local statics (see the `adjust_global_const` function
542+
// documentation). Please note that the `const_eval` call in the early
543+
// return above calls `eval_const_to_op` again, so `adjust_global_const`
544+
// is guaranteed to be called for all constants.
545+
let val_val = M::adjust_global_const(self, val_val)?;
541546
// Other cases need layout.
542547
let layout = from_known_layout(self.tcx, layout, || self.layout_of(val.ty))?;
543548
let op = match val_val {

0 commit comments

Comments
 (0)