diff options
| author | Vytautas Astrauskas <astrauv@amazon.com> | 2020-04-16 08:09:42 -0700 |
|---|---|---|
| committer | Vytautas Astrauskas <astrauv@amazon.com> | 2020-04-16 08:09:42 -0700 |
| commit | d41f8bf5fdc9ae9588cfcac968a24b131f9707ee (patch) | |
| tree | 22ceac0ed8bd86af055e96321d868071e49bebbb | |
| parent | 844eead57e346444a9182e5e2eee3d41ff0dca3f (diff) | |
| download | rust-d41f8bf5fdc9ae9588cfcac968a24b131f9707ee.tar.gz rust-d41f8bf5fdc9ae9588cfcac968a24b131f9707ee.zip | |
Move the explanation why adjust_global_const is called for all constants.
| -rw-r--r-- | src/librustc_mir/interpret/operand.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 450d5500cfd..678a81bc534 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -528,6 +528,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // 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 // 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)?); } ty::ConstKind::Infer(..) @@ -539,9 +543,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { }; // 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. + // documentation). 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))?; |
