Skip to content

Commit d41f8bf

Browse files
author
Vytautas Astrauskas
committed
Move the explanation why adjust_global_const is called for all constants.
1 parent 844eead commit d41f8bf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/librustc_mir/interpret/operand.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
528528
// potentially requiring the current static to be evaluated again. This is not a
529529
// problem here, because we are building an operand which means an actual read is
530530
// happening.
531+
//
532+
// The machine callback `adjust_global_const` below is guaranteed to
533+
// be called for all constants because `const_eval` calls
534+
// `eval_const_to_op` recursively.
531535
return Ok(self.const_eval(GlobalId { instance, promoted }, val.ty)?);
532536
}
533537
ty::ConstKind::Infer(..)
@@ -539,9 +543,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
539543
};
540544
// This call allows the machine to create fresh allocation ids for
541545
// 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.
546+
// documentation).
545547
let val_val = M::adjust_global_const(self, val_val)?;
546548
// Other cases need layout.
547549
let layout = from_known_layout(self.tcx, layout, || self.layout_of(val.ty))?;

0 commit comments

Comments
 (0)