Skip to content

Commit fb3aa33

Browse files
committed
Revert "Derive Clone on fewer THIR types."
This reverts commit f0b6d66.
1 parent 96cfc75 commit fb3aa33

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
@@ -19,7 +19,7 @@ use rustc_hir as hir;
1919
use rustc_hir::def_id::DefId;
2020
use rustc_hir::{BindingMode, ByRef, HirId, MatchSource, RangeEnd};
2121
use rustc_index::{IndexVec, newtype_index};
22-
use rustc_macros::{HashStable, TypeVisitable};
22+
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable};
2323
use rustc_span::def_id::LocalDefId;
2424
use rustc_span::{ErrorGuaranteed, Span, Symbol};
2525
use rustc_target::asm::InlineAsmRegOrRegClass;
@@ -52,7 +52,7 @@ macro_rules! thir_with_elements {
5252
/// A container for a THIR body.
5353
///
5454
/// This can be indexed directly by any THIR index (e.g. [`ExprId`]).
55-
#[derive(Debug, HashStable)]
55+
#[derive(Debug, HashStable, Clone)]
5656
pub struct Thir<'tcx> {
5757
pub body_type: BodyTy<'tcx>,
5858
$(
@@ -90,15 +90,15 @@ thir_with_elements! {
9090
params: ParamId => Param<'tcx> => "p{}",
9191
}
9292

93-
#[derive(Debug, HashStable)]
93+
#[derive(Debug, HashStable, Clone)]
9494
pub enum BodyTy<'tcx> {
9595
Const(Ty<'tcx>),
9696
Fn(FnSig<'tcx>),
9797
GlobalAsm(Ty<'tcx>),
9898
}
9999

100100
/// Description of a type-checked function parameter.
101-
#[derive(Debug, HashStable)]
101+
#[derive(Clone, Debug, HashStable)]
102102
pub struct Param<'tcx> {
103103
/// The pattern that appears in the parameter list, or None for implicit parameters.
104104
pub pat: Option<Box<Pat<'tcx>>>,
@@ -118,7 +118,7 @@ pub enum LintLevel {
118118
Explicit(HirId),
119119
}
120120

121-
#[derive(Debug, HashStable)]
121+
#[derive(Clone, Debug, HashStable)]
122122
pub struct Block {
123123
/// Whether the block itself has a label. Used by `label: {}`
124124
/// and `try` blocks.
@@ -138,7 +138,7 @@ pub struct Block {
138138

139139
type UserTy<'tcx> = Option<Box<CanonicalUserType<'tcx>>>;
140140

141-
#[derive(Debug, HashStable)]
141+
#[derive(Clone, Debug, HashStable)]
142142
pub struct AdtExpr<'tcx> {
143143
/// The ADT we're constructing.
144144
pub adt_def: AdtDef<'tcx>,
@@ -155,7 +155,7 @@ pub struct AdtExpr<'tcx> {
155155
pub base: AdtExprBase<'tcx>,
156156
}
157157

158-
#[derive(Debug, HashStable)]
158+
#[derive(Clone, Debug, HashStable)]
159159
pub enum AdtExprBase<'tcx> {
160160
/// A struct expression where all the fields are explicitly enumerated: `Foo { a, b }`.
161161
None,
@@ -168,7 +168,7 @@ pub enum AdtExprBase<'tcx> {
168168
DefaultFields(Box<[Ty<'tcx>]>),
169169
}
170170

171-
#[derive(Debug, HashStable)]
171+
#[derive(Clone, Debug, HashStable)]
172172
pub struct ClosureExpr<'tcx> {
173173
pub closure_id: LocalDefId,
174174
pub args: UpvarArgs<'tcx>,
@@ -177,7 +177,7 @@ pub struct ClosureExpr<'tcx> {
177177
pub fake_reads: Vec<(ExprId, FakeReadCause, HirId)>,
178178
}
179179

180-
#[derive(Debug, HashStable)]
180+
#[derive(Clone, Debug, HashStable)]
181181
pub struct InlineAsmExpr<'tcx> {
182182
pub asm_macro: AsmMacro,
183183
pub template: &'tcx [InlineAsmTemplatePiece],
@@ -195,12 +195,12 @@ pub enum BlockSafety {
195195
ExplicitUnsafe(HirId),
196196
}
197197

198-
#[derive(Debug, HashStable)]
198+
#[derive(Clone, Debug, HashStable)]
199199
pub struct Stmt<'tcx> {
200200
pub kind: StmtKind<'tcx>,
201201
}
202202

203-
#[derive(Debug, HashStable)]
203+
#[derive(Clone, Debug, HashStable)]
204204
pub enum StmtKind<'tcx> {
205205
/// An expression with a trailing semicolon.
206206
Expr {
@@ -240,11 +240,11 @@ pub enum StmtKind<'tcx> {
240240
},
241241
}
242242

243-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, HashStable)]
243+
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
244244
pub struct LocalVarId(pub HirId);
245245

246246
/// A THIR expression.
247-
#[derive(Debug, HashStable)]
247+
#[derive(Clone, Debug, HashStable)]
248248
pub struct Expr<'tcx> {
249249
/// kind of expression
250250
pub kind: ExprKind<'tcx>,
@@ -271,7 +271,7 @@ pub struct TempLifetime {
271271
pub backwards_incompatible: Option<region::Scope>,
272272
}
273273

274-
#[derive(Debug, HashStable)]
274+
#[derive(Clone, Debug, HashStable)]
275275
pub enum ExprKind<'tcx> {
276276
/// `Scope`s are used to explicitly mark destruction scopes,
277277
/// and to track the `HirId` of the expressions within the scope.
@@ -548,20 +548,20 @@ pub enum ExprKind<'tcx> {
548548
/// Represents the association of a field identifier and an expression.
549549
///
550550
/// This is used in struct constructors.
551-
#[derive(Debug, HashStable)]
551+
#[derive(Clone, Debug, HashStable)]
552552
pub struct FieldExpr {
553553
pub name: FieldIdx,
554554
pub expr: ExprId,
555555
}
556556

557-
#[derive(Debug, HashStable)]
557+
#[derive(Clone, Debug, HashStable)]
558558
pub struct FruInfo<'tcx> {
559559
pub base: ExprId,
560560
pub field_types: Box<[Ty<'tcx>]>,
561561
}
562562

563563
/// A `match` arm.
564-
#[derive(Debug, HashStable)]
564+
#[derive(Clone, Debug, HashStable)]
565565
pub struct Arm<'tcx> {
566566
pub pattern: Box<Pat<'tcx>>,
567567
pub guard: Option<ExprId>,
@@ -579,7 +579,7 @@ pub enum LogicalOp {
579579
Or,
580580
}
581581

582-
#[derive(Debug, HashStable)]
582+
#[derive(Clone, Debug, HashStable)]
583583
pub enum InlineAsmOperand<'tcx> {
584584
In {
585585
reg: InlineAsmRegOrRegClass,
@@ -616,13 +616,13 @@ pub enum InlineAsmOperand<'tcx> {
616616
},
617617
}
618618

