@@ -326,6 +326,7 @@ impl ImportDirective {
326
326
}
327
327
328
328
/// The item that an import resolves to.
329
+ #[ deriving( Clone ) ]
329
330
struct Target {
330
331
target_module : @Module ,
331
332
bindings : @NameBindings ,
@@ -354,7 +355,7 @@ struct ImportResolution {
354
355
outstanding_references : Cell < uint > ,
355
356
356
357
/// The value that this `use` directive names, if there is one.
357
- value_target : Option < Target > ,
358
+ value_target : RefCell < Option < Target > > ,
358
359
/// The source node of the `use` directive leading to the value target
359
360
/// being non-none
360
361
value_id : NodeId ,
@@ -372,7 +373,7 @@ impl ImportResolution {
372
373
type_id : id,
373
374
value_id : id,
374
375
outstanding_references : Cell :: new ( 0 ) ,
375
- value_target : None ,
376
+ value_target : RefCell :: new ( None ) ,
376
377
type_target : None ,
377
378
is_public : Cell :: new ( is_public) ,
378
379
}
@@ -382,7 +383,7 @@ impl ImportResolution {
382
383
-> Option < Target > {
383
384
match namespace {
384
385
TypeNS => return self . type_target ,
385
- ValueNS => return self . value_target ,
386
+ ValueNS => return self . value_target . get ( ) ,
386
387
}
387
388
}
388
389
@@ -2418,8 +2419,8 @@ impl Resolver {
2418
2419
match value_result {
2419
2420
BoundResult ( target_module, name_bindings) => {
2420
2421
debug ! ( "(resolving single import) found value target" ) ;
2421
- import_resolution. value_target =
2422
- Some ( Target :: new ( target_module, name_bindings) ) ;
2422
+ import_resolution. value_target . set (
2423
+ Some ( Target :: new ( target_module, name_bindings) ) ) ;
2423
2424
import_resolution. value_id = directive. id ;
2424
2425
used_public = name_bindings. defined_in_public_namespace ( ValueNS ) ;
2425
2426
}
@@ -2443,7 +2444,7 @@ impl Resolver {
2443
2444
}
2444
2445
}
2445
2446
2446
- if import_resolution. value_target . is_none ( ) &&
2447
+ if import_resolution. value_target . get ( ) . is_none ( ) &&
2447
2448
import_resolution. type_target . is_none ( ) {
2448
2449
let msg = format ! ( "unresolved import: there is no \
2449
2450
`{}` in `{}`",
@@ -2461,7 +2462,7 @@ impl Resolver {
2461
2462
// record what this import resolves to for later uses in documentation,
2462
2463
// this may resolve to either a value or a type, but for documentation
2463
2464
// purposes it's good enough to just favor one over the other.
2464
- match import_resolution. value_target {
2465
+ match import_resolution. value_target . get ( ) {
2465
2466
Some ( target) => {
2466
2467
let def = target. bindings . def_for_namespace ( ValueNS ) . unwrap ( ) ;
2467
2468
self . def_map . insert ( directive. id , def) ;
@@ -2534,8 +2535,8 @@ impl Resolver {
2534
2535
// Simple: just copy the old import resolution.
2535
2536
let new_import_resolution =
2536
2537
@mut ImportResolution :: new ( id, is_public) ;
2537
- new_import_resolution. value_target =
2538
- target_import_resolution. value_target ;
2538
+ new_import_resolution. value_target . set (
2539
+ target_import_resolution. value_target . get ( ) ) ;
2539
2540
new_import_resolution. type_target =
2540
2541
target_import_resolution. type_target ;
2541
2542
@@ -2546,13 +2547,13 @@ impl Resolver {
2546
2547
// Merge the two import resolutions at a finer-grained
2547
2548
// level.
2548
2549
2549
- match target_import_resolution. value_target {
2550
+ match target_import_resolution. value_target . get ( ) {
2550
2551
None => {
2551
2552
// Continue.
2552
2553
}
2553
2554
Some ( value_target) => {
2554
- dest_import_resolution. value_target =
2555
- Some ( value_target) ;
2555
+ dest_import_resolution. value_target . set (
2556
+ Some ( value_target) ) ;
2556
2557
}
2557
2558
}
2558
2559
match target_import_resolution. type_target {
@@ -2595,8 +2596,8 @@ impl Resolver {
2595
2596
// Merge the child item into the import resolution.
2596
2597
if name_bindings. defined_in_public_namespace ( ValueNS ) {
2597
2598
debug ! ( "(resolving glob import) ... for value target" ) ;
2598
- dest_import_resolution. value_target =
2599
- Some ( Target :: new ( containing_module, name_bindings) ) ;
2599
+ dest_import_resolution. value_target . set (
2600
+ Some ( Target :: new ( containing_module, name_bindings) ) ) ;
2600
2601
dest_import_resolution. value_id = id;
2601
2602
}
2602
2603
if name_bindings. defined_in_public_namespace ( TypeNS ) {
0 commit comments