Stop re-exporting RestrictionResult variants.

This commit is contained in:
Ms2ger 2015-12-15 16:15:59 +01:00
parent 9e63cecb10
commit 9a0ab50ac0
2 changed files with 14 additions and 14 deletions

View File

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

View File

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