Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f0b6d66

Browse files
committedFeb 2, 2025
Derive Clone on fewer THIR types.
Some of these were never necessary, and some were facilitated by the previous commit.
1 parent 17e4aec commit f0b6d66

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed
 

‎compiler/rustc_middle/src/thir.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_hir as hir;
1818
use rustc_hir::def_id::DefId;
1919
use rustc_hir::{BindingMode, ByRef, HirId, MatchSource, RangeEnd};
2020
use rustc_index::{IndexVec, newtype_index};
21-
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable};
21+
use rustc_macros::{HashStable, TypeVisitable};
2222
use rustc_middle::middle::region;
2323
use rustc_middle::mir::interpret::AllocId;
2424
use rustc_middle::mir::{self, BinOp, BorrowKind, FakeReadCause, UnOp};
@@ -53,7 +53,7 @@ macro_rules! thir_with_elements {
5353
/// A container for a THIR body.
5454
///
5555
/// This can be indexed directly by any THIR index (e.g. [`ExprId`]).
56-
#[derive(Debug, HashStable, Clone)]
56+
#[derive(Debug, HashStable)]
5757
pub struct Thir<'tcx> {
5858
$(
5959
pub $field_name: $field_ty,
@@ -98,14 +98,14 @@ thir_with_elements! {
9898
params: ParamId => Param<'tcx> => "p{}",
9999
}
100100

101-
#[derive(Debug, HashStable, Clone)]
101+
#[derive(Debug, HashStable)]
102102
pub enum BodyTy<'tcx> {
103103
Const(Ty<'tcx>),
104104
Fn(FnSig<'tcx>),
105105
}
106106

107107
/// Description of a type-checked function parameter.
108-
#[derive(Clone, Debug, HashStable)]
108+
#[derive(Debug, HashStable)]
109109
pub struct Param<'tcx> {
110110
/// The pattern that appears in the parameter list, or None for implicit parameters.
111111
pub pat: Option<Box<Pat<'tcx>>>,
@@ -125,7 +125,7 @@ pub enum LintLevel {
125125
Explicit(HirId),
126126
}
127127

128-
#[derive(Clone, Debug, HashStable)]
128+
#[derive(Debug, HashStable)]
129129
pub struct Block {
130130
/// Whether the block itself has a label. Used by `label: {}`
131131
/// and `try` blocks.
@@ -145,7 +145,7 @@ pub struct Block {
145145

146146
type UserTy<'tcx> = Option<Box<CanonicalUserType<'tcx>>>;
147147

148-
#[derive(Clone, Debug, HashStable)]
148+
#[derive(Debug, HashStable)]
149149
pub struct AdtExpr<'tcx> {
150150
/// The ADT we're constructing.
151151
pub adt_def: AdtDef<'tcx>,
@@ -162,7 +162,7 @@ pub struct AdtExpr<'tcx> {
162162
pub base: AdtExprBase<'tcx>,
163163
}
164164

165-
#[derive(Clone, Debug, HashStable)]
165+
#[derive(Debug, HashStable)]
166166
pub enum AdtExprBase<'tcx> {
167167
/// A struct expression where all the fields are explicitly enumerated: `Foo { a, b }`.
168168
None,
@@ -175,7 +175,7 @@ pub enum AdtExprBase<'tcx> {
175175
DefaultFields(Box<[Ty<'tcx>]>),
176176
}
177177

178-
#[derive(Clone, Debug, HashStable)]
178+
#[derive(Debug, HashStable)]
179179
pub struct ClosureExpr<'tcx> {
180180
pub closure_id: LocalDefId,
181181
pub args: UpvarArgs<'tcx>,
@@ -184,7 +184,7 @@ pub struct ClosureExpr<'tcx> {
184184
pub fake_reads: Vec<(ExprId, FakeReadCause, HirId)>,
185185
}
186186

187-
#[derive(Clone, Debug, HashStable)]
187+
#[derive(Debug, HashStable)]
188188
pub struct InlineAsmExpr<'tcx> {
189189
pub asm_macro: AsmMacro,
190190
pub template: &'tcx [InlineAsmTemplatePiece],
@@ -202,12 +202,12 @@ pub enum BlockSafety {
202202
ExplicitUnsafe(HirId),
203203
}
204204

205-
#[derive(Clone, Debug, HashStable)]
205+
#[derive(Debug, HashStable)]
206206
pub struct Stmt<'tcx> {
207207
pub kind: StmtKind<'tcx>,
208208
}
209209

210-
#[derive(Clone, Debug, HashStable)]
210+
#[derive(Debug, HashStable)]
211211
pub enum StmtKind<'tcx> {
212212
/// An expression with a trailing semicolon.
213213
Expr {
@@ -247,11 +247,11 @@ pub enum StmtKind<'tcx> {
247247
},
248248
}
249249

250-
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
250+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, HashStable)]
251251
pub struct LocalVarId(pub HirId);
252252

253253
/// A THIR expression.
254-
#[derive(Clone, Debug, HashStable)]
254+
#[derive(Debug, HashStable)]
255255
pub struct Expr<'tcx> {
256256
/// kind of expression
257257
pub kind: ExprKind<'tcx>,
@@ -278,7 +278,7 @@ pub struct TempLifetime {
278278
pub backwards_incompatible: Option<region::Scope>,
279279
}
280280

281-
#[derive(Clone, Debug, HashStable)]
281+
#[derive(Debug, HashStable)]
282282
pub enum ExprKind<'tcx> {
283283
/// `Scope`s are used to explicitly mark destruction scopes,
284284
/// and to track the `HirId` of the expressions within the scope.
@@ -543,20 +543,20 @@ pub enum ExprKind<'tcx> {
543543
/// Represents the association of a field identifier and an expression.
544544
///
545545
/// This is used in struct constructors.
546-
#[derive(Clone, Debug, HashStable)]
546+
#[derive(Debug, HashStable)]
547547
pub struct FieldExpr {
548548
pub name: FieldIdx,
549549
pub expr: ExprId,
550550
}
551551

552-
#[derive(Clone, Debug, HashStable)]
552+
#[derive(Debug, HashStable)]
553553
pub struct FruInfo<'tcx> {
554554
pub base: ExprId,
555555
pub field_types: Box<[Ty<'tcx>]>,
556556
}
557557

558558
/// A `match` arm.
559-
#[derive(Clone, Debug, HashStable)]
559+
#[derive(Debug, HashStable)]
560560
pub struct Arm<'tcx> {
561561
pub pattern: Box<Pat<'tcx>>,
562562
pub guard: Option<ExprId>,
@@ -574,7 +574,7 @@ pub enum LogicalOp {
574574
Or,
575575
}
576576

577-
#[derive(Clone, Debug, HashStable)]
577+
#[derive(Debug, HashStable)]
578578
pub enum InlineAsmOperand<'tcx> {
579579
In {
580580
reg: InlineAsmRegOrRegClass,
@@ -612,13 +612,13 @@ pub enum InlineAsmOperand<'tcx> {
612612
},
613613
}
614614

615-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
615+
#[derive(Debug, HashStable, TypeVisitable)]
616616
pub struct FieldPat<'tcx> {
617617
pub field: FieldIdx,
618618
pub pattern: Box<Pat<'tcx>>,
619619
}
620620

621-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
621+
#[derive(Debug, HashStable, TypeVisitable)]
622622
pub struct Pat<'tcx> {
623623
pub ty: Ty<'tcx>,
624624
pub span: Span,
@@ -726,7 +726,7 @@ impl<'tcx> Pat<'tcx> {
726726
}
727727
}
728728

729-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
729+
#[derive(Debug, HashStable, TypeVisitable)]
730730
pub struct Ascription<'tcx> {
731731
pub annotation: CanonicalUserTypeAnnotation<'tcx>,
732732
/// Variance to use when relating the `user_ty` to the **type of the value being
@@ -750,7 +750,7 @@ pub struct Ascription<'tcx> {
750750
pub variance: ty::Variance,
751751
}
752752

753-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
753+
#[derive(Debug, HashStable, TypeVisitable)]
754754
pub enum PatKind<'tcx> {
755755
/// A wildcard pattern: `_`.
756756
Wild,

0 commit comments

Comments
 (0)
Please sign in to comment.