Skip to content

Commit 388971b

Browse files
committed
interpret: remove some unused trait impls
1 parent 967a9c9 commit 388971b

File tree

3 files changed

+10
-44
lines changed

3 files changed

+10
-44
lines changed

Diff for: compiler/rustc_const_eval/src/interpret/eval_context.rs

+4-36
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ use std::cell::Cell;
22
use std::fmt;
33
use std::mem;
44

5-
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
65
use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
76
use rustc_index::vec::IndexVec;
8-
use rustc_macros::HashStable;
97
use rustc_middle::mir;
108
use rustc_middle::mir::interpret::{InterpError, InvalidProgramInfo};
119
use rustc_middle::ty::layout::{
@@ -16,7 +14,6 @@ use rustc_middle::ty::{
1614
self, query::TyCtxtAt, subst::SubstsRef, ParamEnv, Ty, TyCtxt, TypeFoldable,
1715
};
1816
use rustc_mir_dataflow::storage::always_storage_live_locals;
19-
use rustc_query_system::ich::StableHashingContext;
2017
use rustc_session::Limit;
2118
use rustc_span::{Pos, Span};
2219
use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout};
@@ -142,7 +139,7 @@ pub struct FrameInfo<'tcx> {
142139
}
143140

144141
/// Unwind information.
145-
#[derive(Clone, Copy, Eq, PartialEq, Debug, HashStable)]
142+
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
146143
pub enum StackPopUnwind {
147144
/// The cleanup block.
148145
Cleanup(mir::BasicBlock),
@@ -152,7 +149,7 @@ pub enum StackPopUnwind {
152149
NotAllowed,
153150
}
154151

155-
#[derive(Clone, Copy, Eq, PartialEq, Debug, HashStable)] // Miri debug-prints these
152+
#[derive(Clone, Copy, Eq, PartialEq, Debug)] // Miri debug-prints these
156153
pub enum StackPopCleanup {
157154
/// Jump to the next block in the caller, or cause UB if None (that's a function
158155
/// that may never return). Also store layout of return place so
@@ -168,16 +165,15 @@ pub enum StackPopCleanup {
168165
}
169166

170167
/// State of a local variable including a memoized layout
171-
#[derive(Clone, Debug, PartialEq, Eq, HashStable)]
168+
#[derive(Clone, Debug)]
172169
pub struct LocalState<'tcx, Tag: Provenance = AllocId> {
173170
pub value: LocalValue<Tag>,
174171
/// Don't modify if `Some`, this is only used to prevent computing the layout twice
175-
#[stable_hasher(ignore)]
176172
pub layout: Cell<Option<TyAndLayout<'tcx>>>,
177173
}
178174

179175
/// Current value of a local variable
180-
#[derive(Copy, Clone, PartialEq, Eq, HashStable, Debug)] // Miri debug-prints these
176+
#[derive(Copy, Clone, Debug)] // Miri debug-prints these
181177
pub enum LocalValue<Tag: Provenance = AllocId> {
182178
/// This local is not currently alive, and cannot be used at all.
183179
Dead,
@@ -1021,31 +1017,3 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug
10211017
}
10221018
}
10231019
}
1024-
1025-
impl<'ctx, 'mir, 'tcx, Tag: Provenance, Extra> HashStable<StableHashingContext<'ctx>>
1026-
for Frame<'mir, 'tcx, Tag, Extra>
1027-
where
1028-
Extra: HashStable<StableHashingContext<'ctx>>,
1029-
Tag: HashStable<StableHashingContext<'ctx>>,
1030-
{
1031-
fn hash_stable(&self, hcx: &mut StableHashingContext<'ctx>, hasher: &mut StableHasher) {
1032-
// Exhaustive match on fields to make sure we forget no field.
1033-
let Frame {
1034-
body,
1035-
instance,
1036-
return_to_block,
1037-
return_place,
1038-
locals,
1039-
loc,
1040-
extra,
1041-
tracing_span: _,
1042-
} = self;
1043-
body.hash_stable(hcx, hasher);
1044-
instance.hash_stable(hcx, hasher);
1045-
return_to_block.hash_stable(hcx, hasher);
1046-
return_place.hash_stable(hcx, hasher);
1047-
locals.hash_stable(hcx, hasher);
1048-
loc.hash_stable(hcx, hasher);
1049-
extra.hash_stable(hcx, hasher);
1050-
}
1051-
}

Diff for: compiler/rustc_const_eval/src/interpret/operand.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::fmt::Write;
55

66
use rustc_hir::def::Namespace;
7-
use rustc_macros::HashStable;
87
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
98
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter, Printer};
109
use rustc_middle::ty::{ConstInt, DelaySpanBugEmitted, Ty};
@@ -25,7 +24,7 @@ use super::{
2524
/// operations and wide pointers. This idea was taken from rustc's codegen.
2625
/// In particular, thanks to `ScalarPair`, arithmetic operations and casts can be entirely
2726
/// defined on `Immediate`, and do not have to work with a `Place`.
28-
#[derive(Copy, Clone, PartialEq, Eq, HashStable, Hash, Debug)]
27+
#[derive(Copy, Clone, Debug)]
2928
pub enum Immediate<Tag: Provenance = AllocId> {
3029
/// A single scalar value (must have *initialized* `Scalar` ABI).
3130
/// FIXME: we also currently often use this for ZST.
@@ -182,13 +181,13 @@ impl<'tcx, Tag: Provenance> std::ops::Deref for ImmTy<'tcx, Tag> {
182181
/// An `Operand` is the result of computing a `mir::Operand`. It can be immediate,
183182
/// or still in memory. The latter is an optimization, to delay reading that chunk of
184183
/// memory and to avoid having to store arbitrary-sized data here.
185-
#[derive(Copy, Clone, PartialEq, Eq, HashStable, Hash, Debug)]
184+
#[derive(Copy, Clone, Debug)]
186185
pub enum Operand<Tag: Provenance = AllocId> {
187186
Immediate(Immediate<Tag>),
188187
Indirect(MemPlace<Tag>),
189188
}
190189

191-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
190+
#[derive(Copy, Clone, Debug)]
192191
pub struct OpTy<'tcx, Tag: Provenance = AllocId> {
193192
op: Operand<Tag>, // Keep this private; it helps enforce invariants.
194193
pub layout: TyAndLayout<'tcx>,

Diff for: compiler/rustc_const_eval/src/interpret/place.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use std::hash::Hash;
66

77
use rustc_ast::Mutability;
8-
use rustc_macros::HashStable;
98
use rustc_middle::mir;
109
use rustc_middle::ty;
1110
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
@@ -17,7 +16,7 @@ use super::{
1716
Pointer, Provenance, Scalar, ScalarMaybeUninit,
1817
};
1918

20-
#[derive(Copy, Clone, Hash, PartialEq, Eq, HashStable, Debug)]
19+
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
2120
/// Information required for the sound usage of a `MemPlace`.
2221
pub enum MemPlaceMeta<Tag: Provenance = AllocId> {
2322
/// The unsized payload (e.g. length for slices or vtable pointer for trait objects).
@@ -47,7 +46,7 @@ impl<Tag: Provenance> MemPlaceMeta<Tag> {
4746
}
4847
}
4948

50-
#[derive(Copy, Clone, Hash, PartialEq, Eq, HashStable, Debug)]
49+
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
5150
pub struct MemPlace<Tag: Provenance = AllocId> {
5251
/// The pointer can be a pure integer, with the `None` tag.
5352
pub ptr: Pointer<Option<Tag>>,
@@ -60,7 +59,7 @@ pub struct MemPlace<Tag: Provenance = AllocId> {
6059
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
6160
rustc_data_structures::static_assert_size!(MemPlace, 40);
6261

63-
#[derive(Copy, Clone, Hash, PartialEq, Eq, HashStable, Debug)]
62+
#[derive(Copy, Clone, Debug)]
6463
pub enum Place<Tag: Provenance = AllocId> {
6564
/// A place referring to a value allocated in the `Memory` system.
6665
Ptr(MemPlace<Tag>),

0 commit comments

Comments
 (0)