]> git.lizzy.rs Git - rust.git/commitdiff
Move `Eq + Hash + Clone` bounds to `Machine`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Wed, 4 Jul 2018 20:05:43 +0000 (13:05 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Wed, 4 Jul 2018 21:36:07 +0000 (14:36 -0700)
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/machine.rs
src/librustc_mir/interpret/step.rs

index 363ad537b3f36f4eac621594e5daf94063f69b8c..a92c81e046a0ffd9f01d650d54875ab30191c272 100644 (file)
@@ -163,7 +163,7 @@ pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mi
 }
 
 impl<'a, 'mir, 'tcx, M> Default for InfiniteLoopDetector<'a, 'mir, 'tcx, M>
-    where M: Eq + Hash + Machine<'mir, 'tcx>,
+    where M: Machine<'mir, 'tcx>,
           'tcx: 'a + 'mir,
 {
     fn default() -> Self {
@@ -175,7 +175,7 @@ fn default() -> Self {
 }
 
 impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M>
-    where M: Clone + Eq + Hash + Machine<'mir, 'tcx>,
+    where M: Machine<'mir, 'tcx>,
           'tcx: 'a + 'mir,
 {
     /// Returns `true` if the loop detector has not yet observed a snapshot.
@@ -302,9 +302,7 @@ pub fn new(
         param_env: ty::ParamEnv<'tcx>,
         machine: M,
         memory_data: M::MemoryData,
-    ) -> Self
-        where M: Eq + Hash
-    {
+    ) -> Self {
         EvalContext {
             machine,
             tcx,
@@ -612,9 +610,7 @@ pub(super) fn eval_rvalue_into_place(
         &mut self,
         rvalue: &mir::Rvalue<'tcx>,
         place: &mir::Place<'tcx>,
-    ) -> EvalResult<'tcx>
-        where M: Clone + Eq + Hash,
-    {
+    ) -> EvalResult<'tcx> {
         let dest = self.eval_place(place)?;
         let dest_ty = self.place_ty(place);
 
index f6491d7f1a46903507b236ed17166a976bb3464f..e2086c57c7c7c5ee53da4097bda0f93610809dac 100644 (file)
@@ -15,7 +15,7 @@
 
 /// Methods of this trait signifies a point where CTFE evaluation would fail
 /// and some use case dependent behaviour can instead be applied
-pub trait Machine<'mir, 'tcx>: Sized {
+pub trait Machine<'mir, 'tcx>: Clone + Eq + Hash {
     /// Additional data that can be accessed via the Memory
     type MemoryData: Clone + Eq + Hash;
 
index 25f45fff04d1ee6613553d8e71b9c6dc34f1d24f..db90714d0e6231d7b747fa142f8c6e21d112ac00 100644 (file)
@@ -2,16 +2,12 @@
 //!
 //! The main entry point is the `step` method.
 
-use std::hash::Hash;
-
 use rustc::mir;
 
 use rustc::mir::interpret::EvalResult;
 use super::{EvalContext, Machine};
 
-impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
-    where M: Clone + Eq + Hash,
-{
+impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
     pub fn inc_step_counter_and_detect_loops(&mut self) -> EvalResult<'tcx, ()> {
         /// The number of steps between loop detector snapshots.
         /// Should be a power of two for performance reasons.