@@ -420,7 +420,7 @@ struct Module {
420
420
is_public : bool ,
421
421
422
422
children : RefCell < HashMap < Name , @NameBindings > > ,
423
- imports : @ mut ~[ @ImportDirective ] ,
423
+ imports : RefCell < ~[ @ImportDirective ] > ,
424
424
425
425
// The external module children of this node that were declared with
426
426
// `extern mod`.
@@ -470,7 +470,7 @@ impl Module {
470
470
kind : Cell :: new ( kind) ,
471
471
is_public : is_public,
472
472
children : RefCell :: new ( HashMap :: new ( ) ) ,
473
- imports : @ mut ~[ ] ,
473
+ imports : RefCell :: new ( ~[ ] ) ,
474
474
external_module_children : RefCell :: new ( HashMap :: new ( ) ) ,
475
475
anonymous_children : RefCell :: new ( HashMap :: new ( ) ) ,
476
476
import_resolutions : RefCell :: new ( HashMap :: new ( ) ) ,
@@ -481,8 +481,8 @@ impl Module {
481
481
}
482
482
483
483
fn all_imports_resolved ( & self ) -> bool {
484
- let imports = & mut * self . imports ;
485
- return imports. len ( ) == self . resolved_import_count . get ( ) ;
484
+ let mut imports = self . imports . borrow_mut ( ) ;
485
+ return imports. get ( ) . len ( ) == self . resolved_import_count . get ( ) ;
486
486
}
487
487
}
488
488
@@ -1951,7 +1951,11 @@ impl Resolver {
1951
1951
let directive = @ImportDirective :: new ( module_path,
1952
1952
subclass, span, id,
1953
1953
is_public) ;
1954
- module_. imports . push ( directive) ;
1954
+
1955
+ {
1956
+ let mut imports = module_. imports . borrow_mut ( ) ;
1957
+ imports. get ( ) . push ( directive) ;
1958
+ }
1955
1959
1956
1960
// Bump the reference count on the name. Or, if this is a glob, set
1957
1961
// the appropriate flag.
@@ -2069,11 +2073,11 @@ impl Resolver {
2069
2073
return ;
2070
2074
}
2071
2075
2072
- let imports = & mut * module. imports ;
2073
- let import_count = imports. len ( ) ;
2076
+ let mut imports = module. imports . borrow_mut ( ) ;
2077
+ let import_count = imports. get ( ) . len ( ) ;
2074
2078
while module. resolved_import_count . get ( ) < import_count {
2075
2079
let import_index = module. resolved_import_count . get ( ) ;
2076
- let import_directive = imports[ import_index] ;
2080
+ let import_directive = imports. get ( ) [ import_index] ;
2077
2081
match self . resolve_import_for_module ( module, import_directive) {
2078
2082
Failed => {
2079
2083
// We presumably emitted an error. Continue.
@@ -2149,7 +2153,7 @@ impl Resolver {
2149
2153
fn resolve_import_for_module(&mut self,
2150
2154
module_: @Module,
2151
2155
import_directive: @ImportDirective)
2152
- -> ResolveResult<()> {
2156
+ -> ResolveResult<()> {
2153
2157
let mut resolution_result = Failed;
2154
2158
let module_path = &import_directive.module_path;
2155
2159
@@ -3230,16 +3234,20 @@ impl Resolver {
3230
3234
3231
3235
fn report_unresolved_imports ( & mut self , module_ : @Module ) {
3232
3236
let index = module_. resolved_import_count . get ( ) ;
3233
- let imports : & mut ~ [ @ ImportDirective ] = & mut * module_. imports ;
3234
- let import_count = imports. len ( ) ;
3237
+ let mut imports = module_. imports . borrow_mut ( ) ;
3238
+ let import_count = imports. get ( ) . len ( ) ;
3235
3239
if index != import_count {
3236
- let sn = self . session . codemap . span_to_snippet ( imports[ index] . span ) . unwrap ( ) ;
3240
+ let sn = self . session
3241
+ . codemap
3242
+ . span_to_snippet ( imports. get ( ) [ index] . span )
3243
+ . unwrap ( ) ;
3237
3244
if sn. contains ( "::" ) {
3238
- self . resolve_error ( imports[ index] . span , "unresolved import" ) ;
3245
+ self . resolve_error ( imports. get ( ) [ index] . span ,
3246
+ "unresolved import" ) ;
3239
3247
} else {
3240
3248
let err = format ! ( "unresolved import (maybe you meant `{}::*`?)" ,
3241
3249
sn. slice( 0 , sn. len( ) ) ) ;
3242
- self . resolve_error ( imports[ index] . span , err) ;
3250
+ self . resolve_error ( imports. get ( ) [ index] . span , err) ;
3243
3251
}
3244
3252
}
3245
3253
0 commit comments