From e64a0072d66f0071f47325711a226f34d7b76f05 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 14 Dec 2014 23:03:34 -0500 Subject: [PATCH] librustc: use `#[deriving(Copy)]` --- src/librustc/lint/builtin.rs | 63 +++---- src/librustc/lint/mod.rs | 15 +- src/librustc/metadata/common.rs | 3 +- src/librustc/metadata/csearch.rs | 3 +- src/librustc/metadata/cstore.rs | 8 +- src/librustc/metadata/decoder.rs | 4 +- src/librustc/metadata/filesearch.rs | 3 +- src/librustc/metadata/tydecode.rs | 3 +- src/librustc/middle/cfg/construct.rs | 3 +- src/librustc/middle/cfg/mod.rs | 3 +- src/librustc/middle/check_loop.rs | 7 +- src/librustc/middle/check_match.rs | 3 +- src/librustc/middle/check_static.rs | 4 +- src/librustc/middle/const_eval.rs | 3 +- src/librustc/middle/dataflow.rs | 4 +- src/librustc/middle/def.rs | 12 +- src/librustc/middle/effect.rs | 4 +- src/librustc/middle/expr_use_visitor.rs | 23 +-- src/librustc/middle/fast_reject.rs | 4 +- src/librustc/middle/graph.rs | 12 +- src/librustc/middle/infer/mod.rs | 12 +- .../middle/infer/region_inference/mod.rs | 23 +-- src/librustc/middle/infer/type_variable.rs | 4 +- src/librustc/middle/infer/unify.rs | 3 +- src/librustc/middle/lang_items.rs | 4 +- src/librustc/middle/liveness.rs | 27 +-- src/librustc/middle/mem_categorization.rs | 37 +--- src/librustc/middle/region.rs | 7 +- src/librustc/middle/resolve.rs | 70 ++----- src/librustc/middle/resolve_lifetime.rs | 4 +- src/librustc/middle/subst.rs | 4 +- src/librustc/middle/traits/select.rs | 4 +- src/librustc/middle/ty.rs | 174 +++++------------- src/librustc/session/config.rs | 20 +- src/librustc/util/common.rs | 4 +- src/librustc/util/nodemap.rs | 4 +- 36 files changed, 159 insertions(+), 426 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index f6fd9f60e5c3f..88b12aa5660c9 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -56,10 +56,9 @@ declare_lint! { "suggest using `loop { }` instead of `while true { }`" } +#[deriving(Copy)] pub struct WhileTrue; -impl Copy for WhileTrue {} - impl LintPass for WhileTrue { fn get_lints(&self) -> LintArray { lint_array!(WHILE_TRUE) @@ -83,10 +82,9 @@ declare_lint! { "detects unnecessary type casts that can be removed" } +#[deriving(Copy)] pub struct UnusedCasts; -impl Copy for UnusedCasts {} - impl LintPass for UnusedCasts { fn get_lints(&self) -> LintArray { lint_array!(UNUSED_TYPECASTS) @@ -126,13 +124,12 @@ declare_lint! { "shift exceeds the type's number of bits" } +#[deriving(Copy)] pub struct TypeLimits { /// Id of the last visited negated expression negated_expr_id: ast::NodeId, } -impl Copy for TypeLimits {} - impl TypeLimits { pub fn new() -> TypeLimits { TypeLimits { @@ -442,10 +439,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> { } } +#[deriving(Copy)] pub struct ImproperCTypes; -impl Copy for ImproperCTypes {} - impl LintPass for ImproperCTypes { fn get_lints(&self) -> LintArray { lint_array!(IMPROPER_CTYPES) @@ -486,10 +482,9 @@ declare_lint! { "use of owned (Box type) heap memory" } +#[deriving(Copy)] pub struct BoxPointers; -impl Copy for BoxPointers {} - impl BoxPointers { fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>, span: Span, ty: Ty<'tcx>) { @@ -627,10 +622,9 @@ declare_lint! { "detects attributes that were not used by the compiler" } +#[deriving(Copy)] pub struct UnusedAttributes; -impl Copy for UnusedAttributes {} - impl LintPass for UnusedAttributes { fn get_lints(&self) -> LintArray { lint_array!(UNUSED_ATTRIBUTES) @@ -711,10 +705,9 @@ declare_lint! { "path statements with no effect" } +#[deriving(Copy)] pub struct PathStatements; -impl Copy for PathStatements {} - impl LintPass for PathStatements { fn get_lints(&self) -> LintArray { lint_array!(PATH_STATEMENTS) @@ -746,10 +739,9 @@ declare_lint! { "unused result of an expression in a statement" } +#[deriving(Copy)] pub struct UnusedResults; -impl Copy for UnusedResults {} - impl LintPass for UnusedResults { fn get_lints(&self) -> LintArray { lint_array!(UNUSED_MUST_USE, UNUSED_RESULTS) @@ -815,10 +807,9 @@ declare_lint! { "types, variants, traits and type parameters should have camel case names" } +#[deriving(Copy)] pub struct NonCamelCaseTypes; -impl Copy for NonCamelCaseTypes {} - impl NonCamelCaseTypes { fn check_case(&self, cx: &Context, sort: &str, ident: ast::Ident, span: Span) { fn is_camel_case(ident: ast::Ident) -> bool { @@ -939,10 +930,9 @@ declare_lint! { "methods, functions, lifetime parameters and modules should have snake case names" } +#[deriving(Copy)] pub struct NonSnakeCase; -impl Copy for NonSnakeCase {} - impl NonSnakeCase { fn check_snake_case(&self, cx: &Context, sort: &str, ident: ast::Ident, span: Span) { fn is_snake_case(ident: ast::Ident) -> bool { @@ -1053,10 +1043,9 @@ declare_lint! { "static constants should have uppercase identifiers" } +#[deriving(Copy)] pub struct NonUpperCaseGlobals; -impl Copy for NonUpperCaseGlobals {} - impl LintPass for NonUpperCaseGlobals { fn get_lints(&self) -> LintArray { lint_array!(NON_UPPER_CASE_GLOBALS) @@ -1107,10 +1096,9 @@ declare_lint! { "`if`, `match`, `while` and `return` do not need parentheses" } +#[deriving(Copy)] pub struct UnusedParens; -impl Copy for UnusedParens {} - impl UnusedParens { fn check_unused_parens_core(&self, cx: &Context, value: &ast::Expr, msg: &str, struct_lit_needs_parens: bool) { @@ -1202,10 +1190,9 @@ declare_lint! { "unnecessary braces around an imported item" } +#[deriving(Copy)] pub struct UnusedImportBraces; -impl Copy for UnusedImportBraces {} - impl LintPass for UnusedImportBraces { fn get_lints(&self) -> LintArray { lint_array!(UNUSED_IMPORT_BRACES) @@ -1242,10 +1229,9 @@ declare_lint! { "using `Struct { x: x }` instead of `Struct { x }`" } +#[deriving(Copy)] pub struct NonShorthandFieldPatterns; -impl Copy for NonShorthandFieldPatterns {} - impl LintPass for NonShorthandFieldPatterns { fn get_lints(&self) -> LintArray { lint_array!(NON_SHORTHAND_FIELD_PATTERNS) @@ -1276,10 +1262,9 @@ declare_lint! { "unnecessary use of an `unsafe` block" } +#[deriving(Copy)] pub struct UnusedUnsafe; -impl Copy for UnusedUnsafe {} - impl LintPass for UnusedUnsafe { fn get_lints(&self) -> LintArray { lint_array!(UNUSED_UNSAFE) @@ -1302,10 +1287,9 @@ declare_lint! { "usage of an `unsafe` block" } +#[deriving(Copy)] pub struct UnsafeBlocks; -impl Copy for UnsafeBlocks {} - impl LintPass for UnsafeBlocks { fn get_lints(&self) -> LintArray { lint_array!(UNSAFE_BLOCKS) @@ -1327,10 +1311,9 @@ declare_lint! { "detect mut variables which don't need to be mutable" } +#[deriving(Copy)] pub struct UnusedMut; -impl Copy for UnusedMut {} - impl UnusedMut { fn check_unused_mut_pat(&self, cx: &Context, pats: &[P]) { // collect all mutable pattern and group their NodeIDs by their Identifier to @@ -1397,10 +1380,9 @@ declare_lint! { "detects unnecessary allocations that can be eliminated" } +#[deriving(Copy)] pub struct UnusedAllocation; -impl Copy for UnusedAllocation {} - impl LintPass for UnusedAllocation { fn get_lints(&self) -> LintArray { lint_array!(UNUSED_ALLOCATION) @@ -1589,10 +1571,9 @@ impl LintPass for MissingDoc { } } +#[deriving(Copy)] pub struct MissingCopyImplementations; -impl Copy for MissingCopyImplementations {} - impl LintPass for MissingCopyImplementations { fn get_lints(&self) -> LintArray { lint_array!(MISSING_COPY_IMPLEMENTATIONS) @@ -1665,10 +1646,9 @@ declare_lint! { /// Checks for use of items with `#[deprecated]`, `#[experimental]` and /// `#[unstable]` attributes, or no stability attribute. +#[deriving(Copy)] pub struct Stability; -impl Copy for Stability {} - impl Stability { fn lint(&self, cx: &Context, id: ast::DefId, span: Span) { let stability = stability::lookup(cx.tcx, id); @@ -1903,10 +1883,9 @@ declare_lint!{ /// Does nothing as a lint pass, but registers some `Lint`s /// which are used by other parts of the compiler. +#[deriving(Copy)] pub struct HardwiredLints; -impl Copy for HardwiredLints {} - impl LintPass for HardwiredLints { fn get_lints(&self) -> LintArray { lint_array!( diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 79d57305f9642..009a1d444dc13 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -42,6 +42,7 @@ use syntax::ast; pub use lint::context::{Context, LintStore, raw_emit_lint, check_crate, gather_attrs}; /// Specification of a single lint. +#[deriving(Copy)] pub struct Lint { /// A string identifier for the lint. /// @@ -64,8 +65,6 @@ pub struct Lint { pub desc: &'static str, } -impl Copy for Lint {} - impl Lint { /// Get the lint's name, with ASCII letters converted to lowercase. pub fn name_lower(&self) -> String { @@ -175,14 +174,12 @@ pub trait LintPass { pub type LintPassObject = Box; /// Identifies a lint known to the compiler. -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub struct LintId { // Identity is based on pointer equality of this field. lint: &'static Lint, } -impl Copy for LintId {} - impl PartialEq for LintId { fn eq(&self, other: &LintId) -> bool { (self.lint as *const Lint) == (other.lint as *const Lint) @@ -213,13 +210,11 @@ impl LintId { } /// Setting for how to handle a lint. -#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord)] pub enum Level { Allow, Warn, Deny, Forbid } -impl Copy for Level {} - impl Level { /// Convert a level to a lower-case string. pub fn as_str(self) -> &'static str { @@ -244,7 +239,7 @@ impl Level { } /// How a lint level was set. -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Clone, Copy, PartialEq, Eq)] pub enum LintSource { /// Lint is at the default level as declared /// in rustc or a plugin. @@ -257,8 +252,6 @@ pub enum LintSource { CommandLine, } -impl Copy for LintSource {} - pub type LevelSource = (Level, LintSource); pub mod builtin; diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index b698e4fcc7f7b..03e436e98df46 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -113,7 +113,7 @@ pub const tag_items_data_item_reexport_def_id: uint = 0x39; pub const tag_items_data_item_reexport_name: uint = 0x3a; // used to encode crate_ctxt side tables -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[repr(uint)] pub enum astencode_tag { // Reserves 0x40 -- 0x5f tag_ast = 0x40, @@ -145,7 +145,6 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f tag_table_object_cast_map = 0x57, } -impl Copy for astencode_tag {} static first_astencode_tag: uint = tag_ast as uint; static last_astencode_tag: uint = tag_table_object_cast_map as uint; impl astencode_tag { diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 4cbb1babf9a2c..a474af7c6e1ff 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -33,14 +33,13 @@ use syntax::parse::token; use std::collections::hash_map::HashMap; +#[deriving(Copy)] pub struct MethodInfo { pub name: ast::Name, pub def_id: ast::DefId, pub vis: ast::Visibility, } -impl Copy for MethodInfo {} - pub fn get_symbol(cstore: &cstore::CStore, def: ast::DefId) -> String { let cdata = cstore.get_crate_data(def.krate); decoder::get_symbol(cdata.data(), def.node) diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index cede093fae696..d5247472c3447 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -48,23 +48,19 @@ pub struct crate_metadata { pub span: Span, } -#[deriving(Show, PartialEq, Clone)] +#[deriving(Copy, Show, PartialEq, Clone)] pub enum LinkagePreference { RequireDynamic, RequireStatic, } -impl Copy for LinkagePreference {} - -#[deriving(Clone, PartialEq, FromPrimitive)] +#[deriving(Copy, Clone, PartialEq, FromPrimitive)] pub enum NativeLibraryKind { NativeStatic, // native static library (.a archive) NativeFramework, // OSX-specific NativeUnknown, // default way to specify a dynamic library } -impl Copy for NativeLibraryKind {} - // Where a crate came from on the local filesystem. One of these two options // must be non-None. #[deriving(PartialEq, Clone)] diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 7f1df80da3c8f..b89c5dbcd0885 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -450,15 +450,13 @@ pub fn get_symbol(data: &[u8], id: ast::NodeId) -> String { } // Something that a name can resolve to. -#[deriving(Clone,Show)] +#[deriving(Copy, Clone, Show)] pub enum DefLike { DlDef(def::Def), DlImpl(ast::DefId), DlField } -impl Copy for DefLike {} - /// Iterates over the language items in the given crate. pub fn each_lang_item(cdata: Cmd, mut f: F) -> bool where F: FnMut(ast::NodeId, uint) -> bool, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 507fb751303f9..0b859abc531c8 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -20,13 +20,12 @@ use std::os; use util::fs as myfs; +#[deriving(Copy)] pub enum FileMatch { FileMatches, FileDoesntMatch, } -impl Copy for FileMatch {} - // A module for searching for libraries // FIXME (#2658): I'm not happy how this module turned out. Should // probably just be folded into cstore. diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index f2a41c48d1203..9d3a2c1d66777 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -44,7 +44,7 @@ use syntax::parse::token; // def-id will depend on where it originated from. Therefore, the conversion // function is given an indicator of the source of the def-id. See // astencode.rs for more information. -#[deriving(Show)] +#[deriving(Copy, Show)] pub enum DefIdSource { // Identifies a struct, trait, enum, etc. NominalType, @@ -62,7 +62,6 @@ pub enum DefIdSource { UnboxedClosureSource } -impl Copy for DefIdSource {} pub type conv_did<'a> = |source: DefIdSource, ast::DefId|: 'a -> ast::DefId; diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index 0e10155beb470..82bed2540317f 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -26,14 +26,13 @@ struct CFGBuilder<'a, 'tcx: 'a> { loop_scopes: Vec, } +#[deriving(Copy)] struct LoopScope { loop_id: ast::NodeId, // id of loop/while node continue_index: CFGIndex, // where to go on a `loop` break_index: CFGIndex, // where to go on a `break } -impl Copy for LoopScope {} - pub fn construct(tcx: &ty::ctxt, blk: &ast::Block) -> CFG { let mut graph = graph::Graph::new(); diff --git a/src/librustc/middle/cfg/mod.rs b/src/librustc/middle/cfg/mod.rs index bc512a73a4bd8..a74fff5630bfd 100644 --- a/src/librustc/middle/cfg/mod.rs +++ b/src/librustc/middle/cfg/mod.rs @@ -26,12 +26,11 @@ pub struct CFG { pub exit: CFGIndex, } +#[deriving(Copy)] pub struct CFGNodeData { pub id: ast::NodeId } -impl Copy for CFGNodeData {} - pub struct CFGEdgeData { pub exiting_scopes: Vec } diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index c4ad089d76e6e..cb454f94dc74c 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -16,20 +16,17 @@ use syntax::codemap::Span; use syntax::visit::Visitor; use syntax::visit; -#[deriving(Clone, PartialEq)] +#[deriving(Clone, Copy, PartialEq)] enum Context { Normal, Loop, Closure } -impl Copy for Context {} - +#[deriving(Copy)] struct CheckLoopVisitor<'a> { sess: &'a Session, cx: Context } -impl<'a> Copy for CheckLoopVisitor<'a> {} - pub fn check_crate(sess: &Session, krate: &ast::Crate) { visit::walk_crate(&mut CheckLoopVisitor { sess: sess, cx: Normal }, krate) } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 034bf3e840a89..79e776c330884 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -127,13 +127,12 @@ enum Usefulness { NotUseful } +#[deriving(Copy)] enum WitnessPreference { ConstructWitness, LeaveOutWitness } -impl Copy for WitnessPreference {} - impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> { fn visit_expr(&mut self, ex: &ast::Expr) { check_expr(self, ex); diff --git a/src/librustc/middle/check_static.rs b/src/librustc/middle/check_static.rs index af2be6e088dd5..21e94d69366d6 100644 --- a/src/librustc/middle/check_static.rs +++ b/src/librustc/middle/check_static.rs @@ -39,7 +39,7 @@ use syntax::visit::Visitor; use syntax::codemap::Span; use syntax::visit; -#[deriving(Eq, PartialEq)] +#[deriving(Copy, Eq, PartialEq)] enum Mode { InConstant, InStatic, @@ -47,8 +47,6 @@ enum Mode { InNothing, } -impl Copy for Mode {} - struct CheckStaticVisitor<'a, 'tcx: 'a> { tcx: &'a ty::ctxt<'tcx>, mode: Mode, diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index f0d52d1ac23d0..9b94335654734 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -62,14 +62,13 @@ use std::collections::hash_map::Vacant; // - Non-constants: everything else. // +#[deriving(Copy)] pub enum constness { integral_const, general_const, non_const } -impl Copy for constness {} - type constness_cache = DefIdMap; pub fn join(a: constness, b: constness) -> constness { diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 9373a5704b2b0..17ebd1b94a708 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -27,14 +27,12 @@ use syntax::visit; use syntax::print::{pp, pprust}; use util::nodemap::NodeMap; -#[deriving(Show)] +#[deriving(Copy, Show)] pub enum EntryOrExit { Entry, Exit, } -impl Copy for EntryOrExit {} - #[deriving(Clone)] pub struct DataFlowContext<'a, 'tcx: 'a, O> { tcx: &'a ty::ctxt<'tcx>, diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index 8573dc747bb07..20a0dbdc1eefa 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/middle/def.rs @@ -15,7 +15,7 @@ use middle::subst::ParamSpace; use syntax::ast; use syntax::ast_util::local_def; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Def { DefFn(ast::DefId, bool /* is_ctor */), DefStaticMethod(/* method */ ast::DefId, MethodProvenance), @@ -56,15 +56,13 @@ pub enum Def { DefMethod(ast::DefId /* method */, Option /* trait */, MethodProvenance), } -impl Copy for Def {} - -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum MethodProvenance { FromTrait(ast::DefId), FromImpl(ast::DefId), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum TyParamProvenance { FromSelf(ast::DefId), FromParam(ast::DefId), @@ -81,8 +79,6 @@ impl MethodProvenance { } } -impl Copy for MethodProvenance {} - impl TyParamProvenance { pub fn def_id(&self) -> ast::DefId { match *self { @@ -92,8 +88,6 @@ impl TyParamProvenance { } } -impl Copy for TyParamProvenance {} - impl Def { pub fn def_id(&self) -> ast::DefId { match *self { diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index d16ce3ad678b3..0c0cba6e53e06 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -23,15 +23,13 @@ use syntax::codemap::Span; use syntax::visit; use syntax::visit::Visitor; -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] enum UnsafeContext { SafeContext, UnsafeFn, UnsafeBlock(ast::NodeId), } -impl Copy for UnsafeContext {} - fn type_is_unsafe_function(ty: Ty) -> bool { match ty.sty { ty::ty_bare_fn(ref f) => f.unsafety == ast::Unsafety::Unsafe, diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 901944cd0168e..abc3c8d0d8fa4 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -95,7 +95,7 @@ pub trait Delegate<'tcx> { mode: MutateMode); } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] pub enum LoanCause { ClosureCapture(Span), AddrOf, @@ -107,26 +107,20 @@ pub enum LoanCause { MatchDiscriminant } -impl kinds::Copy for LoanCause {} - -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] pub enum ConsumeMode { Copy, // reference to x where x has a type that copies Move(MoveReason), // reference to x where x has a type that moves } -impl kinds::Copy for ConsumeMode {} - -#[deriving(PartialEq,Show)] +#[deriving(Copy, PartialEq, Show)] pub enum MoveReason { DirectRefMove, PatBindingMove, CaptureMove, } -impl kinds::Copy for MoveReason {} - -#[deriving(PartialEq,Show)] +#[deriving(Copy, PartialEq, Show)] pub enum MatchMode { NonBindingMatch, BorrowingMatch, @@ -134,8 +128,6 @@ pub enum MatchMode { MovingMatch, } -impl kinds::Copy for MatchMode {} - #[deriving(PartialEq,Show)] enum TrackMatchMode { Unknown, @@ -205,23 +197,20 @@ impl TrackMatchMode { } } -#[deriving(PartialEq,Show)] +#[deriving(Copy, PartialEq, Show)] pub enum MutateMode { Init, JustWrite, // x = y WriteAndRead, // x += y } -impl kinds::Copy for MutateMode {} - +#[deriving(Copy)] enum OverloadedCallType { FnOverloadedCall, FnMutOverloadedCall, FnOnceOverloadedCall, } -impl kinds::Copy for OverloadedCallType {} - impl OverloadedCallType { fn from_trait_id(tcx: &ty::ctxt, trait_id: ast::DefId) -> OverloadedCallType { diff --git a/src/librustc/middle/fast_reject.rs b/src/librustc/middle/fast_reject.rs index 5c0d4b4841ee3..297d6bcb03cb9 100644 --- a/src/librustc/middle/fast_reject.rs +++ b/src/librustc/middle/fast_reject.rs @@ -14,7 +14,7 @@ use syntax::ast; use self::SimplifiedType::*; /// See `simplify_type -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash)] pub enum SimplifiedType { BoolSimplifiedType, CharSimplifiedType, @@ -33,8 +33,6 @@ pub enum SimplifiedType { ParameterSimplifiedType, } -impl Copy for SimplifiedType {} - /// Tries to simplify a type by dropping type parameters, deref'ing away any reference types, etc. /// The idea is to get something simple that we can use to quickly decide if two types could unify /// during method lookup. diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 4c03ed2a480ef..e73fcd93e0504 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -60,30 +60,24 @@ impl Show for Edge { } } -#[deriving(Clone, PartialEq, Show)] +#[deriving(Clone, Copy, PartialEq, Show)] pub struct NodeIndex(pub uint); #[allow(non_upper_case_globals)] pub const InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX); -impl Copy for NodeIndex {} - -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] pub struct EdgeIndex(pub uint); #[allow(non_upper_case_globals)] pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX); -impl Copy for EdgeIndex {} - // Use a private field here to guarantee no more instances are created: -#[deriving(Show)] +#[deriving(Copy, Show)] pub struct Direction { repr: uint } #[allow(non_upper_case_globals)] pub const Outgoing: Direction = Direction { repr: 0 }; #[allow(non_upper_case_globals)] pub const Incoming: Direction = Direction { repr: 1 }; -impl Copy for Direction {} - impl NodeIndex { fn get(&self) -> uint { let NodeIndex(v) = *self; v } /// Returns unique id (unique with respect to the graph holding associated node). diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index f419f050cf594..25eadae5b92f1 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -97,7 +97,7 @@ pub type SkolemizationMap = FnvHashMap; /// Why did we require that the two types be related? /// /// See `error_reporting.rs` for more details -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] pub enum TypeOrigin { // Not yet categorized in a better way Misc(Span), @@ -131,8 +131,6 @@ pub enum TypeOrigin { EquatePredicate(Span), } -impl Copy for TypeOrigin {} - /// See `error_reporting.rs` for more details #[deriving(Clone, Show)] pub enum ValuePairs<'tcx> { @@ -223,7 +221,7 @@ pub enum SubregionOrigin<'tcx> { } /// Times when we replace late-bound regions with variables: -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] pub enum LateBoundRegionConversionTime { /// when a fn is called FnCall, @@ -232,8 +230,6 @@ pub enum LateBoundRegionConversionTime { HigherRankedType, } -impl Copy for LateBoundRegionConversionTime {} - /// Reasons to create a region inference variable /// /// See `error_reporting.rs` for more details @@ -270,15 +266,13 @@ pub enum RegionVariableOrigin<'tcx> { BoundRegionInCoherence(ast::Name), } -#[deriving(Show)] +#[deriving(Copy, Show)] pub enum fixup_err { unresolved_int_ty(IntVid), unresolved_float_ty(FloatVid), unresolved_ty(TyVid) } -impl Copy for fixup_err {} - pub fn fixup_err_to_string(f: fixup_err) -> String { match f { unresolved_int_ty(_) => { diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index d34373e66a1e0..bcaf39cc8dbd1 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -40,7 +40,7 @@ mod doc; mod graphviz; // A constraint that influences the inference process. -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub enum Constraint { // One region variable is subregion of another ConstrainVarSubVar(RegionVid, RegionVid), @@ -52,8 +52,6 @@ pub enum Constraint { ConstrainVarSubReg(RegionVid, Region), } -impl Copy for Constraint {} - // Something we have to verify after region inference is done, but // which does not directly influence the inference process pub enum Verify<'tcx> { @@ -69,15 +67,13 @@ pub enum Verify<'tcx> { VerifyParamBound(ty::ParamTy, SubregionOrigin<'tcx>, Region, Vec), } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(Copy, PartialEq, Eq, Hash)] pub struct TwoRegions { a: Region, b: Region, } -impl Copy for TwoRegions {} - -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] pub enum UndoLogEntry { OpenSnapshot, CommitedSnapshot, @@ -88,15 +84,11 @@ pub enum UndoLogEntry { AddCombination(CombineMapType, TwoRegions) } -impl Copy for UndoLogEntry {} - -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] pub enum CombineMapType { Lub, Glb } -impl Copy for CombineMapType {} - #[deriving(Clone, Show)] pub enum RegionResolutionError<'tcx> { /// `ConcreteFailure(o, a, b)`: @@ -940,15 +932,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // ______________________________________________________________________ -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] enum Classification { Expanding, Contracting } -impl Copy for Classification {} - +#[deriving(Copy)] pub enum VarValue { NoValue, Value(Region), ErrorValue } -impl Copy for VarValue {} - struct VarData { classification: Classification, value: VarValue, diff --git a/src/librustc/middle/infer/type_variable.rs b/src/librustc/middle/infer/type_variable.rs index 0d7f542535c2f..5e857154871ea 100644 --- a/src/librustc/middle/infer/type_variable.rs +++ b/src/librustc/middle/infer/type_variable.rs @@ -46,13 +46,11 @@ struct Delegate; type Relation = (RelationDir, ty::TyVid); -#[deriving(PartialEq,Show)] +#[deriving(Copy, PartialEq, Show)] pub enum RelationDir { SubtypeOf, SupertypeOf, EqTo } -impl Copy for RelationDir {} - impl RelationDir { fn opposite(self) -> RelationDir { match self { diff --git a/src/librustc/middle/infer/unify.rs b/src/librustc/middle/infer/unify.rs index a2dd4d6291352..0b81823e9ed1a 100644 --- a/src/librustc/middle/infer/unify.rs +++ b/src/librustc/middle/infer/unify.rs @@ -90,10 +90,9 @@ pub struct Node { pub rank: uint, } +#[deriving(Copy)] pub struct Delegate; -impl Copy for Delegate {} - // We can't use V:LatticeValue, much as I would like to, // because frequently the pattern is that V=Option for some // other type parameter U, and we have no way to say diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 8d5528b3709ad..2ffc5d8a510a3 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -45,13 +45,11 @@ macro_rules! lets_do_this { $( $variant:ident, $name:expr, $method:ident; )* ) => { -#[deriving(FromPrimitive, PartialEq, Eq, Hash)] +#[deriving(Copy, FromPrimitive, PartialEq, Eq, Hash)] pub enum LangItem { $($variant),* } -impl Copy for LangItem {} - pub struct LanguageItems { pub items: Vec>, pub missing: Vec, diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 4df655882b155..b76d798941ef9 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -135,16 +135,12 @@ enum LoopKind<'a> { ForLoop(&'a ast::Pat), } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] struct Variable(uint); -impl Copy for Variable {} - -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] struct LiveNode(uint); -impl Copy for LiveNode {} - impl Variable { fn get(&self) -> uint { let Variable(v) = *self; v } } @@ -159,7 +155,7 @@ impl Clone for LiveNode { } } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] enum LiveNodeKind { FreeVarNode(Span), ExprNode(Span), @@ -167,8 +163,6 @@ enum LiveNodeKind { ExitNode } -impl Copy for LiveNodeKind {} - fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &ty::ctxt) -> String { let cm = cx.sess.codemap(); match lnk { @@ -247,15 +241,13 @@ struct CaptureInfo { var_nid: NodeId } -#[deriving(Show)] +#[deriving(Copy, Show)] struct LocalInfo { id: NodeId, ident: ast::Ident } -impl Copy for LocalInfo {} - -#[deriving(Show)] +#[deriving(Copy, Show)] enum VarKind { Arg(NodeId, ast::Ident), Local(LocalInfo), @@ -263,8 +255,6 @@ enum VarKind { CleanExit } -impl Copy for VarKind {} - struct IrMaps<'a, 'tcx: 'a> { tcx: &'a ty::ctxt<'tcx>, @@ -536,15 +526,13 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) { // Actually we compute just a bit more than just liveness, but we use // the same basic propagation framework in all cases. -#[deriving(Clone)] +#[deriving(Clone, Copy)] struct Users { reader: LiveNode, writer: LiveNode, used: bool } -impl Copy for Users {} - fn invalid_users() -> Users { Users { reader: invalid_node(), @@ -553,6 +541,7 @@ fn invalid_users() -> Users { } } +#[deriving(Copy)] struct Specials { exit_ln: LiveNode, fallthrough_ln: LiveNode, @@ -560,8 +549,6 @@ struct Specials { clean_exit_var: Variable } -impl Copy for Specials {} - static ACC_READ: uint = 1u; static ACC_WRITE: uint = 2u; static ACC_USE: uint = 4u; diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 0e05eb4dcdd9a..dce75579ca0a2 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -101,7 +101,7 @@ pub enum categorization<'tcx> { } // Represents any kind of upvar -#[deriving(Clone, PartialEq, Show)] +#[deriving(Clone, Copy, PartialEq, Show)] pub struct Upvar { pub id: ty::UpvarId, // Unboxed closure kinds are used even for old-style closures for simplicity @@ -110,10 +110,8 @@ pub struct Upvar { pub is_unboxed: bool } -impl Copy for Upvar {} - // different kinds of pointers: -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub enum PointerKind { OwnedPtr, BorrowedPtr(ty::BorrowKind, ty::Region), @@ -121,57 +119,45 @@ pub enum PointerKind { UnsafePtr(ast::Mutability) } -impl Copy for PointerKind {} - // We use the term "interior" to mean "something reachable from the // base without a pointer dereference", e.g. a field -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub enum InteriorKind { InteriorField(FieldName), InteriorElement(ElementKind), } -impl Copy for InteriorKind {} - -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub enum FieldName { NamedField(ast::Name), PositionalField(uint) } -impl Copy for FieldName {} - -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub enum ElementKind { VecElement, OtherElement, } -impl Copy for ElementKind {} - -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub enum MutabilityCategory { McImmutable, // Immutable. McDeclared, // Directly declared as mutable. McInherited, // Inherited from the fact that owner is mutable. } -impl Copy for MutabilityCategory {} - // A note about the provenance of a `cmt`. This is used for // special-case handling of upvars such as mutability inference. // Upvar categorization can generate a variable number of nested // derefs. The note allows detecting them without deep pattern // matching on the categorization. -#[deriving(Clone, PartialEq, Show)] +#[deriving(Clone, Copy, PartialEq, Show)] pub enum Note { NoteClosureEnv(ty::UpvarId), // Deref through closure env NoteUpvarRef(ty::UpvarId), // Deref through by-ref upvar NoteNone // Nothing special } -impl Copy for Note {} - // `cmt`: "Category, Mutability, and Type". // // a complete categorization of a value indicating where it originated @@ -200,13 +186,12 @@ pub type cmt<'tcx> = Rc>; // We pun on *T to mean both actual deref of a ptr as well // as accessing of components: +#[deriving(Copy)] pub enum deref_kind { deref_ptr(PointerKind), deref_interior(InteriorKind), } -impl Copy for deref_kind {} - // Categorizes a derefable type. Note that we include vectors and strings as // derefable (we model an index as the combination of a deref and then a // pointer adjustment). @@ -1394,13 +1379,13 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } } +#[deriving(Copy)] pub enum InteriorSafety { InteriorUnsafe, InteriorSafe } -impl Copy for InteriorSafety {} - +#[deriving(Copy)] pub enum AliasableReason { AliasableBorrowed, AliasableClosure(ast::NodeId), // Aliasable due to capture Fn closure env @@ -1409,8 +1394,6 @@ pub enum AliasableReason { AliasableStaticMut(InteriorSafety), } -impl Copy for AliasableReason {} - impl<'tcx> cmt_<'tcx> { pub fn guarantor(&self) -> cmt<'tcx> { //! Returns `self` after stripping away any owned pointer derefs or diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 390729df0125d..e0d5a3a50e612 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -36,13 +36,11 @@ use syntax::visit::{Visitor, FnKind}; /// placate the same deriving in `ty::FreeRegion`, but we may want to /// actually attach a more meaningful ordering to scopes than the one /// generated via deriving here. -#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] pub enum CodeExtent { Misc(ast::NodeId) } -impl Copy for CodeExtent {} - impl CodeExtent { /// Creates a scope that represents the dynamic extent associated /// with `node_id`. @@ -117,6 +115,7 @@ pub struct RegionMaps { terminating_scopes: RefCell>, } +#[deriving(Copy)] pub struct Context { var_parent: Option, @@ -124,8 +123,6 @@ pub struct Context { parent: Option, } -impl Copy for Context {} - struct RegionResolutionVisitor<'a> { sess: &'a Session, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 734453db693ec..e1e376c537cba 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -89,13 +89,12 @@ use std::uint; // Definition mapping pub type DefMap = RefCell>; +#[deriving(Copy)] struct binding_info { span: Span, binding_mode: BindingMode, } -impl Copy for binding_info {} - // Map from the name in a pattern to its binding mode. type BindingMap = HashMap; @@ -118,7 +117,7 @@ pub type ExternalExports = DefIdSet; // FIXME: dox pub type LastPrivateMap = NodeMap; -#[deriving(Show)] +#[deriving(Copy, Show)] pub enum LastPrivate { LastMod(PrivateDep), // `use` directives (imports) can refer to two separate definitions in the @@ -132,25 +131,19 @@ pub enum LastPrivate { type_used: ImportUse}, } -impl Copy for LastPrivate {} - -#[deriving(Show)] +#[deriving(Copy, Show)] pub enum PrivateDep { AllPublic, DependsOn(DefId), } -impl Copy for PrivateDep {} - // How an import is used. -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] pub enum ImportUse { Unused, // The import is not used. Used, // The import is used. } -impl Copy for ImportUse {} - impl LastPrivate { fn or(self, other: LastPrivate) -> LastPrivate { match (self, other) { @@ -160,24 +153,20 @@ impl LastPrivate { } } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] enum PatternBindingMode { RefutableMode, LocalIrrefutableMode, ArgumentIrrefutableMode, } -impl Copy for PatternBindingMode {} - -#[deriving(PartialEq, Eq, Hash, Show)] +#[deriving(Copy, PartialEq, Eq, Hash, Show)] enum Namespace { TypeNS, ValueNS } -impl Copy for Namespace {} - -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] enum NamespaceError { NoError, ModuleError, @@ -185,8 +174,6 @@ enum NamespaceError { ValueError } -impl Copy for NamespaceError {} - /// A NamespaceResult represents the result of resolving an import in /// a particular namespace. The result is either definitely-resolved, /// definitely- unresolved, or unknown. @@ -247,13 +234,12 @@ impl<'a, 'v> Visitor<'v> for Resolver<'a> { } /// Contains data for specific types of import directives. +#[deriving(Copy)] enum ImportDirectiveSubclass { SingleImport(Name /* target */, Name /* source */), GlobImport } -impl Copy for ImportDirectiveSubclass {} - /// The context that we thread through while building the reduced graph. #[deriving(Clone)] enum ReducedGraphParent { @@ -293,6 +279,7 @@ enum FallbackSuggestion { TraitMethod(String), } +#[deriving(Copy)] enum TypeParameters<'a> { NoTypeParameters, HasTypeParameters( @@ -310,11 +297,9 @@ enum TypeParameters<'a> { RibKind) } -impl<'a> Copy for TypeParameters<'a> {} - // The rib kind controls the translation of local // definitions (`DefLocal`) to upvars (`DefUpvar`). -#[deriving(Show)] +#[deriving(Copy, Show)] enum RibKind { // No translation needs to be applied. NormalRibKind, @@ -337,38 +322,31 @@ enum RibKind { ConstantItemRibKind } -impl Copy for RibKind {} - // Methods can be required or provided. RequiredMethod methods only occur in traits. -#[deriving(Show)] +#[deriving(Copy, Show)] enum MethodSort { RequiredMethod, ProvidedMethod(NodeId) } -impl Copy for MethodSort {} - +#[deriving(Copy)] enum UseLexicalScopeFlag { DontUseLexicalScope, UseLexicalScope } -impl Copy for UseLexicalScopeFlag {} - enum ModulePrefixResult { NoPrefixFound, PrefixFound(Rc, uint) } -#[deriving(Clone, Eq, PartialEq)] +#[deriving(Clone, Copy, Eq, PartialEq)] pub enum TraitItemKind { NonstaticMethodTraitItemKind, StaticMethodTraitItemKind, TypeTraitItemKind, } -impl Copy for TraitItemKind {} - impl TraitItemKind { pub fn from_explicit_self_category(explicit_self_category: ExplicitSelfCategory) @@ -381,7 +359,7 @@ impl TraitItemKind { } } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] enum NameSearchType { /// We're doing a name search in order to resolve a `use` directive. ImportSearch, @@ -391,19 +369,16 @@ enum NameSearchType { PathSearch, } -impl Copy for NameSearchType {} - +#[deriving(Copy)] enum BareIdentifierPatternResolution { FoundStructOrEnumVariant(Def, LastPrivate), FoundConst(Def, LastPrivate), BareIdentifierPatternUnresolved } -impl Copy for BareIdentifierPatternResolution {} - // Specifies how duplicates should be handled when adding a child item if // another item exists with the same name in some namespace. -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] enum DuplicateCheckingMode { ForbidDuplicateModules, ForbidDuplicateTypesAndModules, @@ -412,8 +387,6 @@ enum DuplicateCheckingMode { OverwriteDuplicates } -impl Copy for DuplicateCheckingMode {} - /// One local scope. #[deriving(Show)] struct Rib { @@ -543,7 +516,7 @@ enum ParentLink { } /// The type of module this is. -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] enum ModuleKind { NormalModuleKind, TraitModuleKind, @@ -552,8 +525,6 @@ enum ModuleKind { AnonymousModuleKind, } -impl Copy for ModuleKind {} - /// One node in the tree of modules. struct Module { parent_link: ParentLink, @@ -645,15 +616,13 @@ struct TypeNsDef { } // Records a possibly-private value definition. -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] struct ValueNsDef { modifiers: DefModifiers, // see note in ImportResolution about how to use this def: Def, value_span: Option, } -impl Copy for ValueNsDef {} - // Records the definitions (at most one for each namespace) that a name is // bound to. struct NameBindings { @@ -662,6 +631,7 @@ struct NameBindings { } /// Ways in which a trait can be referenced +#[deriving(Copy)] enum TraitReferenceType { TraitImplementation, // impl SomeTrait for T { ... } TraitDerivation, // trait T : SomeTrait { ... } @@ -670,8 +640,6 @@ enum TraitReferenceType { TraitQPath, // :: } -impl Copy for TraitReferenceType {} - impl NameBindings { fn new() -> NameBindings { NameBindings { diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 33701905aa110..2202137d14936 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -34,7 +34,7 @@ use syntax::visit; use syntax::visit::Visitor; use util::nodemap::NodeMap; -#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] pub enum DefRegion { DefStaticRegion, DefEarlyBoundRegion(/* space */ subst::ParamSpace, @@ -46,8 +46,6 @@ pub enum DefRegion { /* lifetime decl */ ast::NodeId), } -impl Copy for DefRegion {} - // maps the id of each lifetime reference to the lifetime decl // that it corresponds to pub type NamedRegionMap = NodeMap; diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 1cf25cd1dc866..30a47ff913258 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -187,7 +187,7 @@ impl RegionSubsts { /////////////////////////////////////////////////////////////////////////// // ParamSpace -#[deriving(PartialOrd, Ord, PartialEq, Eq, +#[deriving(Copy, PartialOrd, Ord, PartialEq, Eq, Clone, Hash, Encodable, Decodable, Show)] pub enum ParamSpace { TypeSpace, // Type parameters attached to a type definition, trait, or impl @@ -196,8 +196,6 @@ pub enum ParamSpace { FnSpace, // Type parameters attached to a method or fn } -impl Copy for ParamSpace {} - impl ParamSpace { pub fn all() -> [ParamSpace, ..4] { [TypeSpace, SelfSpace, AssocSpace, FnSpace] diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 6c7ae666ae06c..8ba28b61006bd 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -91,7 +91,7 @@ pub enum MethodMatchResult { MethodDidNotMatch, } -#[deriving(Show)] +#[deriving(Copy, Show)] pub enum MethodMatchedData { // In the case of a precise match, we don't really need to store // how the match was found. So don't. @@ -102,8 +102,6 @@ pub enum MethodMatchedData { CoerciveMethodMatch(/* impl we matched */ ast::DefId) } -impl Copy for MethodMatchedData {} - /// The selection process begins by considering all impls, where /// clauses, and so forth that might resolve an obligation. Sometimes /// we'll be able to say definitively that (e.g.) an impl does not diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 6839e8bcc45db..acf1fced72cae 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -107,22 +107,18 @@ pub struct CrateAnalysis<'tcx> { pub name: String, } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(Copy, PartialEq, Eq, Hash)] pub struct field<'tcx> { pub name: ast::Name, pub mt: mt<'tcx> } -impl<'tcx> Copy for field<'tcx> {} - -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] pub enum ImplOrTraitItemContainer { TraitContainer(ast::DefId), ImplContainer(ast::DefId), } -impl Copy for ImplOrTraitItemContainer {} - impl ImplOrTraitItemContainer { pub fn id(&self) -> ast::DefId { match *self { @@ -177,14 +173,12 @@ impl<'tcx> ImplOrTraitItem<'tcx> { } } -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub enum ImplOrTraitItemId { MethodTraitItemId(ast::DefId), TypeTraitItemId(ast::DefId), } -impl Copy for ImplOrTraitItemId {} - impl ImplOrTraitItemId { pub fn def_id(&self) -> ast::DefId { match *self { @@ -238,7 +232,7 @@ impl<'tcx> Method<'tcx> { } } -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub struct AssociatedType { pub name: ast::Name, pub vis: ast::Visibility, @@ -246,17 +240,13 @@ pub struct AssociatedType { pub container: ImplOrTraitItemContainer, } -impl Copy for AssociatedType {} - -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub struct mt<'tcx> { pub ty: Ty<'tcx>, pub mutbl: ast::Mutability, } -impl<'tcx> Copy for mt<'tcx> {} - -#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] pub enum TraitStore { /// Box UniqTraitStore, @@ -264,9 +254,7 @@ pub enum TraitStore { RegionTraitStore(Region, ast::Mutability), } -impl Copy for TraitStore {} - -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] pub struct field_ty { pub name: Name, pub id: DefId, @@ -274,33 +262,28 @@ pub struct field_ty { pub origin: ast::DefId, // The DefId of the struct in which the field is declared. } -impl Copy for field_ty {} - // Contains information needed to resolve types and (in the future) look up // the types of AST nodes. -#[deriving(PartialEq, Eq, Hash)] +#[deriving(Copy, PartialEq, Eq, Hash)] pub struct creader_cache_key { pub cnum: CrateNum, pub pos: uint, pub len: uint } -impl Copy for creader_cache_key {} - +#[deriving(Copy)] pub enum ast_ty_to_ty_cache_entry<'tcx> { atttce_unresolved, /* not resolved yet */ atttce_resolved(Ty<'tcx>) /* resolved to a type, irrespective of region */ } -impl<'tcx> Copy for ast_ty_to_ty_cache_entry<'tcx> {} - #[deriving(Clone, PartialEq, Decodable, Encodable)] pub struct ItemVariances { pub types: VecPerParamSpace, pub regions: VecPerParamSpace, } -#[deriving(Clone, PartialEq, Decodable, Encodable, Show)] +#[deriving(Clone, Copy, PartialEq, Decodable, Encodable, Show)] pub enum Variance { Covariant, // T <: T iff A <: B -- e.g., function return type Invariant, // T <: T iff B == A -- e.g., type of mutable cell @@ -308,8 +291,6 @@ pub enum Variance { Bivariant, // T <: T -- e.g., unused type parameter } -impl Copy for Variance {} - #[deriving(Clone, Show)] pub enum AutoAdjustment<'tcx> { AdjustAddEnv(ty::TraitStore), @@ -449,14 +430,12 @@ pub fn type_of_adjust<'tcx>(cx: &ctxt<'tcx>, adj: &AutoAdjustment<'tcx>) -> Opti } } -#[deriving(Clone, Encodable, Decodable, PartialEq, PartialOrd, Show)] +#[deriving(Clone, Copy, Encodable, Decodable, PartialEq, PartialOrd, Show)] pub struct param_index { pub space: subst::ParamSpace, pub index: uint } -impl Copy for param_index {} - #[deriving(Clone, Show)] pub enum MethodOrigin<'tcx> { // fully statically resolved method @@ -513,8 +492,6 @@ pub struct MethodCallee<'tcx> { pub substs: subst::Substs<'tcx> } -impl Copy for MethodCall {} - /// With method calls, we store some extra information in /// side tables (i.e method_map). We use /// MethodCall as a key to index into these tables instead of @@ -527,21 +504,19 @@ impl Copy for MethodCall {} /// needed to add to the side tables. Thus to disambiguate /// we also keep track of whether there's an adjustment in /// our key. -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub struct MethodCall { pub expr_id: ast::NodeId, pub adjustment: ExprAdjustment } -#[deriving(Clone, PartialEq, Eq, Hash, Show, Encodable, Decodable)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show, Encodable, Decodable)] pub enum ExprAdjustment { NoAdjustment, AutoDeref(uint), AutoObject } -impl Copy for ExprAdjustment {} - impl MethodCall { pub fn expr(id: ast::NodeId) -> MethodCall { MethodCall { @@ -615,6 +590,7 @@ pub type ObjectCastMap<'tcx> = RefCell>>>; /// A restriction that certain types must be the same size. The use of /// `transmute` gives rise to these restrictions. +#[deriving(Copy)] pub struct TransmuteRestriction<'tcx> { /// The span from whence the restriction comes. pub span: Span, @@ -626,8 +602,6 @@ pub struct TransmuteRestriction<'tcx> { pub id: ast::NodeId, } -impl<'tcx> Copy for TransmuteRestriction<'tcx> {} - /// The data structure to keep track of all the information that typechecker /// generates so that so that it can be reused and doesn't have to be redone /// later on. @@ -923,7 +897,7 @@ pub struct ClosureTy<'tcx> { pub abi: abi::Abi, } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash)] pub enum FnOutput<'tcx> { FnConverging(Ty<'tcx>), FnDiverging @@ -938,8 +912,6 @@ impl<'tcx> FnOutput<'tcx> { } } -impl<'tcx> Copy for FnOutput<'tcx> {} - /// Signature of a function type, which I have arbitrarily /// decided to use to refer to the input/output types. /// @@ -955,15 +927,13 @@ pub struct FnSig<'tcx> { pub type PolyFnSig<'tcx> = Binder>; -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub struct ParamTy { pub space: subst::ParamSpace, pub idx: uint, pub def_id: DefId } -impl Copy for ParamTy {} - /// A [De Bruijn index][dbi] is a standard means of representing /// regions (and perhaps later types) in a higher-ranked setting. In /// particular, imagine a type like this: @@ -1003,7 +973,7 @@ impl Copy for ParamTy {} /// is the outer fn. /// /// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index -#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] pub struct DebruijnIndex { // We maintain the invariant that this is never 0. So 1 indicates // the innermost binder. To ensure this, create with `DebruijnIndex::new`. @@ -1011,7 +981,7 @@ pub struct DebruijnIndex { } /// Representation of regions: -#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Show)] pub enum Region { // Region bound in a type or fn declaration which will be // substituted 'early' -- that is, at the same time when type @@ -1052,15 +1022,13 @@ pub enum Region { /// Upvars do not get their own node-id. Instead, we use the pair of /// the original var id (that is, the root variable that is referenced /// by the upvar) and the id of the closure expression. -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)] pub struct UpvarId { pub var_id: ast::NodeId, pub closure_expr_id: ast::NodeId, } -impl Copy for UpvarId {} - -#[deriving(Clone, PartialEq, Eq, Hash, Show, Encodable, Decodable)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show, Encodable, Decodable)] pub enum BorrowKind { /// Data must be immutable and is aliasable. ImmBorrow, @@ -1106,8 +1074,6 @@ pub enum BorrowKind { MutBorrow } -impl Copy for BorrowKind {} - /// Information describing the borrowing of an upvar. This is computed /// during `typeck`, specifically by `regionck`. The general idea is /// that the compiler analyses treat closures like: @@ -1155,7 +1121,7 @@ impl Copy for BorrowKind {} /// - Through mutation, the borrowed upvars can actually escape /// the closure, so sometimes it is necessary for them to be larger /// than the closure lifetime itself. -#[deriving(PartialEq, Clone, Encodable, Decodable, Show)] +#[deriving(Copy, PartialEq, Clone, Encodable, Decodable, Show)] pub struct UpvarBorrow { pub kind: BorrowKind, pub region: ty::Region, @@ -1163,8 +1129,6 @@ pub struct UpvarBorrow { pub type UpvarBorrowMap = FnvHashMap; -impl Copy for UpvarBorrow {} - impl Region { pub fn is_bound(&self) -> bool { match *self { @@ -1182,9 +1146,7 @@ impl Region { } } -impl Copy for Region {} - -#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] /// A "free" region `fr` can be interpreted as "some region /// at least as big as the scope `fr.scope`". pub struct FreeRegion { @@ -1192,9 +1154,7 @@ pub struct FreeRegion { pub bound_region: BoundRegion } -impl Copy for FreeRegion {} - -#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)] pub enum BoundRegion { /// An anonymous region parameter for a given fn (&T) BrAnon(uint), @@ -1213,8 +1173,6 @@ pub enum BoundRegion { BrEnv } -impl Copy for BoundRegion {} - #[inline] pub fn mk_prim_t<'tcx>(primitive: &'tcx TyS<'static>) -> Ty<'tcx> { // FIXME(#17596) Ty<'tcx> is incorrectly invariant w.r.t 'tcx. @@ -1378,15 +1336,13 @@ impl<'tcx> PolyTraitRef<'tcx> { #[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct Binder(pub T); -#[deriving(Clone, PartialEq)] +#[deriving(Clone, Copy, PartialEq)] pub enum IntVarValue { IntType(ast::IntTy), UintType(ast::UintTy), } -impl Copy for IntVarValue {} - -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] pub enum terr_vstore_kind { terr_vec, terr_str, @@ -1394,18 +1350,14 @@ pub enum terr_vstore_kind { terr_trait } -impl Copy for terr_vstore_kind {} - -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] pub struct expected_found { pub expected: T, pub found: T } -impl Copy for expected_found {} - // Data structures used in type unification -#[deriving(Clone, Show)] +#[deriving(Clone, Copy, Show)] pub enum type_err<'tcx> { terr_mismatch, terr_unsafety_mismatch(expected_found), @@ -1438,8 +1390,6 @@ pub enum type_err<'tcx> { terr_convergence_mismatch(expected_found) } -impl<'tcx> Copy for type_err<'tcx> {} - /// Bounds suitable for a named type parameter like `A` in `fn foo` /// as well as the existential type parameter in an object type. #[deriving(PartialEq, Eq, Hash, Clone, Show)] @@ -1454,17 +1404,15 @@ pub struct ParamBounds<'tcx> { /// major difference between this case and `ParamBounds` is that /// general purpose trait bounds are omitted and there must be /// *exactly one* region. -#[deriving(PartialEq, Eq, Hash, Clone, Show)] +#[deriving(Copy, PartialEq, Eq, Hash, Clone, Show)] pub struct ExistentialBounds { pub region_bound: ty::Region, pub builtin_bounds: BuiltinBounds } -impl Copy for ExistentialBounds {} - pub type BuiltinBounds = EnumSet; -#[deriving(Clone, Encodable, PartialEq, Eq, Decodable, Hash, Show)] +#[deriving(Copy, Clone, Encodable, PartialEq, Eq, Decodable, Hash, Show)] #[repr(uint)] pub enum BuiltinBound { BoundSend, @@ -1473,8 +1421,6 @@ pub enum BuiltinBound { BoundSync, } -impl Copy for BuiltinBound {} - pub fn empty_builtin_bounds() -> BuiltinBounds { EnumSet::new() } @@ -1502,35 +1448,27 @@ impl CLike for BuiltinBound { } } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash)] pub struct TyVid { pub index: uint } -impl Copy for TyVid {} - -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash)] pub struct IntVid { pub index: uint } -impl Copy for IntVid {} - -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash)] pub struct FloatVid { pub index: uint } -impl Copy for FloatVid {} - -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash)] pub struct RegionVid { pub index: uint } -impl Copy for RegionVid {} - -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, Copy, PartialEq, Eq, Hash)] pub enum InferTy { TyVar(TyVid), IntVar(IntVid), @@ -1547,16 +1485,12 @@ pub enum InferTy { FreshIntTy(uint), } -impl Copy for InferTy {} - -#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)] +#[deriving(Clone, Copy, Encodable, Decodable, Eq, Hash, Show)] pub enum InferRegion { ReVar(RegionVid), ReSkolemized(uint, BoundRegion) } -impl Copy for InferRegion {} - impl cmp::PartialEq for InferRegion { fn eq(&self, other: &InferRegion) -> bool { match ((*self), *other) { @@ -2006,15 +1940,13 @@ pub struct UnboxedClosure<'tcx> { pub kind: UnboxedClosureKind, } -#[deriving(Clone, PartialEq, Eq, Show)] +#[deriving(Clone, Copy, PartialEq, Eq, Show)] pub enum UnboxedClosureKind { FnUnboxedClosureKind, FnMutUnboxedClosureKind, FnOnceUnboxedClosureKind, } -impl Copy for UnboxedClosureKind {} - impl UnboxedClosureKind { pub fn trait_did(&self, cx: &ctxt) -> ast::DefId { let result = match *self { @@ -2795,13 +2727,11 @@ pub fn type_needs_unwind_cleanup<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool { /// The reason we compute type contents and not kinds is that it is /// easier for me (nmatsakis) to think about what is contained within /// a type than to think about what is *not* contained within a type. -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub struct TypeContents { pub bits: u64 } -impl Copy for TypeContents {} - macro_rules! def_type_content_sets { (mod $mname:ident { $($name:ident = $bits:expr),+ }) => { #[allow(non_snake_case)] @@ -3443,15 +3373,13 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { /// /// The ordering of the cases is significant. They are sorted so that cmp::max /// will keep the "more erroneous" of two values. -#[deriving(PartialOrd, Ord, Eq, PartialEq, Show)] +#[deriving(Copy, PartialOrd, Ord, Eq, PartialEq, Show)] pub enum Representability { Representable, ContainsRecursive, SelfRecursive, } -impl Copy for Representability {} - /// Check whether a type is representable. This means it cannot contain unboxed /// structural recursion. This check is needed for structs and enums. pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) @@ -4228,6 +4156,7 @@ pub fn expr_is_lval(tcx: &ctxt, e: &ast::Expr) -> bool { /// two kinds of rvalues is an artifact of trans which reflects how we will /// generate code for that kind of expression. See trans/expr.rs for more /// information. +#[deriving(Copy)] pub enum ExprKind { LvalueExpr, RvalueDpsExpr, @@ -4235,8 +4164,6 @@ pub enum ExprKind { RvalueStmtExpr } -impl Copy for ExprKind {} - pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind { if tcx.method_map.borrow().contains_key(&MethodCall::expr(expr.id)) { // Overloaded operations are generally calls, and hence they are @@ -4791,15 +4718,13 @@ pub fn associated_type_parameter_index(cx: &ctxt, cx.sess.bug("couldn't find associated type parameter index") } -#[deriving(PartialEq, Eq)] +#[deriving(Copy, PartialEq, Eq)] pub struct AssociatedTypeInfo { pub def_id: ast::DefId, pub index: uint, pub name: ast::Name, } -impl Copy for AssociatedTypeInfo {} - impl PartialOrd for AssociatedTypeInfo { fn partial_cmp(&self, other: &AssociatedTypeInfo) -> Option { Some(self.index.cmp(&other.index)) @@ -4979,13 +4904,12 @@ pub fn item_path_str(cx: &ctxt, id: ast::DefId) -> String { with_path(cx, id, |path| ast_map::path_to_string(path)).to_string() } +#[deriving(Copy)] pub enum DtorKind { NoDtor, TraitDtor(DefId, bool) } -impl Copy for DtorKind {} - impl DtorKind { pub fn is_present(&self) -> bool { match *self { @@ -5403,14 +5327,13 @@ pub fn tup_fields<'tcx>(v: &[Ty<'tcx>]) -> Vec> { }).collect() } +#[deriving(Copy)] pub struct UnboxedClosureUpvar<'tcx> { pub def: def::Def, pub span: Span, pub ty: Ty<'tcx>, } -impl<'tcx> Copy for UnboxedClosureUpvar<'tcx> {} - // Returns a list of `UnboxedClosureUpvar`s for each upvar. pub fn unboxed_closure_upvars<'tcx>(tcx: &ctxt<'tcx>, closure_id: ast::DefId, substs: &Substs<'tcx>) -> Vec> { @@ -6259,7 +6182,7 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> { } /// The category of explicit self. -#[deriving(Clone, Eq, PartialEq, Show)] +#[deriving(Clone, Copy, Eq, PartialEq, Show)] pub enum ExplicitSelfCategory { StaticExplicitSelfCategory, ByValueExplicitSelfCategory, @@ -6267,8 +6190,6 @@ pub enum ExplicitSelfCategory { ByBoxExplicitSelfCategory, } -impl Copy for ExplicitSelfCategory {} - /// Pushes all the lifetimes in the given type onto the given list. A /// "lifetime in a type" is a lifetime specified by a reference or a lifetime /// in a list of type substitutions. This does *not* traverse into nominal @@ -6329,7 +6250,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec, } /// A free variable referred to in a function. -#[deriving(Encodable, Decodable)] +#[deriving(Copy, Encodable, Decodable)] pub struct Freevar { /// The variable being accessed free. pub def: def::Def, @@ -6338,8 +6259,6 @@ pub struct Freevar { pub span: Span } -impl Copy for Freevar {} - pub type FreevarMap = NodeMap>; pub type CaptureModeMap = NodeMap; @@ -6469,8 +6388,6 @@ impl DebruijnIndex { } } -impl Copy for DebruijnIndex {} - impl<'tcx> Repr<'tcx> for AutoAdjustment<'tcx> { fn repr(&self, tcx: &ctxt<'tcx>) -> String { match *self { @@ -6589,14 +6506,13 @@ pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref.substs.clone().with_method(meth_tps, meth_regions) } +#[deriving(Copy)] pub enum CopyImplementationError { FieldDoesNotImplementCopy(ast::Name), VariantDoesNotImplementCopy(ast::Name), TypeIsStructural, } -impl Copy for CopyImplementationError {} - pub fn can_type_implement_copy<'tcx>(tcx: &ctxt<'tcx>, self_type: Ty<'tcx>, param_env: &ParameterEnvironment<'tcx>) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 59da0af417cfb..0c014d615caf5 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -47,7 +47,7 @@ pub struct Config { pub uint_type: UintTy, } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, Copy, PartialEq)] pub enum OptLevel { No, // -O0 Less, // -O1 @@ -55,18 +55,14 @@ pub enum OptLevel { Aggressive // -O3 } -impl Copy for OptLevel {} - -#[deriving(Clone, PartialEq)] +#[deriving(Clone, Copy, PartialEq)] pub enum DebugInfoLevel { NoDebugInfo, LimitedDebugInfo, FullDebugInfo, } -impl Copy for DebugInfoLevel {} - -#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq)] +#[deriving(Clone, Copy, PartialEq, PartialOrd, Ord, Eq)] pub enum OutputType { OutputTypeBitcode, OutputTypeAssembly, @@ -75,8 +71,6 @@ pub enum OutputType { OutputTypeExe, } -impl Copy for OutputType {} - #[deriving(Clone)] pub struct Options { // The crate config requested for the session, which may be combined @@ -220,16 +214,14 @@ pub fn basic_options() -> Options { // users can have their own entry // functions that don't start a // scheduler -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] pub enum EntryFnType { EntryMain, EntryStart, EntryNone, } -impl Copy for EntryFnType {} - -#[deriving(PartialEq, PartialOrd, Clone, Ord, Eq, Hash)] +#[deriving(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash)] pub enum CrateType { CrateTypeExecutable, CrateTypeDylib, @@ -237,8 +229,6 @@ pub enum CrateType { CrateTypeStaticlib, } -impl Copy for CrateType {} - macro_rules! debugging_opts { ([ $opt:ident ] $cnt:expr ) => ( pub const $opt: u64 = 1 << $cnt; diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 51e18c80d0584..bc6fb1be0758f 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -22,11 +22,9 @@ use syntax::visit::Visitor; // Useful type to use with `Result<>` indicate that an error has already // been reported to the user, so no need to continue checking. -#[deriving(Clone,Show)] +#[deriving(Clone, Copy, Show)] pub struct ErrorReported; -impl Copy for ErrorReported {} - pub fn time(do_it: bool, what: &str, u: U, f: F) -> T where F: FnOnce(U) -> T, { diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index d1816c655fa5f..2b05961bb6a05 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -68,11 +68,9 @@ pub mod DefIdSet { /// /// This uses FNV hashing, as described here: /// http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function -#[deriving(Clone, Default)] +#[deriving(Clone, Copy, Default)] pub struct FnvHasher; -impl Copy for FnvHasher {} - #[allow(missing_copy_implementations)] pub struct FnvState(u64);