Skip to content

Commit 40d1cb4

Browse files
authored
Rollup merge of #136455 - nnethercote:less-Clone, r=compiler-errors
Remove some `Clone` bounds and derives. r? `@cjgillot`
2 parents bdc6b4d + f0b6d66 commit 40d1cb4

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

compiler/rustc_middle/src/thir.rs

+22-22
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.
@@ -556,20 +556,20 @@ pub enum ExprKind<'tcx> {
556556
/// Represents the association of a field identifier and an expression.
557557
///
558558
/// This is used in struct constructors.
559-
#[derive(Clone, Debug, HashStable)]
559+
#[derive(Debug, HashStable)]
560560
pub struct FieldExpr {
561561
pub name: FieldIdx,
562562
pub expr: ExprId,
563563
}
564564

565-
#[derive(Clone, Debug, HashStable)]
565+
#[derive(Debug, HashStable)]
566566
pub struct FruInfo<'tcx> {
567567
pub base: ExprId,
568568
pub field_types: Box<[Ty<'tcx>]>,
569569
}
570570

571571
/// A `match` arm.
572-
#[derive(Clone, Debug, HashStable)]
572+
#[derive(Debug, HashStable)]
573573
pub struct Arm<'tcx> {
574574
pub pattern: Box<Pat<'tcx>>,
575575
pub guard: Option<ExprId>,
@@ -587,7 +587,7 @@ pub enum LogicalOp {
587587
Or,
588588
}
589589

590-
#[derive(Clone, Debug, HashStable)]
590+
#[derive(Debug, HashStable)]
591591
pub enum InlineAsmOperand<'tcx> {
592592
In {
593593
reg: InlineAsmRegOrRegClass,
@@ -625,13 +625,13 @@ pub enum InlineAsmOperand<'tcx> {
625625
},
626626
}
627627

628-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
628+
#[derive(Debug, HashStable, TypeVisitable)]
629629
pub struct FieldPat<'tcx> {
630630
pub field: FieldIdx,
631631
pub pattern: Box<Pat<'tcx>>,
632632
}
633633

634-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
634+
#[derive(Debug, HashStable, TypeVisitable)]
635635
pub struct Pat<'tcx> {
636636
pub ty: Ty<'tcx>,
637637
pub span: Span,
@@ -739,7 +739,7 @@ impl<'tcx> Pat<'tcx> {
739739
}
740740
}
741741

742-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
742+
#[derive(Debug, HashStable, TypeVisitable)]
743743
pub struct Ascription<'tcx> {
744744
pub annotation: CanonicalUserTypeAnnotation<'tcx>,
745745
/// Variance to use when relating the `user_ty` to the **type of the value being
@@ -763,7 +763,7 @@ pub struct Ascription<'tcx> {
763763
pub variance: ty::Variance,
764764
}
765765

766-
#[derive(Clone, Debug, HashStable, TypeVisitable)]
766+
#[derive(Debug, HashStable, TypeVisitable)]
767767
pub enum PatKind<'tcx> {
768768
/// A wildcard pattern: `_`.
769769
Wild,

compiler/rustc_type_ir/src/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type Never = std::convert::Infallible;
7373
/// which means in practice almost every foldable type needs to also be
7474
/// visitable. (However, there are some types that are visitable without being
7575
/// foldable.)
76-
pub trait TypeFoldable<I: Interner>: TypeVisitable<I> {
76+
pub trait TypeFoldable<I: Interner>: TypeVisitable<I> + Clone {
7777
/// The entry point for folding. To fold a value `t` with a folder `f`
7878
/// call: `t.try_fold_with(f)`.
7979
///

compiler/rustc_type_ir/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use crate::{self as ty, Interner, TypeFlags};
5959
///
6060
/// To implement this conveniently, use the derive macro located in
6161
/// `rustc_macros`.
62-
pub trait TypeVisitable<I: Interner>: fmt::Debug + Clone {
62+
pub trait TypeVisitable<I: Interner>: fmt::Debug {
6363
/// The entry point for visiting. To visit a value `t` with a visitor `v`
6464
/// call: `t.visit_with(v)`.
6565
///

0 commit comments

Comments
 (0)