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> {
208208 loan. repr( self . tcx( ) ) ) ;
209209
210210 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 {
213213 if !op ( loan) {
214214 ret = false ;
215215 break ;
@@ -298,8 +298,8 @@ impl<'a> CheckLoanCtxt<'a> {
298298 return true ;
299299 }
300300
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 ; }
303303
304304 let old_pronoun = if new_loan. loan_path == old_loan. loan_path {
305305 "it" . to_string ( )
Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ impl<'a> GatherLoanCtxt<'a> {
268268 return ;
269269 }
270270
271- restrictions:: SafeIf ( loan_path, restrictions ) => {
271+ restrictions:: SafeIf ( loan_path, restricted_paths ) => {
272272 let loan_scope = match loan_region {
273273 ty:: ReScope ( id) => id,
274274 ty:: ReFree ( ref fr) => fr. scope_id ,
@@ -314,7 +314,7 @@ impl<'a> GatherLoanCtxt<'a> {
314314 gen_scope : gen_scope,
315315 kill_scope : kill_scope,
316316 span : borrow_span,
317- restrictions : restrictions ,
317+ restricted_paths : restricted_paths ,
318318 cause : cause,
319319 }
320320 }
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ use std::rc::Rc;
2323
2424pub enum RestrictionResult {
2525 Safe ,
26- SafeIf ( Rc < LoanPath > , Vec < Restriction > )
26+ SafeIf ( Rc < LoanPath > , Vec < Rc < LoanPath > > )
2727}
2828
2929pub fn compute_restrictions ( bccx : & BorrowckCtxt ,
@@ -71,7 +71,7 @@ impl<'a> RestrictionsContext<'a> {
7171 mc:: cat_upvar( ty:: UpvarId { var_id : local_id, ..} , _) => {
7272 // R-Variable
7373 let lp = Rc :: new ( LpVar ( local_id) ) ;
74- SafeIf ( lp. clone ( ) , vec ! ( Restriction { loan_path : lp } ) )
74+ SafeIf ( lp. clone ( ) , vec ! ( lp ) )
7575 }
7676
7777 mc:: cat_downcast( cmt_base) => {
@@ -164,7 +164,7 @@ impl<'a> RestrictionsContext<'a> {
164164 Safe => Safe ,
165165 SafeIf ( base_lp, mut base_vec) => {
166166 let lp = Rc :: new ( LpExtend ( base_lp, mc, elem) ) ;
167- base_vec. push ( Restriction { loan_path : lp. clone ( ) } ) ;
167+ base_vec. push ( lp. clone ( ) ) ;
168168 SafeIf ( lp, base_vec)
169169 }
170170 }
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ pub struct Loan {
181181 index : uint ,
182182 loan_path : Rc < LoanPath > ,
183183 kind : ty:: BorrowKind ,
184- restrictions : Vec < Restriction > ,
184+ restricted_paths : Vec < Rc < LoanPath > > ,
185185 gen_scope : ast:: NodeId ,
186186 kill_scope : ast:: NodeId ,
187187 span : Span ,
@@ -249,10 +249,6 @@ pub fn opt_loan_path(cmt: &mc::cmt) -> Option<Rc<LoanPath>> {
249249 }
250250}
251251
252- pub struct Restriction {
253- loan_path : Rc < LoanPath > ,
254- }
255-
256252///////////////////////////////////////////////////////////////////////////
257253// Errors
258254
@@ -777,13 +773,7 @@ impl Repr for Loan {
777773 self . kind,
778774 self . gen_scope,
779775 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 ( )
787777 }
788778}
789779
You can’t perform that action at this time.
0 commit comments