Skip to content

Commit fa0383f

Browse files
author
Jorge Aparicio
committed
librustc_typeck: use #[deriving(Copy)]
1 parent 5e2bca9 commit fa0383f

File tree

6 files changed

+11
-27
lines changed

6 files changed

+11
-27
lines changed

src/librustc_typeck/check/method/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ pub enum MethodError {
4646

4747
// A pared down enum describing just the places from which a method
4848
// candidate can arise. Used for error reporting only.
49-
#[deriving(PartialOrd, Ord, PartialEq, Eq)]
49+
#[deriving(Copy, PartialOrd, Ord, PartialEq, Eq)]
5050
pub enum CandidateSource {
5151
ImplSource(ast::DefId),
5252
TraitSource(/* trait id */ ast::DefId),
5353
}
5454

55-
impl Copy for CandidateSource {}
56-
5755
type MethodIndex = uint; // just for doc purposes
5856

5957
/// Determines whether the type `self_ty` supports a method name `method_name` or not.

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ pub struct Inherited<'a, 'tcx: 'a> {
166166

167167
/// When type-checking an expression, we propagate downward
168168
/// whatever type hint we are able in the form of an `Expectation`.
169+
#[deriving(Copy)]
169170
enum Expectation<'tcx> {
170171
/// We know nothing about what type this expression should have.
171172
NoExpectation,
@@ -177,8 +178,6 @@ enum Expectation<'tcx> {
177178
ExpectCastableToType(Ty<'tcx>),
178179
}
179180

180-
impl<'tcx> Copy for Expectation<'tcx> {}
181-
182181
impl<'tcx> Expectation<'tcx> {
183182
// Disregard "castable to" expectations because they
184183
// can lead us astray. Consider for example `if cond
@@ -1976,14 +1975,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19761975
}
19771976
}
19781977

1979-
#[deriving(Show)]
1978+
#[deriving(Copy, Show)]
19801979
pub enum LvaluePreference {
19811980
PreferMutLvalue,
19821981
NoPreference
19831982
}
19841983

1985-
impl Copy for LvaluePreference {}
1986-
19871984
/// Executes an autoderef loop for the type `t`. At each step, invokes `should_stop` to decide
19881985
/// whether to terminate the loop. Returns the final type and number of derefs that it performed.
19891986
///
@@ -2856,14 +2853,12 @@ pub fn lookup_tup_field_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
28562853

28572854
// Controls whether the arguments are automatically referenced. This is useful
28582855
// for overloaded binary and unary operators.
2859-
#[deriving(PartialEq)]
2856+
#[deriving(Copy, PartialEq)]
28602857
pub enum AutorefArgs {
28612858
Yes,
28622859
No,
28632860
}
28642861

2865-
impl Copy for AutorefArgs {}
2866-
28672862
/// Controls whether the arguments are tupled. This is used for the call
28682863
/// operator.
28692864
///

src/librustc_typeck/check/writeback.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
343343
///////////////////////////////////////////////////////////////////////////
344344
// Resolution reason.
345345

346+
#[deriving(Copy)]
346347
enum ResolveReason {
347348
ResolvingExpr(Span),
348349
ResolvingLocal(Span),
@@ -351,8 +352,6 @@ enum ResolveReason {
351352
ResolvingUnboxedClosure(ast::DefId),
352353
}
353354

354-
impl Copy for ResolveReason {}
355-
356355
impl ResolveReason {
357356
fn span(&self, tcx: &ty::ctxt) -> Span {
358357
match *self {

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ fn convert_associated_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
490490
}
491491
}
492492

493+
#[deriving(Copy)]
493494
enum ConvertMethodContext<'a> {
494495
/// Used when converting implementation methods.
495496
ImplConvertMethodContext,
@@ -498,8 +499,6 @@ enum ConvertMethodContext<'a> {
498499
TraitConvertMethodContext(ast::DefId, &'a [ast::TraitItem]),
499500
}
500501

501-
impl<'a> Copy for ConvertMethodContext<'a> {}
502-
503502
fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
504503
convert_method_context: ConvertMethodContext,
505504
container: ImplOrTraitItemContainer,

src/librustc_typeck/rscope.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ pub trait RegionScope {
3636

3737
// A scope in which all regions must be explicitly named. This is used
3838
// for types that appear in structs and so on.
39+
#[deriving(Copy)]
3940
pub struct ExplicitRscope;
4041

41-
impl Copy for ExplicitRscope {}
42-
4342
impl RegionScope for ExplicitRscope {
4443
fn default_region_bound(&self, _span: Span) -> Option<ty::Region> {
4544
None

src/librustc_typeck/variance.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,16 @@ pub fn infer_variance(tcx: &ty::ctxt) {
229229

230230
type VarianceTermPtr<'a> = &'a VarianceTerm<'a>;
231231

232-
#[deriving(Show)]
232+
#[deriving(Copy, Show)]
233233
struct InferredIndex(uint);
234234

235-
impl Copy for InferredIndex {}
236-
235+
#[deriving(Copy)]
237236
enum VarianceTerm<'a> {
238237
ConstantTerm(ty::Variance),
239238
TransformTerm(VarianceTermPtr<'a>, VarianceTermPtr<'a>),
240239
InferredTerm(InferredIndex),
241240
}
242241

243-
impl<'a> Copy for VarianceTerm<'a> {}
244-
245242
impl<'a> fmt::Show for VarianceTerm<'a> {
246243
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
247244
match *self {
@@ -268,14 +265,12 @@ struct TermsContext<'a, 'tcx: 'a> {
268265
inferred_infos: Vec<InferredInfo<'a>> ,
269266
}
270267

271-
#[deriving(Show, PartialEq)]
268+
#[deriving(Copy, Show, PartialEq)]
272269
enum ParamKind {
273270
TypeParam,
274271
RegionParam
275272
}
276273

277-
impl Copy for ParamKind {}
278-
279274
struct InferredInfo<'a> {
280275
item_id: ast::NodeId,
281276
kind: ParamKind,
@@ -427,13 +422,12 @@ struct ConstraintContext<'a, 'tcx: 'a> {
427422

428423
/// Declares that the variable `decl_id` appears in a location with
429424
/// variance `variance`.
425+
#[deriving(Copy)]
430426
struct Constraint<'a> {
431427
inferred: InferredIndex,
432428
variance: &'a VarianceTerm<'a>,
433429
}
434430

435-
impl<'a> Copy for Constraint<'a> {}
436-
437431
fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
438432
krate: &ast::Crate)
439433
-> ConstraintContext<'a, 'tcx> {

0 commit comments

Comments
 (0)