Rename Machine::eval_maybe_thread_local_static_const to adjust_global_const and add an additional comment.

This commit is contained in:
Vytautas Astrauskas 2020-04-16 07:47:10 -07:00
parent 738ebcfb6a
commit 844eead57e
2 changed files with 7 additions and 2 deletions

View File

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

View File

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