Skip to content

Commit b34b0f7

Browse files
authored
Rollup merge of rust-lang#62173 - RalfJung:miri-interp, r=oli-obk
rename InterpretCx -> InterpCx That's more consistent with InterpResult and InterpError. r? @oli-obk
2 parents 0b8b883 + fc918a3 commit b34b0f7

16 files changed

+71
-71
lines changed

src/librustc/mir/interpret/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'
182182
/// up with a Rust-level backtrace of where the error occured.
183183
/// Thsese should always be constructed by calling `.into()` on
184184
/// a `InterpError`. In `librustc_mir::interpret`, we have the `err!`
185-
/// macro for this
185+
/// macro for this.
186186
#[derive(Debug, Clone)]
187187
pub struct InterpErrorInfo<'tcx> {
188188
pub kind: InterpError<'tcx, u64>,

src/librustc_mir/const_eval.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use syntax::source_map::{Span, DUMMY_SP};
2222
use crate::interpret::{self,
2323
PlaceTy, MPlaceTy, OpTy, ImmTy, Immediate, Scalar,
2424
RawConst, ConstValue,
25-
InterpResult, InterpErrorInfo, InterpError, GlobalId, InterpretCx, StackPopCleanup,
25+
InterpResult, InterpErrorInfo, InterpError, GlobalId, InterpCx, StackPopCleanup,
2626
Allocation, AllocId, MemoryKind, Memory,
2727
snapshot, RefTracking, intern_const_alloc_recursive,
2828
};
@@ -34,7 +34,7 @@ const STEPS_UNTIL_DETECTOR_ENABLED: isize = 1_000_000;
3434
/// Should be a power of two for performance reasons.
3535
const DETECTOR_SNAPSHOT_PERIOD: isize = 256;
3636

37-
/// The `InterpretCx` is only meant to be used to do field and index projections into constants for
37+
/// The `InterpCx` is only meant to be used to do field and index projections into constants for
3838
/// `simd_shuffle` and const patterns in match arms.
3939
///
4040
/// The function containing the `match` that is currently being analyzed may have generic bounds
@@ -47,7 +47,7 @@ pub(crate) fn mk_eval_cx<'mir, 'tcx>(
4747
param_env: ty::ParamEnv<'tcx>,
4848
) -> CompileTimeEvalContext<'mir, 'tcx> {
4949
debug!("mk_eval_cx: {:?}", param_env);
50-
InterpretCx::new(tcx.at(span), param_env, CompileTimeInterpreter::new())
50+
InterpCx::new(tcx.at(span), param_env, CompileTimeInterpreter::new())
5151
}
5252

5353
pub(crate) fn eval_promoted<'mir, 'tcx>(
@@ -303,7 +303,7 @@ impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
303303
}
304304

305305
crate type CompileTimeEvalContext<'mir, 'tcx> =
306-
InterpretCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>;
306+
InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>;
307307

