@@ -219,7 +219,6 @@ use util::nodemap::FnvHashMap;
219
219
use util:: ppaux:: { Repr , vec_map_to_string} ;
220
220
221
221
use std;
222
- use std:: cell:: RefCell ;
223
222
use std:: cmp:: Ordering ;
224
223
use std:: iter:: AdditiveIterator ;
225
224
use std:: rc:: Rc ;
@@ -429,7 +428,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
429
428
}
430
429
431
430
fn enter_match < ' a , ' b , ' p , ' blk , ' tcx , F > ( bcx : Block < ' blk , ' tcx > ,
432
- dm : & RefCell < DefMap > ,
431
+ dm : & DefMap ,
433
432
m : & [ Match < ' a , ' p , ' blk , ' tcx > ] ,
434
433
col : usize ,
435
434
val : ValueRef ,
@@ -450,7 +449,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
450
449
let mut bound_ptrs = br. bound_ptrs . clone ( ) ;
451
450
match this. node {
452
451
ast:: PatIdent ( _, ref path, None ) => {
453
- if pat_is_binding ( & dm. borrow ( ) , & * this) {
452
+ if pat_is_binding ( & dm, & * this) {
454
453
bound_ptrs. push ( ( path. node , val) ) ;
455
454
}
456
455
}
@@ -475,7 +474,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
475
474
}
476
475
477
476
fn enter_default < ' a , ' p , ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
478
- dm : & RefCell < DefMap > ,
477
+ dm : & DefMap ,
479
478
m : & [ Match < ' a , ' p , ' blk , ' tcx > ] ,
480
479
col : usize ,
481
480
val : ValueRef )
@@ -489,7 +488,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
489
488
490
489
// Collect all of the matches that can match against anything.
491
490
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] ) {
493
492
let mut r = pats[ ..col] . to_vec ( ) ;
494
493
r. push_all ( & pats[ col + 1 ..] ) ;
495
494
Some ( r)
@@ -530,7 +529,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
530
529
fn enter_opt < ' a , ' p , ' blk , ' tcx > (
531
530
bcx : Block < ' blk , ' tcx > ,
532
531
_: ast:: NodeId ,
533
- dm : & RefCell < DefMap > ,
532
+ dm : & DefMap ,
534
533
m : & [ Match < ' a , ' p , ' blk , ' tcx > ] ,
535
534
opt : & Opt ,
536
535
col : usize ,
@@ -773,11 +772,11 @@ impl FailureHandler {
773
772
}
774
773
}
775
774
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 {
778
777
match pat. node {
779
778
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 ,
781
780
_ => 0
782
781
}
783
782
}
@@ -997,9 +996,9 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
997
996
return ;
998
997
}
999
998
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 {
1003
1002
Some ( col) => {
1004
1003
let val = vals[ col] ;
1005
1004
if has_nested_bindings ( m, col) {
@@ -1095,7 +1094,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
1095
1094
} ;
1096
1095
match adt_vals {
1097
1096
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|
1099
1098
check_match:: specialize ( & mcx, pats,
1100
1099
& check_match:: Single , col,
1101
1100
field_vals. len ( ) )
@@ -1153,7 +1152,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
1153
1152
C_int ( ccx, 0 ) // Placeholder for when not using a switch
1154
1153
} ;
1155
1154
1156
- let defaults = enter_default ( else_cx, dm , m, col, val) ;
1155
+ let defaults = enter_default ( else_cx, & dm . borrow ( ) , m, col, val) ;
1157
1156
let exhaustive = chk. is_infallible ( ) && defaults. len ( ) == 0 ;
1158
1157
let len = opts. len ( ) ;
1159
1158
@@ -1253,7 +1252,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
1253
1252
}
1254
1253
ConstantValue ( ..) | ConstantRange ( ..) => ( )
1255
1254
}
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) ;
1257
1256
let mut opt_vals = unpacked;
1258
1257
opt_vals. push_all ( & vals_left[ ..] ) ;
1259
1258
compile_submatch ( opt_cx,
0 commit comments