librustc_typeck: use #[deriving(Copy)]

This commit is contained in:
Jorge Aparicio 2014-12-14 23:16:06 -05:00
parent 5e2bca9e86
commit fa0383f38d
6 changed files with 11 additions and 27 deletions

View file

@ -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.

View file

@ -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.
///

View file

@ -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 {

View file

@ -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,

View file

@ -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

View file

@ -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> {