File tree Expand file tree Collapse file tree 4 files changed +11
-21
lines changed
src/librustc/middle/borrowck Expand file tree Collapse file tree 4 files changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -208,8 +208,8 @@ impl<'a> CheckLoanCtxt<'a> {
208
208
loan. repr( self . tcx( ) ) ) ;
209
209
210
210
let mut ret = true ;
211
- for restr in loan. restrictions . iter ( ) {
212
- if * restr . loan_path == * loan_path {
211
+ for restr_path in loan. restricted_paths . iter ( ) {
212
+ if * * restr_path == * loan_path {
213
213
if !op ( loan) {
214
214
ret = false ;
215
215
break ;
@@ -298,8 +298,8 @@ impl<'a> CheckLoanCtxt<'a> {
298
298
return true ;
299
299
}
300
300
301
- for restr in loan1. restrictions . iter ( ) {
302
- if restr . loan_path != loan2. loan_path { continue ; }
301
+ for restr_path in loan1. restricted_paths . iter ( ) {
302
+ if * restr_path != loan2. loan_path { continue ; }
303
303
304
304
let old_pronoun = if new_loan. loan_path == old_loan. loan_path {
305
305
"it" . to_string ( )
Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ impl<'a> GatherLoanCtxt<'a> {
268
268
return ;
269
269
}
270
270
271
- restrictions:: SafeIf ( loan_path, restrictions ) => {
271
+ restrictions:: SafeIf ( loan_path, restricted_paths ) => {
272
272
let loan_scope = match loan_region {
273
273
ty:: ReScope ( id) => id,
274
274
ty:: ReFree ( ref fr) => fr. scope_id ,
@@ -314,7 +314,7 @@ impl<'a> GatherLoanCtxt<'a> {
314
314
gen_scope : gen_scope,
315
315
kill_scope : kill_scope,
316
316
span : borrow_span,
317
- restrictions : restrictions ,
317
+ restricted_paths : restricted_paths ,
318
318
cause : cause,
319
319
}
320
320
}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ use std::rc::Rc;
23
23
24
24
pub enum RestrictionResult {
25
25
Safe ,
26
- SafeIf ( Rc < LoanPath > , Vec < Restriction > )
26
+ SafeIf ( Rc < LoanPath > , Vec < Rc < LoanPath > > )
27
27
}
28
28
29
29
pub fn compute_restrictions ( bccx : & BorrowckCtxt ,
@@ -71,7 +71,7 @@ impl<'a> RestrictionsContext<'a> {
71
71
mc:: cat_upvar( ty:: UpvarId { var_id : local_id, ..} , _) => {
72
72
// R-Variable
73
73
let lp = Rc :: new ( LpVar ( local_id) ) ;
74
- SafeIf ( lp. clone ( ) , vec ! ( Restriction { loan_path : lp } ) )
74
+ SafeIf ( lp. clone ( ) , vec ! ( lp ) )
75
75
}
76
76
77
77
mc:: cat_downcast( cmt_base) => {
@@ -164,7 +164,7 @@ impl<'a> RestrictionsContext<'a> {
164
164
Safe => Safe ,
165
165
SafeIf ( base_lp, mut base_vec) => {
166
166
let lp = Rc :: new ( LpExtend ( base_lp, mc, elem) ) ;
167
- base_vec. push ( Restriction { loan_path : lp. clone ( ) } ) ;
167
+ base_vec. push ( lp. clone ( ) ) ;
168
168
SafeIf ( lp, base_vec)
169
169
}
170
170
}
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ pub struct Loan {
181
181
index : uint ,
182
182
loan_path : Rc < LoanPath > ,
183
183
kind : ty:: BorrowKind ,
184
- restrictions : Vec < Restriction > ,
184
+ restricted_paths : Vec < Rc < LoanPath > > ,
185
185
gen_scope : ast:: NodeId ,
186
186
kill_scope : ast:: NodeId ,
187
187
span : Span ,
@@ -249,10 +249,6 @@ pub fn opt_loan_path(cmt: &mc::cmt) -> Option<Rc<LoanPath>> {
249
249
}
250
250
}
251
251
252
- pub struct Restriction {
253
- loan_path : Rc < LoanPath > ,
254
- }
255
-
256
252
///////////////////////////////////////////////////////////////////////////
257
253
// Errors
258
254
@@ -777,13 +773,7 @@ impl Repr for Loan {
777
773
self . kind,
778
774
self . gen_scope,
779
775
self . kill_scope,
780
- self . restrictions. repr( tcx) ) ) . to_string ( )
781
- }
782
- }
783
-
784
- impl Repr for Restriction {
785
- fn repr ( & self , tcx : & ty:: ctxt ) -> String {
786
- ( format ! ( "Restriction({})" , self . loan_path. repr( tcx) ) ) . to_string ( )
776
+ self . restricted_paths. repr( tcx) ) ) . to_string ( )
787
777
}
788
778
}
789
779
You can’t perform that action at this time.
0 commit comments