@@ -219,7 +219,6 @@ use util::nodemap::FnvHashMap;
219219use util:: ppaux:: { Repr , vec_map_to_string} ;
220220
221221use std;
222- use std:: cell:: RefCell ;
223222use std:: cmp:: Ordering ;
224223use std:: iter:: AdditiveIterator ;
225224use std:: rc:: Rc ;
@@ -429,7 +428,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
429428}
430429
431430fn enter_match < ' a , ' b , ' p , ' blk , ' tcx , F > ( bcx : Block < ' blk , ' tcx > ,
432- dm : & RefCell < DefMap > ,
431+ dm : & DefMap ,
433432 m : & [ Match < ' a , ' p , ' blk , ' tcx > ] ,
434433 col : usize ,
435434 val : ValueRef ,
@@ -450,7 +449,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
450449 let mut bound_ptrs = br. bound_ptrs . clone ( ) ;
451450 match this. node {
452451 ast:: PatIdent ( _, ref path, None ) => {
453- if pat_is_binding ( & dm. borrow ( ) , & * this) {
452+ if pat_is_binding ( & dm, & * this) {
454453 bound_ptrs. push ( ( path. node , val) ) ;
455454 }
456455 }
@@ -475,7 +474,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
475474}
476475
477476fn enter_default < ' a , ' p , ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
478- dm : & RefCell < DefMap > ,
477+ dm : & DefMap ,
479478 m : & [ Match < ' a , ' p , ' blk , ' tcx > ] ,
480479 col : usize ,
481480 val : ValueRef )
@@ -489,7 +488,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
489488
490489 // Collect all of the matches that can match against anything.
491490 enter_match ( bcx, dm, m, col, val, |pats| {
492- if pat_is_binding_or_wild ( & dm. borrow ( ) , & * pats[ col] ) {
491+ if pat_is_binding_or_wild ( & dm, & * pats[ col] ) {
493492 let mut r = pats[ ..col] . to_vec ( ) ;
494493 r. push_all ( & pats[ col + 1 ..] ) ;
495494 Some ( r)
@@ -530,7 +529,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
530529fn enter_opt < ' a , ' p , ' blk , ' tcx > (
531530 bcx : Block < ' blk , ' tcx > ,
532531 _: ast:: NodeId ,
533- dm : & RefCell < DefMap > ,
532+ dm : & DefMap ,
534533 m : & [ Match < ' a , ' p , ' blk , ' tcx > ] ,
535534 opt : & Opt ,
536535 col : usize ,
@@ -773,11 +772,11 @@ impl FailureHandler {
773772 }
774773}
775774
776- fn pick_column_to_specialize ( def_map : & RefCell < DefMap > , m : & [ Match ] ) -> Option < usize > {
777- fn pat_score ( def_map : & RefCell < DefMap > , pat : & ast:: Pat ) -> usize {
775+ fn pick_column_to_specialize ( def_map : & DefMap , m : & [ Match ] ) -> Option < usize > {
776+ fn pat_score ( def_map : & DefMap , pat : & ast:: Pat ) -> usize {
778777 match pat. node {
779778 ast:: PatIdent ( _, _, Some ( ref inner) ) => pat_score ( def_map, & * * inner) ,
780- _ if pat_is_refutable ( & def_map. borrow ( ) , pat) => 1 ,
779+ _ if pat_is_refutable ( & def_map, pat) => 1 ,
781780 _ => 0
782781 }
783782 }
@@ -997,9 +996,9 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
997996 return ;
998997 }
999998
1000- let tcx = bcx . tcx ( ) ;
1001- let def_map = & tcx. def_map ;
1002- match pick_column_to_specialize ( def_map , m ) {
999+ // On a separate line to limit the lifetime of the borrow
1000+ let col_opt = pick_column_to_specialize ( & bcx . tcx ( ) . def_map . borrow ( ) , m ) ;
1001+ match col_opt {
10031002 Some ( col) => {
10041003 let val = vals[ col] ;
10051004 if has_nested_bindings ( m, col) {
@@ -1095,7 +1094,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
10951094 } ;
10961095 match adt_vals {
10971096 Some ( field_vals) => {
1098- let pats = enter_match ( bcx, dm , m, col, val, |pats|
1097+ let pats = enter_match ( bcx, & dm . borrow ( ) , m, col, val, |pats|
10991098 check_match:: specialize ( & mcx, pats,
11001099 & check_match:: Single , col,
11011100 field_vals. len ( ) )
@@ -1153,7 +1152,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
11531152 C_int ( ccx, 0 ) // Placeholder for when not using a switch
11541153 } ;
11551154
1156- let defaults = enter_default ( else_cx, dm , m, col, val) ;
1155+ let defaults = enter_default ( else_cx, & dm . borrow ( ) , m, col, val) ;
11571156 let exhaustive = chk. is_infallible ( ) && defaults. len ( ) == 0 ;
11581157 let len = opts. len ( ) ;
11591158
@@ -1253,7 +1252,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
12531252 }
12541253 ConstantValue ( ..) | ConstantRange ( ..) => ( )
12551254 }
1256- let opt_ms = enter_opt ( opt_cx, pat_id, dm , m, opt, col, size, val) ;
1255+ let opt_ms = enter_opt ( opt_cx, pat_id, & dm . borrow ( ) , m, opt, col, size, val) ;
12571256 let mut opt_vals = unpacked;
12581257 opt_vals. push_all ( & vals_left[ ..] ) ;
12591258 compile_submatch ( opt_cx,
0 commit comments