librustc_borrowck: use #[deriving(Copy)]
This commit is contained in:
parent
e64a0072d6
commit
392ea799b8
3 changed files with 13 additions and 35 deletions
|
|
@ -56,11 +56,9 @@ pub mod gather_loans;
|
|||
|
||||
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 @@ impl<'tcx> LoanPath<'tcx> {
|
|||
// 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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 @@ static InvalidMovePathIndex: 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 {
|
||||
|
|
|
|||
|
|
@ -25,15 +25,13 @@ use rustc::middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
|
|||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue