diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-14 23:16:06 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-19 10:51:00 -0500 |
| commit | fa0383f38d4b165ad2285efade1bbdbb780cdfe5 (patch) | |
| tree | 7a467dc2c698afe3906b39a4623f9cc380c18b22 /src | |
| parent | 5e2bca9e86ee6e40d6aaf6e4f4ba60a6e71b01e4 (diff) | |
| download | rust-fa0383f38d4b165ad2285efade1bbdbb780cdfe5.tar.gz rust-fa0383f38d4b165ad2285efade1bbdbb780cdfe5.zip | |
librustc_typeck: use `#[deriving(Copy)]`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/method/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 11 | ||||
| -rw-r--r-- | src/librustc_typeck/check/writeback.rs | 3 | ||||
| -rw-r--r-- | src/librustc_typeck/collect.rs | 3 | ||||
| -rw-r--r-- | src/librustc_typeck/rscope.rs | 3 | ||||
| -rw-r--r-- | src/librustc_typeck/variance.rs | 14 |
6 files changed, 11 insertions, 27 deletions
diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index ffaeceb3eed..3b7eb22e56c 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -46,14 +46,12 @@ pub enum MethodError { // A pared down enum describing just the places from which a method // candidate can arise. Used for error reporting only. -#[deriving(PartialOrd, Ord, PartialEq, Eq)] +#[deriving(Copy, PartialOrd, Ord, PartialEq, Eq)] pub enum CandidateSource { ImplSource(ast::DefId), TraitSource(/* trait id */ ast::DefId), } -impl Copy for CandidateSource {} - type MethodIndex = uint; // just for doc purposes /// Determines whether the type `self_ty` supports a method name `method_name` or not. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9e249cc449d..bbc33826f35 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -166,6 +166,7 @@ pub struct Inherited<'a, 'tcx: 'a> { /// When type-checking an expression, we propagate downward /// whatever type hint we are able in the form of an `Expectation`. +#[deriving(Copy)] enum Expectation<'tcx> { /// We know nothing about what type this expression should have. NoExpectation, @@ -177,8 +178,6 @@ enum Expectation<'tcx> { ExpectCastableToType(Ty<'tcx>), } -impl<'tcx> Copy for Expectation<'tcx> {} - impl<'tcx> Expectation<'tcx> { // Disregard "castable to" expectations because they // can lead us astray. Consider for example `if cond @@ -1976,14 +1975,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } -#[deriving(Show)] +#[deriving(Copy, Show)] pub enum LvaluePreference { PreferMutLvalue, NoPreference } -impl Copy for LvaluePreference {} - /// Executes an autoderef loop for the type `t`. At each step, invokes `should_stop` to decide /// whether to terminate the loop. Returns the final type and number of derefs that it performed. /// @@ -2856,14 +2853,12 @@ pub fn lookup_tup_field_ty<'tcx>(tcx: &ty::ctxt<'tcx>, // Controls whether the arguments are automatically referenced. This is useful // for overloaded binary and unary operators. -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] pub enum AutorefArgs { Yes, No, } -impl Copy for AutorefArgs {} - /// Controls whether the arguments are tupled. This is used for the call /// operator. /// diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index b73381966e8..700d1211606 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -343,6 +343,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { /////////////////////////////////////////////////////////////////////////// // Resolution reason. +#[deriving(Copy)] enum ResolveReason { ResolvingExpr(Span), ResolvingLocal(Span), @@ -351,8 +352,6 @@ enum ResolveReason { ResolvingUnboxedClosure(ast::DefId), } -impl Copy for ResolveReason {} - impl ResolveReason { fn span(&self, tcx: &ty::ctxt) -> Span { match *self { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 280b42f0959..4612acb04b2 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -490,6 +490,7 @@ fn convert_associated_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, } } +#[deriving(Copy)] enum ConvertMethodContext<'a> { /// Used when converting implementation methods. ImplConvertMethodContext, @@ -498,8 +499,6 @@ enum ConvertMethodContext<'a> { TraitConvertMethodContext(ast::DefId, &'a [ast::TraitItem]), } -impl<'a> Copy for ConvertMethodContext<'a> {} - fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>, convert_method_context: ConvertMethodContext, container: ImplOrTraitItemContainer, diff --git a/src/librustc_typeck/rscope.rs b/src/librustc_typeck/rscope.rs index 39c7a87837c..f43e8579022 100644 --- a/src/librustc_typeck/rscope.rs +++ b/src/librustc_typeck/rscope.rs @@ -36,10 +36,9 @@ pub trait RegionScope { // A scope in which all regions must be explicitly named. This is used // for types that appear in structs and so on. +#[deriving(Copy)] pub struct ExplicitRscope; -impl Copy for ExplicitRscope {} - impl RegionScope for ExplicitRscope { fn default_region_bound(&self, _span: Span) -> Option<ty::Region> { None diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index 67478e0bfa7..ef0d1bc3859 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -229,19 +229,16 @@ pub fn infer_variance(tcx: &ty::ctxt) { type VarianceTermPtr<'a> = &'a VarianceTerm<'a>; -#[deriving(Show)] +#[deriving(Copy, Show)] struct InferredIndex(uint); -impl Copy for InferredIndex {} - +#[deriving(Copy)] enum VarianceTerm<'a> { ConstantTerm(ty::Variance), TransformTerm(VarianceTermPtr<'a>, VarianceTermPtr<'a>), InferredTerm(InferredIndex), } -impl<'a> Copy for VarianceTerm<'a> {} - impl<'a> fmt::Show for VarianceTerm<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { @@ -268,14 +265,12 @@ struct TermsContext<'a, 'tcx: 'a> { inferred_infos: Vec<InferredInfo<'a>> , } -#[deriving(Show, PartialEq)] +#[deriving(Copy, Show, PartialEq)] enum ParamKind { TypeParam, RegionParam } -impl Copy for ParamKind {} - struct InferredInfo<'a> { item_id: ast::NodeId, kind: ParamKind, @@ -427,13 +422,12 @@ struct ConstraintContext<'a, 'tcx: 'a> { /// Declares that the variable `decl_id` appears in a location with /// variance `variance`. +#[deriving(Copy)] struct Constraint<'a> { inferred: InferredIndex, variance: &'a VarianceTerm<'a>, } -impl<'a> Copy for Constraint<'a> {} - fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>, krate: &ast::Crate) -> ConstraintContext<'a, 'tcx> { |
