提交 d41f8bf5 编写于 作者: V Vytautas Astrauskas

Move the explanation why adjust_global_const is called for all constants.

上级 844eead5
...@@ -528,6 +528,10 @@ pub(super) fn eval_operands( ...@@ -528,6 +528,10 @@ pub(super) fn eval_operands(
// potentially requiring the current static to be evaluated again. This is not a // potentially requiring the current static to be evaluated again. This is not a
// problem here, because we are building an operand which means an actual read is // problem here, because we are building an operand which means an actual read is
// happening. // happening.
//
// The machine callback `adjust_global_const` below is guaranteed to
// be called for all constants because `const_eval` calls
// `eval_const_to_op` recursively.
return Ok(self.const_eval(GlobalId { instance, promoted }, val.ty)?); return Ok(self.const_eval(GlobalId { instance, promoted }, val.ty)?);
} }
ty::ConstKind::Infer(..) ty::ConstKind::Infer(..)
...@@ -539,9 +543,7 @@ pub(super) fn eval_operands( ...@@ -539,9 +543,7 @@ pub(super) fn eval_operands(
}; };
// This call allows the machine to create fresh allocation ids for // This call allows the machine to create fresh allocation ids for
// thread-local statics (see the `adjust_global_const` function // thread-local statics (see the `adjust_global_const` function
// documentation). Please note that the `const_eval` call in the early // documentation).
// 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)?; let val_val = M::adjust_global_const(self, val_val)?;
// Other cases need layout. // Other cases need layout.
let layout = from_known_layout(self.tcx, layout, || self.layout_of(val.ty))?; let layout = from_known_layout(self.tcx, layout, || self.layout_of(val.ty))?;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册