Skip to content

Commit f0361a0

Browse files
committed
Rollup merge of #30392 - Ms2ger:RestrictionResult, r=alexcrichton
2 parents b0b9a55 + 9a0ab50 commit f0361a0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/librustc_borrowck/borrowck/gather_loans/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ use rustc_front::hir::{Expr, FnDecl, Block, Pat};
3333
use rustc_front::intravisit;
3434
use rustc_front::intravisit::Visitor;
3535

36+
use self::restrictions::RestrictionResult;
37+
3638
mod lifetime;
3739
mod restrictions;
3840
mod gather_moves;
@@ -354,12 +356,12 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
354356

355357
// Create the loan record (if needed).
356358
let loan = match restr {
357-
restrictions::Safe => {
359+
RestrictionResult::Safe => {
358360
// No restrictions---no loan record necessary
359361
return;
360362
}
361363

362-
restrictions::SafeIf(loan_path, restricted_paths) => {
364+
RestrictionResult::SafeIf(loan_path, restricted_paths) => {
363365
let loan_scope = match loan_region {
364366
ty::ReScope(scope) => scope,
365367

src/librustc_borrowck/borrowck/gather_loans/restrictions.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
//! Computes the restrictions that result from a borrow.
1212
13-
pub use self::RestrictionResult::*;
14-
1513
use borrowck::*;
1614
use rustc::middle::expr_use_visitor as euv;
1715
use rustc::middle::mem_categorization as mc;
@@ -69,19 +67,19 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
6967
// are inherently non-aliasable, they can only be
7068
// accessed later through the borrow itself and hence
7169
// must inherently comply with its terms.
72-
Safe
70+
RestrictionResult::Safe
7371
}
7472

7573
Categorization::Local(local_id) => {
7674
// R-Variable, locally declared
7775
let lp = new_lp(LpVar(local_id));
78-
SafeIf(lp.clone(), vec![lp])
76+
RestrictionResult::SafeIf(lp.clone(), vec![lp])
7977
}
8078

8179
Categorization::Upvar(mc::Upvar { id, .. }) => {
8280
// R-Variable, captured into closure
8381
let lp = new_lp(LpUpvar(id));
84-
SafeIf(lp.clone(), vec![lp])
82+
RestrictionResult::SafeIf(lp.clone(), vec![lp])
8583
}
8684

8785
Categorization::Downcast(cmt_base, _) => {
@@ -106,7 +104,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
106104
}
107105

108106
Categorization::StaticItem => {
109-
Safe
107+
RestrictionResult::Safe
110108
}
111109

112110
Categorization::Deref(cmt_base, _, pk) => {
@@ -133,11 +131,11 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
133131
cmt: cmt_base,
134132
code: err_borrowed_pointer_too_short(
135133
self.loan_region, lt)});
136-
return Safe;
134+
return RestrictionResult::Safe;
137135
}
138136

139137
match bk {
140-
ty::ImmBorrow => Safe,
138+
ty::ImmBorrow => RestrictionResult::Safe,
141139
ty::MutBorrow | ty::UniqueImmBorrow => {
142140
// R-Deref-Mut-Borrowed
143141
//
@@ -150,7 +148,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
150148
}
151149
}
152150
// Borrowck is not relevant for raw pointers
153-
mc::UnsafePtr(..) => Safe
151+
mc::UnsafePtr(..) => RestrictionResult::Safe
154152
}
155153
}
156154
}
@@ -161,12 +159,12 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
161159
cmt: &mc::cmt<'tcx>,
162160
elem: LoanPathElem) -> RestrictionResult<'tcx> {
163161
match result {
164-
Safe => Safe,
165-
SafeIf(base_lp, mut base_vec) => {
162+
RestrictionResult::Safe => RestrictionResult::Safe,
163+
RestrictionResult::SafeIf(base_lp, mut base_vec) => {
166164
let v = LpExtend(base_lp, cmt.mutbl, elem);
167165
let lp = Rc::new(LoanPath::new(v, cmt.ty));
168166
base_vec.push(lp.clone());
169-
SafeIf(lp, base_vec)
167+
RestrictionResult::SafeIf(lp, base_vec)
170168
}
171169
}
172170
}

0 commit comments

Comments
 (0)