619-
#[derive(Debug, HashStable, TypeVisitable)]
619+
#[derive(Clone, Debug, HashStable, TypeVisitable)]
620620
pub struct FieldPat<'tcx> {
621621
pub field: FieldIdx,
622622
pub pattern: Pat<'tcx>,
623623
}
624624

625-
#[derive(Debug, HashStable, TypeVisitable)]
625+
#[derive(Clone, Debug, HashStable, TypeVisitable)]
626626
pub struct Pat<'tcx> {
627627
pub ty: Ty<'tcx>,
628628
pub span: Span,
@@ -729,7 +729,7 @@ impl<'tcx> Pat<'tcx> {
729729
}
730730
}
731731

732-
#[derive(Debug, HashStable, TypeVisitable)]
732+
#[derive(Clone, Debug, HashStable, TypeVisitable)]
733733
pub struct Ascription<'tcx> {
734734
pub annotation: CanonicalUserTypeAnnotation<'tcx>,
735735
/// Variance to use when relating the `user_ty` to the **type of the value being
@@ -753,7 +753,7 @@ pub struct Ascription<'tcx> {
753753
pub variance: ty::Variance,
754754
}
755755

756-
#[derive(Debug, HashStable, TypeVisitable)]
756+
#[derive(Clone, Debug, HashStable, TypeVisitable)]
757757
pub enum PatKind<'tcx> {
758758
/// A wildcard pattern: `_`.
759759
Wild,

0 commit comments

Comments
 (0)