308308
impl interpret::MayLeak for ! {
309309
#[inline(always)]
@@ -326,12 +326,12 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
326326
const STATIC_KIND: Option<!> = None; // no copying of statics allowed
327327

328328
#[inline(always)]
329-
fn enforce_validity(_ecx: &InterpretCx<'mir, 'tcx, Self>) -> bool {
329+
fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
330330
false // for now, we don't enforce validity
331331
}
332332

333333
fn find_fn(
334-
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
334+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
335335
instance: ty::Instance<'tcx>,
336336
args: &[OpTy<'tcx>],
337337
dest: Option<PlaceTy<'tcx>>,
@@ -371,7 +371,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
371371
}
372372

373373
fn call_intrinsic(
374-
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
374+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
375375
instance: ty::Instance<'tcx>,
376376
args: &[OpTy<'tcx>],
377377
dest: PlaceTy<'tcx>,
@@ -387,7 +387,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
387387
}
388388

389389
fn ptr_op(
390-
_ecx: &InterpretCx<'mir, 'tcx, Self>,
390+
_ecx: &InterpCx<'mir, 'tcx, Self>,
391391
_bin_op: mir::BinOp,
392392
_left: ImmTy<'tcx>,
393393
_right: ImmTy<'tcx>,
@@ -424,15 +424,15 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
424424
}
425425

426426
fn box_alloc(
427-
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
427+
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
428428
_dest: PlaceTy<'tcx>,
429429
) -> InterpResult<'tcx> {
430430
Err(
431431
ConstEvalError::NeedsRfc("heap allocations via `box` keyword".to_string()).into(),
432432
)
433433
}
434434

435-
fn before_terminator(ecx: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
435+
fn before_terminator(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
436436
{
437437
let steps = &mut ecx.machine.steps_since_detector_enabled;
438438

@@ -457,13 +457,13 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
457457
}
458458

459459
#[inline(always)]
460-
fn stack_push(_ecx: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
460+
fn stack_push(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
461461
Ok(())
462462
}
463463

464464
/// Called immediately before a stack frame gets popped.
465465
#[inline(always)]
466-
fn stack_pop(_ecx: &mut InterpretCx<'mir, 'tcx, Self>, _extra: ()) -> InterpResult<'tcx> {
466+
fn stack_pop(_ecx: &mut InterpCx<'mir, 'tcx, Self>, _extra: ()) -> InterpResult<'tcx> {
467467
Ok(())
468468
}
469469
}
@@ -508,7 +508,7 @@ pub fn const_variant_index<'tcx>(
508508
}
509509

510510
pub fn error_to_const_error<'mir, 'tcx>(
511-
ecx: &InterpretCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
511+
ecx: &InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>>,
512512
mut error: InterpErrorInfo<'tcx>,
513513
) -> ConstEvalErr<'tcx> {
514514
error.print_backtrace();
@@ -632,7 +632,7 @@ pub fn const_eval_raw_provider<'tcx>(
632632
}
633633

634634
let span = tcx.def_span(cid.instance.def_id());
635-
let mut ecx = InterpretCx::new(tcx.at(span), key.param_env, CompileTimeInterpreter::new());
635+
let mut ecx = InterpCx::new(tcx.at(span), key.param_env, CompileTimeInterpreter::new());
636636

637637
let res = ecx.load_mir(cid.instance.def);
638638
res.map(|body| {

src/librustc_mir/interpret/cast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use rustc::mir::interpret::{
1111
};
1212
use rustc::mir::CastKind;
1313

14-
use super::{InterpretCx, Machine, PlaceTy, OpTy, Immediate};
14+
use super::{InterpCx, Machine, PlaceTy, OpTy, Immediate};
1515

16-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
16+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1717
fn type_is_fat_ptr(&self, ty: Ty<'tcx>) -> bool {
1818
match ty.sty {
1919
ty::RawPtr(ty::TypeAndMut { ty, .. }) |

src/librustc_mir/interpret/eval_context.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use super::{
2626
Memory, Machine
2727
};
2828

29-
pub struct InterpretCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
29+
pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
3030
/// Stores the `Machine` instance.
3131
pub machine: M,
3232

@@ -158,14 +158,14 @@ impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {
158158
}
159159
}
160160

161-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for InterpretCx<'mir, 'tcx, M> {
161+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for InterpCx<'mir, 'tcx, M> {
162162
#[inline]
163163
fn data_layout(&self) -> &layout::TargetDataLayout {
164164
&self.tcx.data_layout
165165
}
166166
}
167167

168-
impl<'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for InterpretCx<'mir, 'tcx, M>
168+
impl<'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for InterpCx<'mir, 'tcx, M>
169169
where
170170
M: Machine<'mir, 'tcx>,
171171
{
@@ -175,7 +175,7 @@ where
175175
}
176176
}
177177

178-
impl<'mir, 'tcx, M> layout::HasParamEnv<'tcx> for InterpretCx<'mir, 'tcx, M>
178+
impl<'mir, 'tcx, M> layout::HasParamEnv<'tcx> for InterpCx<'mir, 'tcx, M>
179179
where
180180
M: Machine<'mir, 'tcx>,
181181
{
@@ -184,7 +184,7 @@ where
184184
}
185185
}
186186

187-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpretCx<'mir, 'tcx, M> {
187+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
188188
type Ty = Ty<'tcx>;
189189
type TyLayout = InterpResult<'tcx, TyLayout<'tcx>>;
190190

@@ -195,9 +195,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpretCx<'mir, 'tcx, M>
195195
}
196196
}
197197

198-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
198+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
199199
pub fn new(tcx: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>, machine: M) -> Self {
200-
InterpretCx {
200+
InterpCx {
201201
machine,
202202
tcx,
203203
param_env,

src/librustc_mir/interpret/intrinsics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc::mir::interpret::{
1111
};
1212

1313
use super::{
14-
Machine, PlaceTy, OpTy, InterpretCx, Immediate,
14+
Machine, PlaceTy, OpTy, InterpCx, Immediate,
1515
};
1616

1717
mod type_name;
@@ -39,7 +39,7 @@ fn numeric_intrinsic<'tcx, Tag>(
3939
Ok(Scalar::from_uint(bits_out, size))
4040
}
4141

42-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
42+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
4343
/// Returns `true` if emulation happened.
4444
pub fn emulate_intrinsic(
4545
&mut self,

src/librustc_mir/interpret/machine.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc::ty::{self, query::TyCtxtAt};
1111

1212
use super::{
1313
Allocation, AllocId, InterpResult, Scalar, AllocationExtra,
14-
InterpretCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, Memory
14+
InterpCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, Memory
1515
};
1616

1717
/// Whether this kind of memory is allowed to leak
@@ -95,11 +95,11 @@ pub trait Machine<'mir, 'tcx>: Sized {
9595
const STATIC_KIND: Option<Self::MemoryKinds>;
9696

9797
/// Whether to enforce the validity invariant
98-
fn enforce_validity(ecx: &InterpretCx<'mir, 'tcx, Self>) -> bool;
98+
fn enforce_validity(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool;
9999

100100
/// Called before a basic block terminator is executed.
101101
/// You can use this to detect endlessly running programs.
102-
fn before_terminator(ecx: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx>;
102+
fn before_terminator(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx>;
103103

104104
/// Entry point to all function calls.
105105
///
@@ -112,7 +112,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
112112
/// Passing `dest`and `ret` in the same `Option` proved very annoying when only one of them
113113
/// was used.
114114
fn find_fn(
115-
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
115+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
116116
instance: ty::Instance<'tcx>,
117117
args: &[OpTy<'tcx, Self::PointerTag>],
118118
dest: Option<PlaceTy<'tcx, Self::PointerTag>>,
@@ -122,7 +122,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
122122
/// Directly process an intrinsic without pushing a stack frame.
123123
/// If this returns successfully, the engine will take care of jumping to the next block.
124124
fn call_intrinsic(
125-
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
125+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
126126
instance: ty::Instance<'tcx>,
127127
args: &[OpTy<'tcx, Self::PointerTag>],
128128
dest: PlaceTy<'tcx, Self::PointerTag>,
@@ -145,15 +145,15 @@ pub trait Machine<'mir, 'tcx>: Sized {
145145
///
146146
/// Returns a (value, overflowed) pair if the operation succeeded
147147
fn ptr_op(
148-
ecx: &InterpretCx<'mir, 'tcx, Self>,
148+
ecx: &InterpCx<'mir, 'tcx, Self>,
149149
bin_op: mir::BinOp,
150150
left: ImmTy<'tcx, Self::PointerTag>,
151151
right: ImmTy<'tcx, Self::PointerTag>,
152152
) -> InterpResult<'tcx, (Scalar<Self::PointerTag>, bool)>;
153153

154154
/// Heap allocations via the `box` keyword.
155155
fn box_alloc(
156-
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
156+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
157157
dest: PlaceTy<'tcx, Self::PointerTag>,
158158
) -> InterpResult<'tcx>;
159159

@@ -193,19 +193,19 @@ pub trait Machine<'mir, 'tcx>: Sized {
193193
/// Executes a retagging operation
194194
#[inline]
195195
fn retag(
196-
_ecx: &mut InterpretCx<'mir, 'tcx, Self>,
196+
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
197197
_kind: mir::RetagKind,
198198
_place: PlaceTy<'tcx, Self::PointerTag>,
199199
) -> InterpResult<'tcx> {
200200
Ok(())
201201
}
202202

203203
/// Called immediately before a new stack frame got pushed
204-
fn stack_push(ecx: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx, Self::FrameExtra>;
204+
fn stack_push(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx, Self::FrameExtra>;
205205

206206
/// Called immediately after a stack frame gets popped
207207
fn stack_pop(
208-
ecx: &mut InterpretCx<'mir, 'tcx, Self>,
208+
ecx: &mut InterpCx<'mir, 'tcx, Self>,
209209
extra: Self::FrameExtra,
210210
) -> InterpResult<'tcx>;
211211

src/librustc_mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod intern;
1919
pub use rustc::mir::interpret::*; // have all the `interpret` symbols in one place: here
2020

2121
pub use self::eval_context::{
22-
InterpretCx, Frame, StackPopCleanup, LocalState, LocalValue,
22+
InterpCx, Frame, StackPopCleanup, LocalState, LocalValue,
2323
};
2424

2525
pub use self::place::{Place, PlaceTy, MemPlace, MPlaceTy};

src/librustc_mir/interpret/operand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc::mir::interpret::{
1515
sign_extend, truncate,
1616
};
1717
use super::{
18-
InterpretCx, Machine,
18+
InterpCx, Machine,
1919
MemPlace, MPlaceTy, PlaceTy, Place,
2020
};
2121
pub use rustc::mir::interpret::ScalarMaybeUndef;
@@ -213,7 +213,7 @@ pub(super) fn from_known_layout<'tcx>(
213213
}
214214
}
215215

216-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
216+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
217217
/// Try reading an immediate in memory; this is interesting particularly for `ScalarPair`.
218218
/// Returns `None` if the layout does not permit loading this as a value.
219219
fn try_read_immediate_from_mplace(

src/librustc_mir/interpret/operator.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use syntax::ast::FloatTy;
44
use rustc_apfloat::Float;
55
use rustc::mir::interpret::{InterpResult, Scalar};
66

7-
use super::{InterpretCx, PlaceTy, Immediate, Machine, ImmTy};
7+
use super::{InterpCx, PlaceTy, Immediate, Machine, ImmTy};
88

99

10-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
10+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1111
/// Applies the binary operation `op` to the two operands and writes a tuple of the result
1212
/// and a boolean signifying the potential overflow to the destination.
1313
pub fn binop_with_overflow(
@@ -36,7 +36,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
3636
}
3737
}
3838

39-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
39+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
4040
fn binary_char_op(
4141
&self,
4242
bin_op: mir::BinOp,

src/librustc_mir/interpret/place.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc::ty::TypeFoldable;
1313

1414
use super::{
1515
GlobalId, AllocId, Allocation, Scalar, InterpResult, Pointer, PointerArithmetic,
16-
InterpretCx, Machine, AllocMap, AllocationExtra,
16+
InterpCx, Machine, AllocMap, AllocationExtra,
1717
RawConst, Immediate, ImmTy, ScalarMaybeUndef, Operand, OpTy, MemoryKind, LocalValue
1818
};
1919

@@ -290,7 +290,7 @@ impl<'tcx, Tag: ::std::fmt::Debug> PlaceTy<'tcx, Tag> {
290290
}
291291

292292
// separating the pointer tag for `impl Trait`, see https://github.com/rust-lang/rust/issues/54385
293-
impl<'mir, 'tcx, Tag, M> InterpretCx<'mir, 'tcx, M>
293+
impl<'mir, 'tcx, Tag, M> InterpCx<'mir, 'tcx, M>
294294
where
295295
// FIXME: Working around https://github.com/rust-lang/rust/issues/54385
296296
Tag: ::std::fmt::Debug + Copy + Eq + Hash + 'static,
@@ -583,7 +583,7 @@ where
583583
// global table but not in its local memory: It calls back into tcx through
584584
// a query, triggering the CTFE machinery to actually turn this lazy reference
585585
// into a bunch of bytes. IOW, statics are evaluated with CTFE even when
586-
// this InterpretCx uses another Machine (e.g., in miri). This is what we
586+
// this InterpCx uses another Machine (e.g., in miri). This is what we
587587
// want! This way, computing statics works consistently between codegen
588588
// and miri: They use the same query to eventually obtain a `ty::Const`
589589
// and use that for further computation.

src/librustc_mir/interpret/step.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//! This module contains the `InterpretCx` methods for executing a single step of the interpreter.
1+
//! This module contains the `InterpCx` methods for executing a single step of the interpreter.
22
//!
33
//! The main entry point is the `step` method.
44
55
use rustc::mir;
66
use rustc::ty::layout::LayoutOf;
77
use rustc::mir::interpret::{InterpResult, Scalar, PointerArithmetic};
88

9-
use super::{InterpretCx, Machine};
9+
use super::{InterpCx, Machine};
1010

1111
/// Classify whether an operator is "left-homogeneous", i.e., the LHS has the
1212
/// same type as the result.
@@ -35,7 +35,7 @@ fn binop_right_homogeneous(op: mir::BinOp) -> bool {
3535
}
3636
}
3737

38-
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
38+
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
3939
pub fn run(&mut self) -> InterpResult<'tcx> {
4040
while self.step()? {}
4141
Ok(())

0 commit comments

Comments
 (0)