diff options
| author | Vytautas Astrauskas <astrauv@amazon.com> | 2020-04-16 07:47:10 -0700 |
|---|---|---|
| committer | Vytautas Astrauskas <astrauv@amazon.com> | 2020-04-16 07:47:10 -0700 |
| commit | 844eead57e346444a9182e5e2eee3d41ff0dca3f (patch) | |
| tree | 1bdfb87cc2bc9a487378cf402b6096b230deb76c /src | |
| parent | 738ebcfb6ab1aa6f960f62ff78d7029e554ee51f (diff) | |
| download | rust-844eead57e346444a9182e5e2eee3d41ff0dca3f.tar.gz rust-844eead57e346444a9182e5e2eee3d41ff0dca3f.zip | |
Rename Machine::eval_maybe_thread_local_static_const to adjust_global_const and add an additional comment.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/interpret/machine.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/operand.rs | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 376ce3b239f..dfdd95c95a3 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -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>> { diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index df9ce3f18a9..450d5500cfd 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -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 { |
