diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 47f29a26db145..c07a27043c275 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -33,6 +33,8 @@ use rustc_front::hir::{Expr, FnDecl, Block, Pat}; use rustc_front::intravisit; use rustc_front::intravisit::Visitor; +use self::restrictions::RestrictionResult; + mod lifetime; mod restrictions; mod gather_moves; @@ -354,12 +356,12 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { // Create the loan record (if needed). let loan = match restr { - restrictions::Safe => { + RestrictionResult::Safe => { // No restrictions---no loan record necessary return; } - restrictions::SafeIf(loan_path, restricted_paths) => { + RestrictionResult::SafeIf(loan_path, restricted_paths) => { let loan_scope = match loan_region { ty::ReScope(scope) => scope, diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index cb75180b47466..2a0d8ef276648 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -10,8 +10,6 @@ //! Computes the restrictions that result from a borrow. -pub use self::RestrictionResult::*; - use borrowck::*; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; @@ -69,19 +67,19 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { // are inherently non-aliasable, they can only be // accessed later through the borrow itself and hence // must inherently comply with its terms. - Safe + RestrictionResult::Safe } Categorization::Local(local_id) => { // R-Variable, locally declared let lp = new_lp(LpVar(local_id)); - SafeIf(lp.clone(), vec![lp]) + RestrictionResult::SafeIf(lp.clone(), vec![lp]) } Categorization::Upvar(mc::Upvar { id, .. }) => { // R-Variable, captured into closure let lp = new_lp(LpUpvar(id)); - SafeIf(lp.clone(), vec![lp]) + RestrictionResult::SafeIf(lp.clone(), vec![lp]) } Categorization::Downcast(cmt_base, _) => { @@ -106,7 +104,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { } Categorization::StaticItem => { - Safe + RestrictionResult::Safe } Categorization::Deref(cmt_base, _, pk) => { @@ -133,11 +131,11 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { cmt: cmt_base, code: err_borrowed_pointer_too_short( self.loan_region, lt)}); - return Safe; + return RestrictionResult::Safe; } match bk { - ty::ImmBorrow => Safe, + ty::ImmBorrow => RestrictionResult::Safe, ty::MutBorrow | ty::UniqueImmBorrow => { // R-Deref-Mut-Borrowed // @@ -150,7 +148,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { } } // Borrowck is not relevant for raw pointers - mc::UnsafePtr(..) => Safe + mc::UnsafePtr(..) => RestrictionResult::Safe } } } @@ -161,12 +159,12 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { cmt: &mc::cmt<'tcx>, elem: LoanPathElem) -> RestrictionResult<'tcx> { match result { - Safe => Safe, - SafeIf(base_lp, mut base_vec) => { + RestrictionResult::Safe => RestrictionResult::Safe, + RestrictionResult::SafeIf(base_lp, mut base_vec) => { let v = LpExtend(base_lp, cmt.mutbl, elem); let lp = Rc::new(LoanPath::new(v, cmt.ty)); base_vec.push(lp.clone()); - SafeIf(lp, base_vec) + RestrictionResult::SafeIf(lp, base_vec) } } }