Skip to content

Commit df186ef

Browse files
committed
Remove superfluous traversable impls
1 parent 2c4d9b9 commit df186ef

File tree

20 files changed

+41
-171
lines changed

20 files changed

+41
-171
lines changed

compiler/rustc_middle/src/hir/place.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_hir::HirId;
55
use rustc_target::abi::{FieldIdx, VariantIdx};
66

77
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
8-
#[derive(TypeFoldable, TypeVisitable)]
98
pub enum PlaceBase {
109
/// A temporary variable.
1110
Rvalue,
@@ -18,7 +17,6 @@ pub enum PlaceBase {
1817
}
1918

2019
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
21-
#[derive(TypeFoldable, TypeVisitable)]
2220
pub enum ProjectionKind {
2321
/// A dereference of a pointer, reference or `Box<T>` of the given type.
2422
Deref,

compiler/rustc_middle/src/infer/canonical.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,6 @@ impl<'tcx, R> QueryResponse<'tcx, R> {
364364
pub type QueryOutlivesConstraint<'tcx> =
365365
(ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>, ConstraintCategory<'tcx>);
366366

367-
TrivialTypeTraversalImpls! {
368-
crate::infer::canonical::Certainty,
369-
crate::infer::canonical::CanonicalTyVarKind,
370-
}
371-
372367
impl<'tcx> CanonicalVarValues<'tcx> {
373368
// Given a list of canonical variables, construct a set of values which are
374369
// the identity response.

compiler/rustc_middle/src/mir/basic_blocks.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ impl<'tcx> graph::WithPredecessors for BasicBlocks<'tcx> {
181181
}
182182
}
183183

184-
TrivialTypeTraversalImpls! { Cache }
185-
186184
impl<S: Encoder> Encodable<S> for Cache {
187185
#[inline]
188186
fn encode(&self, _s: &mut S) {}

compiler/rustc_middle/src/mir/coverage.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl ExpressionId {
5353
/// but the zero/counter/expression distinction is also useful for representing
5454
/// the value of code/gap mappings, and the true/false arms of branch mappings.
5555
#[derive(Copy, Clone, PartialEq, Eq)]
56-
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
56+
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
5757
pub enum CovTerm {
5858
Zero,
5959
Counter(CounterId),
@@ -70,7 +70,7 @@ impl Debug for CovTerm {
7070
}
7171
}
7272

73-
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
73+
#[derive(Clone, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
7474
pub enum CoverageKind {
7575
/// Marks the point in MIR control flow represented by a coverage counter.
7676
///
@@ -102,7 +102,6 @@ impl Debug for CoverageKind {
102102
}
103103

104104
#[derive(Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq, Eq, PartialOrd, Ord)]
105-
#[derive(TypeFoldable, TypeVisitable)]
106105
pub struct CodeRegion {
107106
pub file_name: Symbol,
108107
pub start_line: u32,
@@ -122,7 +121,6 @@ impl Debug for CodeRegion {
122121
}
123122

124123
#[derive(Copy, Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
125-
#[derive(TypeFoldable, TypeVisitable)]
126124
pub enum Op {
127125
Subtract,
128126
Add,
@@ -139,15 +137,15 @@ impl Op {
139137
}
140138

141139
#[derive(Clone, Debug)]
142-
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
140+
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
143141
pub struct Expression {
144142
pub lhs: CovTerm,
145143
pub op: Op,
146144
pub rhs: CovTerm,
147145
}
148146

149147
#[derive(Clone, Debug)]
150-
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
148+
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
151149
pub struct Mapping {
152150
pub code_region: CodeRegion,
153151

@@ -164,7 +162,7 @@ pub struct Mapping {
164162
/// to be used in conjunction with the individual coverage statements injected
165163
/// into the function's basic blocks.
166164
#[derive(Clone, Debug)]
167-
#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
165+
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
168166
pub struct FunctionCoverageInfo {
169167
pub function_source_hash: u64,
170168
pub num_counters: usize,

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ impl Into<ErrorGuaranteed> for ReportedErrorInfo {
8282
}
8383
}
8484

85-
TrivialTypeTraversalImpls! { ErrorHandled }
86-
8785
pub type EvalToAllocationRawResult<'tcx> = Result<ConstAlloc<'tcx>, ErrorHandled>;
8886
pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
8987
/// `Ok(None)` indicates the constant was fine, but the valtree couldn't be constructed.

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ pub struct SourceScopeLocalData {
14141414
/// The first will lead to the constraint `w: &'1 str` (for some
14151415
/// inferred region `'1`). The second will lead to the constraint `w:
14161416
/// &'static str`.
1417-
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
1417+
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
14181418
pub struct UserTypeProjections {
14191419
pub contents: Vec<(UserTypeProjection, Span)>,
14201420
}

compiler/rustc_middle/src/mir/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ pub enum ConstraintCategory<'tcx> {
374374
}
375375

376376
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)]
377-
#[derive(TyEncodable, TyDecodable, HashStable, TypeVisitable, TypeFoldable)]
377+
#[derive(TyEncodable, TyDecodable, HashStable)]
378378
pub enum ReturnConstraint {
379379
Normal,
380380
ClosureUpvar(FieldIdx),

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ pub enum FakeReadCause {
520520
}
521521

522522
#[derive(Clone, Debug, PartialEq, TyEncodable, TyDecodable, Hash, HashStable)]
523-
#[derive(TypeFoldable, TypeVisitable)]
524523
pub struct Coverage {
525524
pub kind: CoverageKind,
526525
}
@@ -536,7 +535,6 @@ pub struct CopyNonOverlapping<'tcx> {
536535

537536
/// Represents how a `TerminatorKind::Call` was constructed, used for diagnostics
538537
#[derive(Clone, Copy, TyEncodable, TyDecodable, Debug, PartialEq, Hash, HashStable)]
539-
#[derive(TypeFoldable, TypeVisitable)]
540538
pub enum CallSource {
541539
/// This came from something such as `a > b` or `a + b`. In THIR, if `from_hir_call`
542540
/// is false then this is the desugaring.
@@ -850,7 +848,6 @@ pub struct SwitchTargets {
850848

851849
/// Action to be taken when a stack unwind happens.
852850
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
853-
#[derive(TypeFoldable, TypeVisitable)]
854851
pub enum UnwindAction {
855852
/// No action is to be taken. Continue unwinding.
856853
///
@@ -869,7 +866,6 @@ pub enum UnwindAction {
869866

870867
/// The reason we are terminating the process during unwinding.
871868
#[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
872-
#[derive(TypeFoldable, TypeVisitable)]
873869
pub enum UnwindTerminateReason {
874870
/// Unwinding is just not possible given the ABI of this function.
875871
Abi,
@@ -1362,7 +1358,7 @@ pub enum NullOp<'tcx> {
13621358
}
13631359

13641360
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1365-
#[derive(HashStable, TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)]
1361+
#[derive(HashStable, TyEncodable, TyDecodable)]
13661362
pub enum UnOp {
13671363
/// The `!` operator for logical inversion
13681364
Not,
@@ -1371,7 +1367,7 @@ pub enum UnOp {
13711367
}
13721368

13731369
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Ord, Eq, Hash)]
1374-
#[derive(TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
1370+
#[derive(TyEncodable, TyDecodable, HashStable)]
13751371
pub enum BinOp {
13761372
/// The `+` operator (addition)
13771373
Add,

compiler/rustc_middle/src/mir/type_foldable.rs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,8 @@
11
//! `TypeFoldable` implementations for MIR types
22
3-
use rustc_ast::InlineAsmTemplatePiece;
4-
53
use super::*;
64
use crate::ty;
75

8-
TrivialTypeTraversalImpls! {
9-
BlockTailInfo,
10-
MirPhase,
11-
SourceInfo,
12-
FakeReadCause,
13-
RetagKind,
14-
SourceScope,
15-
SourceScopeLocalData,
16-
UserTypeAnnotationIndex,
17-
BorrowKind,
18-
CastKind,
19-
hir::Movability,
20-
BasicBlock,
21-
SwitchTargets,
22-
CoroutineKind,
23-
CoroutineSavedLocal,
24-
}
25-
26-
TrivialTypeTraversalImpls! {
27-
ConstValue<'tcx>,
28-
NullOp<'tcx>,
29-
}
30-
31-
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [InlineAsmTemplatePiece] {
32-
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
33-
self,
34-
_folder: &mut F,
35-
) -> Result<Self, F::Error> {
36-
Ok(self)
37-
}
38-
}
39-
40-
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [Span] {
41-
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
42-
self,
43-
_folder: &mut F,
44-
) -> Result<Self, F::Error> {
45-
Ok(self)
46-
}
47-
}
48-
496
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx ty::List<PlaceElem<'tcx>> {
507
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
518
self,

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ pub enum ObligationCauseCode<'tcx> {
460460
/// we can walk in order to obtain precise spans for any
461461
/// 'nested' types (e.g. `Foo` in `Option<Foo>`).
462462
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable, Encodable, Decodable)]
463-
#[derive(TypeVisitable, TypeFoldable)]
464463
pub enum WellFormedLoc {
465464
/// Use the type of the provided definition.
466465
Ty(LocalDefId),
@@ -737,8 +736,6 @@ pub enum BuiltinImplSource {
737736
TupleUnsizing,
738737
}
739738

740-
TrivialTypeTraversalImpls! { BuiltinImplSource }
741-
742739
#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
743740
pub enum ObjectSafetyViolation {
744741
/// `Self: Sized` declared on the trait.
@@ -936,7 +933,7 @@ pub enum CodegenObligationError {
936933
FulfillmentError,
937934
}
938935

939-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable, TypeFoldable, TypeVisitable)]
936+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable)]
940937
pub enum DefiningAnchor {
941938
/// `DefId` of the item.
942939
Bind(LocalDefId),

compiler/rustc_middle/src/traits/select.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ impl From<ErrorGuaranteed> for OverflowError {
309309
}
310310
}
311311

312-
TrivialTypeTraversalImpls! { OverflowError }
313-
314312
impl<'tcx> From<OverflowError> for SelectionError<'tcx> {
315313
fn from(overflow_error: OverflowError) -> SelectionError<'tcx> {
316314
match overflow_error {

compiler/rustc_middle/src/traits/solve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct Response<'tcx> {
4949
pub external_constraints: ExternalConstraints<'tcx>,
5050
}
5151

52-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable, TypeFoldable, TypeVisitable)]
52+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable)]
5353
pub enum Certainty {
5454
Yes,
5555
Maybe(MaybeCause),
@@ -89,7 +89,7 @@ impl Certainty {
8989
}
9090

9191
/// Why we failed to evaluate a goal.
92-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable, TypeFoldable, TypeVisitable)]
92+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, HashStable)]
9393
pub enum MaybeCause {
9494
/// We failed due to ambiguity. This ambiguity can either
9595
/// be a true ambiguity, i.e. there are multiple different answers,

compiler/rustc_middle/src/ty/abstract_const.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::ty::{
66
use rustc_errors::ErrorGuaranteed;
77

88
#[derive(Hash, Debug, Clone, Copy, Ord, PartialOrd, PartialEq, Eq)]
9-
#[derive(TyDecodable, TyEncodable, HashStable, TypeVisitable, TypeFoldable)]
9+
#[derive(TyDecodable, TyEncodable, HashStable)]
1010
pub enum CastKind {
1111
/// thir::ExprKind::As
1212
As,
@@ -27,8 +27,6 @@ impl From<ErrorGuaranteed> for NotConstEvaluatable {
2727
}
2828
}
2929

30-
TrivialTypeTraversalImpls! { NotConstEvaluatable }
31-
3230
pub type BoundAbstractConst<'tcx> = Result<Option<EarlyBinder<ty::Const<'tcx>>>, ErrorGuaranteed>;
3331

3432
impl<'tcx> TyCtxt<'tcx> {

compiler/rustc_middle/src/ty/binding.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub enum BindingMode {
66
BindByValue(Mutability),
77
}
88

9-
TrivialTypeTraversalImpls! { BindingMode }
10-
119
impl BindingMode {
1210
pub fn convert(BindingAnnotation(by_ref, mutbl): BindingAnnotation) -> BindingMode {
1311
match by_ref {

compiler/rustc_middle/src/ty/closure.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use self::BorrowKind::*;
2323
pub const CAPTURE_STRUCT_LOCAL: mir::Local = mir::Local::from_u32(1);
2424

2525
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
26-
#[derive(TypeFoldable, TypeVisitable)]
2726
pub struct UpvarPath {
2827
pub hir_id: hir::HirId,
2928
}
@@ -32,7 +31,6 @@ pub struct UpvarPath {
3231
/// the original var ID (that is, the root variable that is referenced
3332
/// by the upvar) and the ID of the closure expression.
3433
#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
35-
#[derive(TypeFoldable, TypeVisitable)]
3634
pub struct UpvarId {
3735
pub var_path: UpvarPath,
3836
pub closure_expr_id: LocalDefId,
@@ -47,7 +45,6 @@ impl UpvarId {
4745
/// Information describing the capture of an upvar. This is computed
4846
/// during `typeck`, specifically by `regionck`.
4947
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, HashStable)]
50-
#[derive(TypeFoldable, TypeVisitable)]
5148
pub enum UpvarCapture {
5249
/// Upvar is captured by value. This is always true when the
5350
/// closure is labeled `move`, but can also be true in other cases
@@ -314,7 +311,6 @@ pub fn is_ancestor_or_same_capture(
314311
/// for a particular capture as well as identifying the part of the source code
315312
/// that triggered this capture to occur.
316313
#[derive(PartialEq, Clone, Debug, Copy, TyEncodable, TyDecodable, HashStable)]
317-
#[derive(TypeFoldable, TypeVisitable)]
318314
pub struct CaptureInfo {
319315
/// Expr Id pointing to use that resulted in selecting the current capture kind
320316
///
@@ -393,7 +389,6 @@ pub fn place_to_string_for_capture<'tcx>(tcx: TyCtxt<'tcx>, place: &HirPlace<'tc
393389
}
394390

395391
#[derive(Clone, PartialEq, Debug, TyEncodable, TyDecodable, Copy, HashStable)]
396-
#[derive(TypeFoldable, TypeVisitable)]
397392
pub enum BorrowKind {
398393
/// Data must be immutable and is aliasable.
399394
ImmBorrow,

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ impl fmt::Display for ImplPolarity {
283283
}
284284

285285
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable, Debug)]
286-
#[derive(TypeFoldable, TypeVisitable)]
287286
pub enum Asyncness {
288287
Yes,
289288
No,

0 commit comments

Comments
 (0)