From 018d128325da01a236f94afac0e1b40ce1865e84 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 20 Sep 2018 10:17:14 +0200 Subject: [PATCH] rename evaluator -> interpreter to make eddyb happy --- src/librustc_codegen_llvm/mir/constant.rs | 2 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_mir/const_eval.rs | 16 ++++++++-------- src/librustc_mir/hair/pattern/mod.rs | 2 +- src/librustc_mir/interpret/mod.rs | 13 ------------- src/librustc_mir/interpret/snapshot.rs | 12 ++++++------ src/librustc_mir/lib.rs | 2 +- src/librustc_mir/transform/const_prop.rs | 6 +++--- 8 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs index b6c9658dd6fc..ce18f31da690 100644 --- a/src/librustc_codegen_llvm/mir/constant.rs +++ b/src/librustc_codegen_llvm/mir/constant.rs @@ -10,7 +10,7 @@ use llvm; use rustc::mir::interpret::{ConstEvalErr, read_target_uint}; -use rustc_mir::interpret::{const_field}; +use rustc_mir::const_eval::const_field; use rustc::hir::def_id::DefId; use rustc::mir; use rustc_data_structures::indexed_vec::Idx; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index f9e717f8d456..e9a81ee46516 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1612,7 +1612,7 @@ fn validate_const<'a, 'tcx>( gid: ::rustc::mir::interpret::GlobalId<'tcx>, what: &str, ) { - let ecx = ::rustc_mir::interpret::mk_eval_cx(tcx, gid.instance, param_env).unwrap(); + let ecx = ::rustc_mir::const_eval::mk_eval_cx(tcx, gid.instance, param_env).unwrap(); let result = (|| { let op = ecx.const_to_op(constant)?; let mut todo = vec![(op, Vec::new())]; diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 34237a557305..0015f62a8f02 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -42,7 +42,7 @@ pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>( ) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'mir, 'tcx>> { debug!("mk_borrowck_eval_cx: {:?}", instance); let param_env = tcx.param_env(instance.def_id()); - let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator::new(), ()); + let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new(), ()); // insert a stack frame so any queries have the correct substs ecx.stack.push(interpret::Frame { block: mir::START_BLOCK, @@ -64,7 +64,7 @@ pub fn mk_eval_cx<'a, 'tcx>( ) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'tcx, 'tcx>> { debug!("mk_eval_cx: {:?}, {:?}", instance, param_env); let span = tcx.def_span(instance.def_id()); - let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator::new(), ()); + let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new(), ()); let mir = ecx.load_mir(instance.def)?; // insert a stack frame so any queries have the correct substs ecx.push_stack_frame( @@ -133,7 +133,7 @@ fn eval_body_and_ecx<'a, 'mir, 'tcx>( // and try improving it down the road when more information is available let span = tcx.def_span(cid.instance.def_id()); let span = mir.map(|mir| mir.span).unwrap_or(span); - let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator::new(), ()); + let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new(), ()); let r = eval_body_using_ecx(&mut ecx, cid, mir, param_env); (r, ecx) } @@ -230,7 +230,7 @@ impl Error for ConstEvalError { } // Extra machine state for CTFE, and the Machine instance -pub struct CompileTimeEvaluator<'a, 'mir, 'tcx: 'a+'mir> { +pub struct CompileTimeInterpreter<'a, 'mir, 'tcx: 'a+'mir> { /// When this value is negative, it indicates the number of interpreter /// steps *until* the loop detector is enabled. When it is positive, it is /// the number of steps after the detector has been enabled modulo the loop @@ -241,9 +241,9 @@ pub struct CompileTimeEvaluator<'a, 'mir, 'tcx: 'a+'mir> { pub(super) loop_detector: snapshot::InfiniteLoopDetector<'a, 'mir, 'tcx>, } -impl<'a, 'mir, 'tcx> CompileTimeEvaluator<'a, 'mir, 'tcx> { +impl<'a, 'mir, 'tcx> CompileTimeInterpreter<'a, 'mir, 'tcx> { fn new() -> Self { - CompileTimeEvaluator { + CompileTimeInterpreter { loop_detector: Default::default(), steps_since_detector_enabled: -snapshot::STEPS_UNTIL_DETECTOR_ENABLED, } @@ -251,10 +251,10 @@ impl<'a, 'mir, 'tcx> CompileTimeEvaluator<'a, 'mir, 'tcx> { } type CompileTimeEvalContext<'a, 'mir, 'tcx> = - EvalContext<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>; + EvalContext<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>; impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx> - for CompileTimeEvaluator<'a, 'mir, 'tcx> + for CompileTimeInterpreter<'a, 'mir, 'tcx> { type MemoryData = (); type MemoryKinds = !; diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 57519d6ad7d7..c72f87836855 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -16,7 +16,7 @@ mod check_match; pub use self::check_match::check_crate; pub(crate) use self::check_match::check_match; -use interpret::{const_field, const_variant_index}; +use const_eval::{const_field, const_variant_index}; use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability}; use rustc::mir::interpret::{Scalar, GlobalId, ConstValue, sign_extend}; diff --git a/src/librustc_mir/interpret/mod.rs b/src/librustc_mir/interpret/mod.rs index 870ce4574e29..6f07c2996b9c 100644 --- a/src/librustc_mir/interpret/mod.rs +++ b/src/librustc_mir/interpret/mod.rs @@ -35,16 +35,3 @@ pub use self::memory::{Memory, MemoryKind}; pub use self::machine::Machine; pub use self::operand::{Value, ValTy, Operand, OpTy}; - -// reexports for compatibility -pub use const_eval::{ - eval_promoted, - mk_borrowck_eval_cx, - mk_eval_cx, - CompileTimeEvaluator, - const_to_allocation_provider, - const_eval_provider, - const_field, - const_variant_index, - op_to_const, -}; diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 89287d5871f2..388e0fd859d6 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -26,7 +26,7 @@ use syntax::source_map::Span; use super::eval_context::{LocalValue, StackPopCleanup}; use super::{Frame, Memory, Operand, MemPlace, Place, Value}; -use const_eval::CompileTimeEvaluator; +use const_eval::CompileTimeInterpreter; /// Number of steps until the detector even starts doing anything. /// Also, a warning is shown to the user when this number is reached. @@ -61,7 +61,7 @@ impl<'a, 'mir, 'tcx> InfiniteLoopDetector<'a, 'mir, 'tcx> pub fn observe_and_analyze<'b>( &mut self, tcx: &TyCtxt<'b, 'tcx, 'tcx>, - memory: &Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>, + memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: &[Frame<'mir, 'tcx>], ) -> EvalResult<'tcx, ()> { @@ -391,7 +391,7 @@ impl<'a, 'mir, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a Frame<'mir, 'tcx> } impl<'a, 'b, 'mir, 'tcx: 'a+'mir> SnapshotContext<'b> - for Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>> + for Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>> { fn resolve(&'b self, id: &AllocId) -> Option<&'b Allocation> { self.get(*id).ok() @@ -399,17 +399,17 @@ impl<'a, 'b, 'mir, 'tcx: 'a+'mir> SnapshotContext<'b> } /// The virtual machine state during const-evaluation at a given point in time. -/// We assume the `CompileTimeEvaluator` has no interesting extra state that +/// We assume the `CompileTimeInterpreter` has no interesting extra state that /// is worth considering here. struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir> { - memory: Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>, + memory: Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: Vec>, } impl<'a, 'mir, 'tcx: 'a + 'mir> EvalSnapshot<'a, 'mir, 'tcx> { fn new( - memory: &Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>, + memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: &[Frame<'mir, 'tcx>] ) -> Self { EvalSnapshot { diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 1594755b4ab8..4546e0bf253c 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -95,7 +95,7 @@ pub fn provide(providers: &mut Providers) { borrow_check::provide(providers); shim::provide(providers); transform::provide(providers); - providers.const_eval = interpret::const_eval_provider; + providers.const_eval = const_eval::const_eval_provider; providers.check_match = hair::pattern::check_match; } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index e48af71b646b..7cfa7de8138a 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -21,8 +21,8 @@ use rustc::mir::interpret::{ ConstEvalErr, EvalErrorKind, ScalarMaybeUndef, Scalar, GlobalId, EvalResult }; use rustc::ty::{TyCtxt, self, Instance}; -use interpret::{EvalContext, CompileTimeEvaluator, eval_promoted, mk_borrowck_eval_cx}; -use interpret::{self, Value, OpTy, MemoryKind}; +use interpret::{self, EvalContext, Value, OpTy, MemoryKind}; +use const_eval::{CompileTimeInterpreter, eval_promoted, mk_borrowck_eval_cx}; use transform::{MirPass, MirSource}; use syntax::source_map::{Span, DUMMY_SP}; use rustc::ty::subst::Substs; @@ -69,7 +69,7 @@ type Const<'tcx> = (OpTy<'tcx>, Span); /// Finds optimization opportunities on the MIR. struct ConstPropagator<'b, 'a, 'tcx:'a+'b> { - ecx: EvalContext<'a, 'b, 'tcx, CompileTimeEvaluator<'a, 'b, 'tcx>>, + ecx: EvalContext<'a, 'b, 'tcx, CompileTimeInterpreter<'a, 'b, 'tcx>>, mir: &'b Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>, source: MirSource,