Skip to content

Commit cf5eaa7

Browse files
Move Eq + Hash + Clone bounds to Machine
1 parent c395044 commit cf5eaa7

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

src/librustc_mir/interpret/eval_context.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mi
163163
}
164164

165165
impl<'a, 'mir, 'tcx, M> Default for InfiniteLoopDetector<'a, 'mir, 'tcx, M>
166-
where M: Eq + Hash + Machine<'mir, 'tcx>,
166+
where M: Machine<'mir, 'tcx>,
167167
'tcx: 'a + 'mir,
168168
{
169169
fn default() -> Self {
@@ -175,7 +175,7 @@ impl<'a, 'mir, 'tcx, M> Default for InfiniteLoopDetector<'a, 'mir, 'tcx, M>
175175
}
176176

177177
impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M>
178-
where M: Clone + Eq + Hash + Machine<'mir, 'tcx>,
178+
where M: Machine<'mir, 'tcx>,
179179
'tcx: 'a + 'mir,
180180
{
181181
/// Returns `true` if the loop detector has not yet observed a snapshot.
@@ -302,9 +302,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
302302
param_env: ty::ParamEnv<'tcx>,
303303
machine: M,
304304
memory_data: M::MemoryData,
305-
) -> Self
306-
where M: Eq + Hash
307-
{
305+
) -> Self {
308306
EvalContext {
309307
machine,
310308
tcx,
@@ -612,9 +610,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
612610
&mut self,
613611
rvalue: &mir::Rvalue<'tcx>,
614612
place: &mir::Place<'tcx>,
615-
) -> EvalResult<'tcx>
616-
where M: Clone + Eq + Hash,
617-
{
613+
) -> EvalResult<'tcx> {
618614
let dest = self.eval_place(place)?;
619615
let dest_ty = self.place_ty(place);
620616

src/librustc_mir/interpret/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use syntax::ast::Mutability;
1515

1616
/// Methods of this trait signifies a point where CTFE evaluation would fail
1717
/// and some use case dependent behaviour can instead be applied
18-
pub trait Machine<'mir, 'tcx>: Sized {
18+
pub trait Machine<'mir, 'tcx>: Clone + Eq + Hash {
1919
/// Additional data that can be accessed via the Memory
2020
type MemoryData: Clone + Eq + Hash;
2121

src/librustc_mir/interpret/step.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
//!
33
//! The main entry point is the `step` method.
44
5-
use std::hash::Hash;
6-
75
use rustc::mir;
86

97
use rustc::mir::interpret::EvalResult;
108
use super::{EvalContext, Machine};
119

12-
impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
13-
where M: Clone + Eq + Hash,
14-
{
10+
impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
1511
pub fn inc_step_counter_and_detect_loops(&mut self) -> EvalResult<'tcx, ()> {
1612
/// The number of steps between loop detector snapshots.
1713
/// Should be a power of two for performance reasons.

0 commit comments

Comments
 (0)