Skip to content

Commit b316033

Browse files
committed
rename CompileTimeInterpreter -> CompileTimeMachine, CompileTimeEvalContext -> CompileTimeInterpCx
to match the terms used in the shared interpreter infrastructure
1 parent b6e5e3f commit b316033

File tree

8 files changed

+35
-35
lines changed

8 files changed

+35
-35
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::TyCtxt;
99
use rustc_middle::ty::{layout::LayoutError, ConstInt};
1010
use rustc_span::{Span, Symbol};
1111

12-
use super::CompileTimeInterpreter;
12+
use super::CompileTimeMachine;
1313
use crate::errors::{self, FrameNote, ReportErrorExt};
1414
use crate::interpret::{err_inval, err_machine_stop};
1515
use crate::interpret::{ErrorHandled, Frame, InterpError, InterpErrorInfo, MachineStopType};
@@ -160,7 +160,7 @@ where
160160
// Even if this is unused, please don't remove it -- chances are we will need to emit a lint during const-eval again in the future!
161161
pub(super) fn lint<'tcx, L>(
162162
tcx: TyCtxtAt<'tcx>,
163-
machine: &CompileTimeInterpreter<'tcx>,
163+
machine: &CompileTimeMachine<'tcx>,
164164
lint: &'static rustc_session::lint::Lint,
165165
decorator: impl FnOnce(Vec<errors::FrameNote>) -> L,
166166
) where

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_span::def_id::LocalDefId;
1717
use rustc_span::{Span, DUMMY_SP};
1818
use rustc_target::abi::{self, Abi};
1919

20-
use super::{CanAccessMutGlobal, CompileTimeEvalContext, CompileTimeInterpreter};
20+
use super::{CanAccessMutGlobal, CompileTimeInterpCx, CompileTimeMachine};
2121
use crate::const_eval::CheckAlignment;
2222
use crate::errors::ConstEvalError;
2323
use crate::errors::{self, DanglingPtrInFinal};
@@ -32,7 +32,7 @@ use crate::CTRL_C_RECEIVED;
3232
// Returns a pointer to where the result lives
3333
#[instrument(level = "trace", skip(ecx, body))]
3434
fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
35-
ecx: &mut CompileTimeEvalContext<'tcx>,
35+
ecx: &mut CompileTimeInterpCx<'tcx>,
3636
cid: GlobalId<'tcx>,
3737
body: &'tcx mir::Body<'tcx>,
3838
) -> InterpResult<'tcx, R> {
@@ -139,13 +139,13 @@ pub(crate) fn mk_eval_cx_to_read_const_val<'tcx>(
139139
root_span: Span,
140140
param_env: ty::ParamEnv<'tcx>,
141141
can_access_mut_global: CanAccessMutGlobal,
142-
) -> CompileTimeEvalContext<'tcx> {
142+
) -> CompileTimeInterpCx<'tcx> {
143143
debug!("mk_eval_cx: {:?}", param_env);
144144
InterpCx::new(
145145
tcx,
146146
root_span,
147147
param_env,
148-
CompileTimeInterpreter::new(can_access_mut_global, CheckAlignment::No),
148+
CompileTimeMachine::new(can_access_mut_global, CheckAlignment::No),
149149
)
150150
}
151151

@@ -156,7 +156,7 @@ pub fn mk_eval_cx_for_const_val<'tcx>(
156156
param_env: ty::ParamEnv<'tcx>,
157157
val: mir::ConstValue<'tcx>,
158158
ty: Ty<'tcx>,
159-
) -> Option<(CompileTimeEvalContext<'tcx>, OpTy<'tcx>)> {
159+
) -> Option<(CompileTimeInterpCx<'tcx>, OpTy<'tcx>)> {
160160
let ecx = mk_eval_cx_to_read_const_val(tcx.tcx, tcx.span, param_env, CanAccessMutGlobal::No);
161161
let op = ecx.const_val_to_op(val, ty, None).ok()?;
162162
Some((ecx, op))
@@ -170,7 +170,7 @@ pub fn mk_eval_cx_for_const_val<'tcx>(
170170
/// encounter an `Indirect` they cannot handle.
171171
#[instrument(skip(ecx), level = "debug")]
172172
pub(super) fn op_to_const<'tcx>(
173-
ecx: &CompileTimeEvalContext<'tcx>,
173+
ecx: &CompileTimeInterpCx<'tcx>,
174174
op: &OpTy<'tcx>,
175175
for_diagnostics: bool,
176176
) -> ConstValue<'tcx> {
@@ -328,14 +328,14 @@ pub trait InterpretationResult<'tcx> {
328328
/// evaluation query.
329329
fn make_result(
330330
mplace: MPlaceTy<'tcx>,
331-
ecx: &mut InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
331+
ecx: &mut InterpCx<'tcx, CompileTimeMachine<'tcx>>,
332332
) -> Self;
333333
}
334334

