@@ -416,7 +416,7 @@ enum ModuleKind {
416
416
/// One node in the tree of modules.
417
417
struct Module {
418
418
parent_link : ParentLink ,
419
- def_id : Option < DefId > ,
419
+ def_id : Cell < Option < DefId > > ,
420
420
kind : Cell < ModuleKind > ,
421
421
is_public : bool ,
422
422
@@ -467,7 +467,7 @@ impl Module {
467
467
-> Module {
468
468
Module {
469
469
parent_link : parent_link,
470
- def_id : def_id,
470
+ def_id : Cell :: new ( def_id) ,
471
471
kind : Cell :: new ( kind) ,
472
472
is_public : is_public,
473
473
children : @mut HashMap :: new ( ) ,
@@ -668,7 +668,7 @@ impl NameBindings {
668
668
None => {
669
669
match type_def. module_def {
670
670
Some ( module) => {
671
- match module. def_id {
671
+ match module. def_id . get ( ) {
672
672
Some ( did) => Some ( DefMod ( did) ) ,
673
673
None => None ,
674
674
}
@@ -1591,7 +1591,7 @@ impl Resolver {
1591
1591
let is_public = vis == ast:: public;
1592
1592
let is_exported = is_public && match new_parent {
1593
1593
ModuleReducedGraphParent ( module) => {
1594
- match module. def_id {
1594
+ match module. def_id . get ( ) {
1595
1595
None => true ,
1596
1596
Some ( did) => self . external_exports . contains ( & did)
1597
1597
}
@@ -1607,7 +1607,7 @@ impl Resolver {
1607
1607
Some ( TypeNsDef { module_def : Some ( module_def) , .. } ) => {
1608
1608
debug ! ( "(building reduced graph for external crate) \
1609
1609
already created module") ;
1610
- module_def. def_id = Some ( def_id) ;
1610
+ module_def. def_id . set ( Some ( def_id) ) ;
1611
1611
}
1612
1612
Some ( _) | None => {
1613
1613
debug ! ( "(building reduced graph for \
@@ -1869,7 +1869,7 @@ impl Resolver {
1869
1869
debug ! ( "(populating external module) attempting to populate {}" ,
1870
1870
self . module_to_str( module) ) ;
1871
1871
1872
- let def_id = match module. def_id {
1872
+ let def_id = match module. def_id . get ( ) {
1873
1873
None => {
1874
1874
debug ! ( "(populating external module) ... no def ID!" ) ;
1875
1875
return
@@ -1904,7 +1904,10 @@ impl Resolver {
1904
1904
fn build_reduced_graph_for_external_crate ( & mut self ,
1905
1905
root : @mut Module ) {
1906
1906
csearch:: each_top_level_item_of_crate ( self . session . cstore ,
1907
- root. def_id . unwrap ( ) . crate ,
1907
+ root. def_id
1908
+ . get ( )
1909
+ . unwrap ( )
1910
+ . crate ,
1908
1911
|def_like, ident, visibility| {
1909
1912
self . build_reduced_graph_for_external_crate_def ( root,
1910
1913
def_like,
@@ -2568,7 +2571,7 @@ impl Resolver {
2568
2571
}
2569
2572
2570
2573
// Record the destination of this import
2571
- match containing_module. def_id {
2574
+ match containing_module. def_id . get ( ) {
2572
2575
Some ( did) => {
2573
2576
self . def_map . insert ( id, DefMod ( did) ) ;
2574
2577
self . last_private . insert ( id, lp) ;
@@ -2667,7 +2670,8 @@ impl Resolver {
2667
2670
// resolving this import chain.
2668
2671
if !used_proxy &&
2669
2672
!search_module. is_public {
2670
- match search_module. def_id {
2673
+ match search_module. def_id
2674
+ . get ( ) {
2671
2675
Some ( did) => {
2672
2676
closest_private =
2673
2677
DependsOn ( did) ;
@@ -2787,7 +2791,9 @@ impl Resolver {
2787
2791
Success ( PrefixFound ( containing_module, index) ) => {
2788
2792
search_module = containing_module;
2789
2793
start_index = index;
2790
- last_private = DependsOn ( containing_module. def_id . unwrap ( ) ) ;
2794
+ last_private = DependsOn ( containing_module. def_id
2795
+ . get ( )
2796
+ . unwrap ( ) ) ;
2791
2797
}
2792
2798
}
2793
2799
@@ -3196,7 +3202,7 @@ impl Resolver {
3196
3202
// If this isn't a local crate, then bail out. We don't need to record
3197
3203
// exports for nonlocal crates.
3198
3204
3199
- match module_. def_id {
3205
+ match module_. def_id . get ( ) {
3200
3206
Some ( def_id) if def_id. crate == LOCAL_CRATE => {
3201
3207
// OK. Continue.
3202
3208
debug ! ( "(recording exports for module subtree) recording \
@@ -3241,7 +3247,7 @@ impl Resolver {
3241
3247
let mut exports2 = ~[ ] ;
3242
3248
3243
3249
self . add_exports_for_module ( & mut exports2, module_) ;
3244
- match module_. def_id {
3250
+ match module_. def_id . get ( ) {
3245
3251
Some ( def_id) => {
3246
3252
self . export_map2 . insert ( def_id. node , exports2) ;
3247
3253
debug ! ( "(computing exports) writing exports for {} (some)" ,
@@ -4644,7 +4650,7 @@ impl Resolver {
4644
4650
match containing_module. external_module_children . find ( & name. name ) {
4645
4651
None => { }
4646
4652
Some ( module) => {
4647
- match module. def_id {
4653
+ match module. def_id . get ( ) {
4648
4654
None => { } // Continue.
4649
4655
Some ( def_id) => {
4650
4656
let lp = if module. is_public { AllPublic } else {
@@ -4707,7 +4713,7 @@ impl Resolver {
4707
4713
TraitModuleKind | ImplModuleKind => {
4708
4714
match self . method_map . find ( & ident. name ) {
4709
4715
Some ( s) => {
4710
- match containing_module. def_id {
4716
+ match containing_module. def_id . get ( ) {
4711
4717
Some ( def_id) if s. contains ( & def_id) => {
4712
4718
debug ! ( "containing module was a trait or impl \
4713
4719
and name was a method -> not resolved") ;
0 commit comments