]> git.lizzy.rs Git - rust.git/commitdiff
librustc_borrowck: use `#[deriving(Copy)]`
authorJorge Aparicio <japaricious@gmail.com>
Mon, 15 Dec 2014 04:06:50 +0000 (23:06 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Fri, 19 Dec 2014 15:51:00 +0000 (10:51 -0500)
src/librustc_borrowck/borrowck/mod.rs
src/librustc_borrowck/borrowck/move_data.rs
src/librustc_borrowck/graphviz.rs

index 7f469db318611f9c69d1e0015221f416cf20de6b..9be87b533f2960640b2be1c3e58b234fcb02a879 100644 (file)
@@ -56,11 +56,9 @@ macro_rules! if_ok {
 
 pub mod move_data;
 
-#[deriving(Clone)]
+#[deriving(Clone, Copy)]
 pub struct LoanDataFlowOperator;
 
-impl Copy for LoanDataFlowOperator {}
-
 pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator>;
 
 impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
@@ -325,14 +323,12 @@ fn to_type(&self) -> ty::Ty<'tcx> { self.ty }
 //     b2b39e8700e37ad32b486b9a8409b50a8a53aa51#commitcomment-7892003
 static DOWNCAST_PRINTED_OPERATOR : &'static str = " as ";
 
-#[deriving(PartialEq, Eq, Hash, Show)]
+#[deriving(Copy, PartialEq, Eq, Hash, Show)]
 pub enum LoanPathElem {
     LpDeref(mc::PointerKind),    // `*LV` in doc.rs
     LpInterior(mc::InteriorKind) // `LV.f` in doc.rs
 }
 
-impl Copy for LoanPathElem {}
-
 pub fn closure_to_block(closure_id: ast::NodeId,
                         tcx: &ty::ctxt) -> ast::NodeId {
     match tcx.map.get(closure_id) {
@@ -494,21 +490,18 @@ pub struct BckError<'tcx> {
     code: bckerr_code
 }
 
+#[deriving(Copy)]
 pub enum AliasableViolationKind {
     MutabilityViolation,
     BorrowViolation(euv::LoanCause)
 }
 
-impl Copy for AliasableViolationKind {}
-
-#[deriving(Show)]
+#[deriving(Copy, Show)]
 pub enum MovedValueUseKind {
     MovedInUse,
     MovedInCapture,
 }
 
-impl Copy for MovedValueUseKind {}
-
 ///////////////////////////////////////////////////////////////////////////
 // Misc
 
index 00b1377af73040793dfa803a227bd45ad65ed47d..d033fd808aa40eadedd842cba911b42a4ebf529e 100644 (file)
@@ -78,11 +78,9 @@ pub struct FlowedMoveData<'a, 'tcx: 'a> {
 }
 
 /// Index into `MoveData.paths`, used like a pointer
-#[deriving(PartialEq, Eq, PartialOrd, Ord, Show)]
+#[deriving(Copy, PartialEq, Eq, PartialOrd, Ord, Show)]
 pub struct MovePathIndex(uint);
 
-impl Copy for MovePathIndex {}
-
 impl MovePathIndex {
     fn get(&self) -> uint {
         let MovePathIndex(v) = *self; v
@@ -100,11 +98,9 @@ fn clone(&self) -> MovePathIndex {
     MovePathIndex(uint::MAX);
 
 /// Index into `MoveData.moves`, used like a pointer
-#[deriving(PartialEq)]
+#[deriving(Copy, PartialEq)]
 pub struct MoveIndex(uint);
 
-impl Copy for MoveIndex {}
-
 impl MoveIndex {
     fn get(&self) -> uint {
         let MoveIndex(v) = *self; v
@@ -134,7 +130,7 @@ pub struct MovePath<'tcx> {
     pub next_sibling: MovePathIndex,
 }
 
-#[deriving(PartialEq, Show)]
+#[deriving(Copy, PartialEq, Show)]
 pub enum MoveKind {
     Declared,   // When declared, variables start out "moved".
     MoveExpr,   // Expression or binding that moves a variable
@@ -142,8 +138,7 @@ pub enum MoveKind {
     Captured    // Closure creation that moves a value
 }
 
-impl Copy for MoveKind {}
-
+#[deriving(Copy)]
 pub struct Move {
     /// Path being moved.
     pub path: MovePathIndex,
@@ -158,8 +153,7 @@ pub struct Move {
     pub next_move: MoveIndex
 }
 
-impl Copy for Move {}
-
+#[deriving(Copy)]
 pub struct Assignment {
     /// Path being assigned.
     pub path: MovePathIndex,
@@ -171,8 +165,7 @@ pub struct Assignment {
     pub span: Span,
 }
 
-impl Copy for Assignment {}
-
+#[deriving(Copy)]
 pub struct VariantMatch {
     /// downcast to the variant.
     pub path: MovePathIndex,
@@ -187,20 +180,14 @@ pub struct VariantMatch {
     pub mode: euv::MatchMode
 }
 
-impl Copy for VariantMatch {}
-
-#[deriving(Clone)]
+#[deriving(Clone, Copy)]
 pub struct MoveDataFlowOperator;
 
-impl Copy for MoveDataFlowOperator {}
-
 pub type MoveDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, MoveDataFlowOperator>;
 
-#[deriving(Clone)]
+#[deriving(Clone, Copy)]
 pub struct AssignDataFlowOperator;
 
-impl Copy for AssignDataFlowOperator {}
-
 pub type AssignDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, AssignDataFlowOperator>;
 
 fn loan_path_is_precise(loan_path: &LoanPath) -> bool {
index 9d41efd678c7cd47e03590be7fe3868751a9defb..3427be1443b3c3b75f29a87e3d9856dd7bd7e192 100644 (file)
 use rustc::middle::dataflow;
 use std::rc::Rc;
 
-#[deriving(Show)]
+#[deriving(Show, Copy)]
 pub enum Variant {
     Loans,
     Moves,
     Assigns,
 }
 
-impl Copy for Variant {}
-
 impl Variant {
     pub fn short_name(&self) -> &'static str {
         match *self {