@@ -1009,7 +1009,7 @@ pub struct Resolver<'a, 'tcx: 'a> {
1009
1009
// The idents for the primitive types.
1010
1010
primitive_type_table : PrimitiveTypeTable ,
1011
1011
1012
- def_map : RefCell < DefMap > ,
1012
+ def_map : DefMap ,
1013
1013
freevars : FreevarMap ,
1014
1014
freevars_seen : NodeMap < NodeMap < usize > > ,
1015
1015
export_map : ExportMap ,
@@ -1133,7 +1133,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1133
1133
1134
1134
primitive_type_table : PrimitiveTypeTable :: new ( ) ,
1135
1135
1136
- def_map : RefCell :: new ( NodeMap ( ) ) ,
1136
+ def_map : NodeMap ( ) ,
1137
1137
freevars : NodeMap ( ) ,
1138
1138
freevars_seen : NodeMap ( ) ,
1139
1139
export_map : NodeMap ( ) ,
@@ -2001,14 +2001,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2001
2001
// user and one 'x' came from the macro.
2002
2002
fn binding_mode_map ( & mut self , pat : & Pat ) -> BindingMap {
2003
2003
let mut result = HashMap :: new ( ) ;
2004
- pat_bindings ( & self . def_map , pat, |binding_mode, _id, sp, path1| {
2004
+ let def_map = RefCell :: new ( :: std:: mem:: replace ( & mut self . def_map , NodeMap ( ) ) ) ;
2005
+ pat_bindings ( & def_map, pat, |binding_mode, _id, sp, path1| {
2005
2006
let name = path1. node ;
2006
2007
result. insert ( name,
2007
2008
BindingInfo {
2008
2009
span : sp,
2009
2010
binding_mode : binding_mode,
2010
2011
} ) ;
2011
2012
} ) ;
2013
+ self . def_map = def_map. into_inner ( ) ;
2012
2014
return result;
2013
2015
}
2014
2016
@@ -2799,7 +2801,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2799
2801
2800
2802
if let Some ( node_id) = self . current_self_type . as_ref ( ) . and_then ( extract_node_id) {
2801
2803
// Look for a field with the same name in the current self_type.
2802
- match self . def_map . borrow ( ) . get ( & node_id) . map ( |d| d. full_def ( ) ) {
2804
+ match self . def_map . get ( & node_id) . map ( |d| d. full_def ( ) ) {
2803
2805
Some ( Def :: Enum ( did) ) |
2804
2806
Some ( Def :: TyAlias ( did) ) |
2805
2807
Some ( Def :: Struct ( did) ) |
@@ -3273,7 +3275,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3273
3275
3274
3276
fn record_def ( & mut self , node_id : NodeId , resolution : PathResolution ) {
3275
3277
debug ! ( "(recording def) recording {:?} for {}" , resolution, node_id) ;
3276
- if let Some ( prev_res) = self . def_map . borrow_mut ( ) . insert ( node_id, resolution) {
3278
+ if let Some ( prev_res) = self . def_map . insert ( node_id, resolution) {
3277
3279
let span = self . ast_map . opt_span ( node_id) . unwrap_or ( codemap:: DUMMY_SP ) ;
3278
3280
span_bug ! ( span,
3279
3281
"path resolved multiple times ({:?} before, {:?} now)" ,
@@ -3314,7 +3316,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3314
3316
Success ( module) => {
3315
3317
let def = module. def . unwrap ( ) ;
3316
3318
let path_resolution = PathResolution { base_def : def, depth : 0 } ;
3317
- self . def_map . borrow_mut ( ) . insert ( id, path_resolution) ;
3319
+ self . def_map . insert ( id, path_resolution) ;
3318
3320
ty:: Visibility :: Restricted ( self . ast_map . as_local_node_id ( def. def_id ( ) ) . unwrap ( ) )
3319
3321
}
3320
3322
Failed ( Some ( ( span, msg) ) ) => {
@@ -3568,7 +3570,7 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
3568
3570
resolver. report_privacy_errors ( ) ;
3569
3571
3570
3572
CrateMap {
3571
- def_map : resolver. def_map ,
3573
+ def_map : RefCell :: new ( resolver. def_map ) ,
3572
3574
freevars : resolver. freevars ,
3573
3575
maybe_unused_trait_imports : resolver. maybe_unused_trait_imports ,
3574
3576
export_map : resolver. export_map ,
0 commit comments