335335
impl<'tcx> InterpretationResult<'tcx> for ConstAlloc<'tcx> {
336336
fn make_result(
337337
mplace: MPlaceTy<'tcx>,
338-
_ecx: &mut InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
338+
_ecx: &mut InterpCx<'tcx, CompileTimeMachine<'tcx>>,
339339
) -> Self {
340340
ConstAlloc { alloc_id: mplace.ptr().provenance.unwrap().alloc_id(), ty: mplace.layout.ty }
341341
}
@@ -383,7 +383,7 @@ fn eval_in_interpreter<'tcx, R: InterpretationResult<'tcx>>(
383383
// they do not have to behave "as if" they were evaluated at runtime.
384384
// For consts however we want to ensure they behave "as if" they were evaluated at runtime,
385385
// so we have to reject reading mutable global memory.
386-
CompileTimeInterpreter::new(CanAccessMutGlobal::from(is_static), CheckAlignment::Error),
386+
CompileTimeMachine::new(CanAccessMutGlobal::from(is_static), CheckAlignment::Error),
387387
);
388388
let res = ecx.load_mir(cid.instance.def, cid.promoted);
389389
res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, body)).map_err(|error| {
@@ -417,7 +417,7 @@ fn eval_in_interpreter<'tcx, R: InterpretationResult<'tcx>>(
417417

418418
#[inline(always)]
419419
fn const_validate_mplace<'tcx>(
420-
ecx: &InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
420+
ecx: &InterpCx<'tcx, CompileTimeMachine<'tcx>>,
421421
mplace: &MPlaceTy<'tcx>,
422422
cid: GlobalId<'tcx>,
423423
) -> Result<(), ErrorHandled> {
@@ -447,7 +447,7 @@ fn const_validate_mplace<'tcx>(
447447

448448
#[inline(always)]
449449
fn report_validation_error<'tcx>(
450-
ecx: &InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
450+
ecx: &InterpCx<'tcx, CompileTimeMachine<'tcx>>,
451451
error: InterpErrorInfo<'tcx>,
452452
alloc_id: AllocId,
453453
) -> ErrorHandled {

compiler/rustc_const_eval/src/const_eval/machine.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const TINY_LINT_TERMINATOR_LIMIT: usize = 20;
4444
const PROGRESS_INDICATOR_START: usize = 4_000_000;
4545

4646
/// Extra machine state for CTFE, and the Machine instance
47-
pub struct CompileTimeInterpreter<'tcx> {
47+
pub struct CompileTimeMachine<'tcx> {
4848
/// The number of terminators that have been evaluated.
4949
///
5050
/// This is used to produce lints informing the user that the compiler is not stuck.
@@ -89,12 +89,12 @@ impl From<bool> for CanAccessMutGlobal {
8989
}
9090
}
9191

92-
impl<'tcx> CompileTimeInterpreter<'tcx> {
92+
impl<'tcx> CompileTimeMachine<'tcx> {
9393
pub(crate) fn new(
9494
can_access_mut_global: CanAccessMutGlobal,
9595
check_alignment: CheckAlignment,
9696
) -> Self {
97-
CompileTimeInterpreter {
97+
CompileTimeMachine {
9898
num_evaluated_steps: 0,
9999
stack: Vec::new(),
100100
can_access_mut_global,
@@ -163,7 +163,7 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxIndexMap<K, V> {
163163
}
164164
}
165165

166-
pub(crate) type CompileTimeEvalContext<'tcx> = InterpCx<'tcx, CompileTimeInterpreter<'tcx>>;
166+
pub(crate) type CompileTimeInterpCx<'tcx> = InterpCx<'tcx, CompileTimeMachine<'tcx>>;
167167

168168
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
169169
pub enum MemoryKind {
@@ -195,7 +195,7 @@ impl interpret::MayLeak for ! {
195195
}
196196
}
197197

198-
impl<'tcx> CompileTimeEvalContext<'tcx> {
198+
impl<'tcx> CompileTimeInterpCx<'tcx> {
199199
fn location_triple_for_span(&self, span: Span) -> (Symbol, u32, u32) {
200200
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
201201
let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo());
@@ -369,7 +369,7 @@ impl<'tcx> CompileTimeEvalContext<'tcx> {
369369
}
370370
}
371371

372-
impl<'tcx> interpret::Machine<'tcx> for CompileTimeInterpreter<'tcx> {
372+
impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
373373
compile_time_machine!(<'tcx>);
374374

375375
type MemoryKind = MemoryKind;

compiler/rustc_const_eval/src/const_eval/valtrees.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_target::abi::{Abi, VariantIdx};
99
use tracing::{debug, instrument, trace};
1010

1111
use super::eval_queries::{mk_eval_cx_to_read_const_val, op_to_const};
12-
use super::machine::CompileTimeEvalContext;
12+
use super::machine::CompileTimeInterpCx;
1313
use super::{ValTreeCreationError, ValTreeCreationResult, VALTREE_MAX_NODES};
1414
use crate::const_eval::CanAccessMutGlobal;
1515
use crate::errors::MaxNumNodesInConstErr;
@@ -21,7 +21,7 @@ use crate::interpret::{
2121

2222
#[instrument(skip(ecx), level = "debug")]
2323
fn branches<'tcx>(
24-
ecx: &CompileTimeEvalContext<'tcx>,
24+
ecx: &CompileTimeInterpCx<'tcx>,
2525
place: &MPlaceTy<'tcx>,
2626
n: usize,
2727
variant: Option<VariantIdx>,
@@ -59,7 +59,7 @@ fn branches<'tcx>(
5959

6060
#[instrument(skip(ecx), level = "debug")]
6161
fn slice_branches<'tcx>(
62-
ecx: &CompileTimeEvalContext<'tcx>,
62+
ecx: &CompileTimeInterpCx<'tcx>,
6363
place: &MPlaceTy<'tcx>,
6464
num_nodes: &mut usize,
6565
) -> ValTreeCreationResult<'tcx> {
@@ -77,7 +77,7 @@ fn slice_branches<'tcx>(
7777

7878
#[instrument(skip(ecx), level = "debug")]
7979
fn const_to_valtree_inner<'tcx>(
80-
ecx: &CompileTimeEvalContext<'tcx>,
80+
ecx: &CompileTimeInterpCx<'tcx>,
8181
place: &MPlaceTy<'tcx>,
8282
num_nodes: &mut usize,
8383
) -> ValTreeCreationResult<'tcx> {
@@ -219,7 +219,7 @@ fn reconstruct_place_meta<'tcx>(
219219

220220
#[instrument(skip(ecx), level = "debug", ret)]
221221
fn create_valtree_place<'tcx>(
222-
ecx: &mut CompileTimeEvalContext<'tcx>,
222+
ecx: &mut CompileTimeInterpCx<'tcx>,
223223
layout: TyAndLayout<'tcx>,
224224
valtree: ty::ValTree<'tcx>,
225225
) -> MPlaceTy<'tcx> {
@@ -364,7 +364,7 @@ pub fn valtree_to_const_value<'tcx>(
364364

365365
/// Put a valtree into memory and return a reference to that.
366366
fn valtree_to_ref<'tcx>(
367-
ecx: &mut CompileTimeEvalContext<'tcx>,
367+
ecx: &mut CompileTimeInterpCx<'tcx>,
368368
valtree: ty::ValTree<'tcx>,
369369
pointee_ty: Ty<'tcx>,
370370
) -> Immediate {
@@ -380,7 +380,7 @@ fn valtree_to_ref<'tcx>(
380380

381381
#[instrument(skip(ecx), level = "debug")]
382382
fn valtree_into_mplace<'tcx>(
383-
ecx: &mut CompileTimeEvalContext<'tcx>,
383+
ecx: &mut CompileTimeInterpCx<'tcx>,
384384
place: &MPlaceTy<'tcx>,
385385
valtree: ty::ValTree<'tcx>,
386386
) {
@@ -457,6 +457,6 @@ fn valtree_into_mplace<'tcx>(
457457
}
458458
}
459459

460-
fn dump_place<'tcx>(ecx: &CompileTimeEvalContext<'tcx>, place: &MPlaceTy<'tcx>) {
460+
fn dump_place<'tcx>(ecx: &CompileTimeInterpCx<'tcx>, place: &MPlaceTy<'tcx>) {
461461
trace!("{:?}", ecx.dump_place(&PlaceTy::from(place.clone())));
462462
}

compiler/rustc_const_eval/src/interpret/intern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub trait HasStaticRootDefId {
4545
fn static_def_id(&self) -> Option<LocalDefId>;
4646
}
4747

48-
impl HasStaticRootDefId for const_eval::CompileTimeInterpreter<'_> {
48+
impl HasStaticRootDefId for const_eval::CompileTimeMachine<'_> {
4949
fn static_def_id(&self) -> Option<LocalDefId> {
5050
Some(self.static_root_ids?.1)
5151
}

compiler/rustc_const_eval/src/interpret/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::const_eval::{CompileTimeEvalContext, CompileTimeInterpreter, InterpretationResult};
1+
use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationResult};
22
use rustc_hir::def_id::LocalDefId;
33
use rustc_middle::mir;
44
use rustc_middle::mir::interpret::{Allocation, InterpResult, Pointer};
@@ -84,7 +84,7 @@ where
8484
impl<'tcx> InterpretationResult<'tcx> for mir::interpret::ConstAllocation<'tcx> {
8585
fn make_result(
8686
mplace: MPlaceTy<'tcx>,
87-
ecx: &mut InterpCx<'tcx, CompileTimeInterpreter<'tcx>>,
87+
ecx: &mut InterpCx<'tcx, CompileTimeMachine<'tcx>>,
8888
) -> Self {
8989
let alloc_id = mplace.ptr().provenance.unwrap().alloc_id();
9090
let alloc = ecx.memory.alloc_map.swap_remove(&alloc_id).unwrap().1;
@@ -93,7 +93,7 @@ impl<'tcx> InterpretationResult<'tcx> for mir::interpret::ConstAllocation<'tcx>
9393
}
9494

9595
pub(crate) fn create_static_alloc<'tcx>(
96-
ecx: &mut CompileTimeEvalContext<'tcx>,
96+
ecx: &mut CompileTimeInterpCx<'tcx>,
9797
static_def_id: LocalDefId,
9898
layout: TyAndLayout<'tcx>,
9999
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {

compiler/rustc_const_eval/src/util/caller_location.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use rustc_middle::ty::{self, Mutability};
77
use rustc_span::symbol::Symbol;
88
use tracing::trace;
99

10-
use crate::const_eval::{mk_eval_cx_to_read_const_val, CanAccessMutGlobal, CompileTimeEvalContext};
10+
use crate::const_eval::{mk_eval_cx_to_read_const_val, CanAccessMutGlobal, CompileTimeInterpCx};
1111
use crate::interpret::*;
1212

1313
/// Allocate a `const core::panic::Location` with the provided filename and line/column numbers.
1414
fn alloc_caller_location<'tcx>(
15-
ecx: &mut CompileTimeEvalContext<'tcx>,
15+
ecx: &mut CompileTimeInterpCx<'tcx>,
1616
filename: Symbol,
1717
line: u32,
1818
col: u32,

compiler/rustc_const_eval/src/util/check_validity_requirement.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_middle::ty::layout::{LayoutCx, LayoutError, LayoutOf, TyAndLayout, Val
33
use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Ty, TyCtxt};
44
use rustc_target::abi::{Abi, FieldsShape, Scalar, Variants};
55

6-
use crate::const_eval::{CanAccessMutGlobal, CheckAlignment, CompileTimeInterpreter};
6+
use crate::const_eval::{CanAccessMutGlobal, CheckAlignment, CompileTimeMachine};
77
use crate::interpret::{InterpCx, MemoryKind, OpTy};
88

99
/// Determines if this type permits "raw" initialization by just transmuting some memory into an
@@ -45,7 +45,7 @@ fn might_permit_raw_init_strict<'tcx>(
4545
tcx: TyCtxt<'tcx>,
4646
kind: ValidityRequirement,
4747
) -> Result<bool, &'tcx LayoutError<'tcx>> {
48-
let machine = CompileTimeInterpreter::new(CanAccessMutGlobal::No, CheckAlignment::Error);
48+
let machine = CompileTimeMachine::new(CanAccessMutGlobal::No, CheckAlignment::Error);
4949

5050
let mut cx = InterpCx::new(tcx, rustc_span::DUMMY_SP, ParamEnv::reveal_all(), machine);
5151

0 commit comments

Comments
 (0)