Skip to content

Commit 5fe8411

Browse files
committed
librustc: De-@mut ImportResolution::value_target
1 parent aa5b422 commit 5fe8411

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/librustc/middle/resolve.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ impl ImportDirective {
326326
}
327327

328328
/// The item that an import resolves to.
329+
#[deriving(Clone)]
329330
struct Target {
330331
target_module: @Module,
331332
bindings: @NameBindings,
@@ -354,7 +355,7 @@ struct ImportResolution {
354355
outstanding_references: Cell<uint>,
355356

356357
/// The value that this `use` directive names, if there is one.
357-
value_target: Option<Target>,
358+
value_target: RefCell<Option<Target>>,
358359
/// The source node of the `use` directive leading to the value target
359360
/// being non-none
360361
value_id: NodeId,
@@ -372,7 +373,7 @@ impl ImportResolution {
372373
type_id: id,
373374
value_id: id,
374375
outstanding_references: Cell::new(0),
375-
value_target: None,
376+
value_target: RefCell::new(None),
376377
type_target: None,
377378
is_public: Cell::new(is_public),
378379
}
@@ -382,7 +383,7 @@ impl ImportResolution {
382383
-> Option<Target> {
383384
match namespace {
384385
TypeNS => return self.type_target,
385-
ValueNS => return self.value_target,
386+
ValueNS => return self.value_target.get(),
386387
}
387388
}
388389

@@ -2418,8 +2419,8 @@ impl Resolver {
24182419
match value_result {
24192420
BoundResult(target_module, name_bindings) => {
24202421
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)));
24232424
import_resolution.value_id = directive.id;
24242425
used_public = name_bindings.defined_in_public_namespace(ValueNS);
24252426
}
@@ -2443,7 +2444,7 @@ impl Resolver {
24432444
}
24442445
}
24452446

2446-
if import_resolution.value_target.is_none() &&
2447+
if import_resolution.value_target.get().is_none() &&
24472448
import_resolution.type_target.is_none() {
24482449
let msg = format!("unresolved import: there is no \
24492450
`{}` in `{}`",
@@ -2461,7 +2462,7 @@ impl Resolver {
24612462
// record what this import resolves to for later uses in documentation,
24622463
// this may resolve to either a value or a type, but for documentation
24632464
// 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() {
24652466
Some(target) => {
24662467
let def = target.bindings.def_for_namespace(ValueNS).unwrap();
24672468
self.def_map.insert(directive.id, def);
@@ -2534,8 +2535,8 @@ impl Resolver {
25342535
// Simple: just copy the old import resolution.
25352536
let new_import_resolution =
25362537
@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());
25392540
new_import_resolution.type_target =
25402541
target_import_resolution.type_target;
25412542

@@ -2546,13 +2547,13 @@ impl Resolver {
25462547
// Merge the two import resolutions at a finer-grained
25472548
// level.
25482549

2549-
match target_import_resolution.value_target {
2550+
match target_import_resolution.value_target.get() {
25502551
None => {
25512552
// Continue.
25522553
}
25532554
Some(value_target) => {
2554-
dest_import_resolution.value_target =
2555-
Some(value_target);
2555+
dest_import_resolution.value_target.set(
2556+
Some(value_target));
25562557
}
25572558
}
25582559
match target_import_resolution.type_target {
@@ -2595,8 +2596,8 @@ impl Resolver {
25952596
// Merge the child item into the import resolution.
25962597
if name_bindings.defined_in_public_namespace(ValueNS) {
25972598
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)));
26002601
dest_import_resolution.value_id = id;
26012602
}
26022603
if name_bindings.defined_in_public_namespace(TypeNS) {

0 commit comments

Comments
 (0)