Skip to content

Commit 3a4fc9d

Browse files
committed
---
yaml --- r: 147630 b: refs/heads/try2 c: 992696f h: refs/heads/master v: v3
1 parent b5fa2c0 commit 3a4fc9d

File tree

2 files changed

+47
-22
lines changed

2 files changed

+47
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 8ee8d2b4b9c1805aef1407d7b8ca476d1490ffa1
8+
refs/heads/try2: 992696fd2793f73c3ccc63df1d88650cfabff8c4
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ struct Module {
442442
anonymous_children: RefCell<HashMap<NodeId,@Module>>,
443443

444444
// The status of resolving each import in this module.
445-
import_resolutions: @mut HashMap<Name, @mut ImportResolution>,
445+
import_resolutions: RefCell<HashMap<Name, @mut ImportResolution>>,
446446

447447
// The number of unresolved globs that this module exports.
448448
glob_count: Cell<uint>,
@@ -472,7 +472,7 @@ impl Module {
472472
imports: @mut ~[],
473473
external_module_children: RefCell::new(HashMap::new()),
474474
anonymous_children: RefCell::new(HashMap::new()),
475-
import_resolutions: @mut HashMap::new(),
475+
import_resolutions: RefCell::new(HashMap::new()),
476476
glob_count: Cell::new(0),
477477
resolved_import_count: Cell::new(0),
478478
populated: Cell::new(!external),
@@ -1951,7 +1951,9 @@ impl Resolver {
19511951
self.idents_to_str(directive.module_path),
19521952
self.session.str_of(target));
19531953

1954-
match module_.import_resolutions.find(&target.name) {
1954+
let mut import_resolutions = module_.import_resolutions
1955+
.borrow_mut();
1956+
match import_resolutions.get().find(&target.name) {
19551957
Some(&resolution) => {
19561958
debug!("(building import directive) bumping \
19571959
reference");
@@ -1965,7 +1967,8 @@ impl Resolver {
19651967
debug!("(building import directive) creating new");
19661968
let resolution = @mut ImportResolution::new(id, is_public);
19671969
resolution.outstanding_references = 1;
1968-
module_.import_resolutions.insert(target.name, resolution);
1970+
import_resolutions.get().insert(target.name,
1971+
resolution);
19691972
}
19701973
}
19711974
}
@@ -2290,7 +2293,9 @@ impl Resolver {
22902293
// Now search the exported imports within the containing
22912294
// module.
22922295

2293-
match containing_module.import_resolutions.find(&source.name) {
2296+
let import_resolutions = containing_module.import_resolutions
2297+
.borrow();
2298+
match import_resolutions.get().find(&source.name) {
22942299
None => {
22952300
// The containing module definitely doesn't have an
22962301
// exported import with the name in question. We can
@@ -2385,8 +2390,11 @@ impl Resolver {
23852390
}
23862391

23872392
// We've successfully resolved the import. Write the results in.
2388-
assert!(module_.import_resolutions.contains_key(&target.name));
2389-
let import_resolution = module_.import_resolutions.get(&target.name);
2393+
let import_resolution = {
2394+
let import_resolutions = module_.import_resolutions.borrow();
2395+
assert!(import_resolutions.get().contains_key(&target.name));
2396+
import_resolutions.get().get_copy(&target.name)
2397+
};
23902398

23912399
match value_result {
23922400
BoundResult(target_module, name_bindings) => {
@@ -2484,8 +2492,10 @@ impl Resolver {
24842492
assert_eq!(containing_module.glob_count.get(), 0);
24852493

24862494
// Add all resolved imports from the containing module.
2487-
for (ident, target_import_resolution) in containing_module.import_resolutions.iter() {
2488-
2495+
let import_resolutions = containing_module.import_resolutions
2496+
.borrow();
2497+
for (ident, target_import_resolution) in import_resolutions.get()
2498+
.iter() {
24892499
debug!("(resolving glob import) writing module resolution \
24902500
{:?} into `{}`",
24912501
target_import_resolution.type_target.is_none(),
@@ -2497,7 +2507,9 @@ impl Resolver {
24972507
}
24982508

24992509
// Here we merge two import resolutions.
2500-
match module_.import_resolutions.find(ident) {
2510+
let mut import_resolutions = module_.import_resolutions
2511+
.borrow_mut();
2512+
match import_resolutions.get().find(ident) {
25012513
None => {
25022514
// Simple: just copy the old import resolution.
25032515
let new_import_resolution =
@@ -2507,7 +2519,7 @@ impl Resolver {
25072519
new_import_resolution.type_target =
25082520
target_import_resolution.type_target;
25092521

2510-
module_.import_resolutions.insert
2522+
import_resolutions.get().insert
25112523
(*ident, new_import_resolution);
25122524
}
25132525
Some(&dest_import_resolution) => {
@@ -2539,13 +2551,15 @@ impl Resolver {
25392551

25402552
let merge_import_resolution = |name, name_bindings: @NameBindings| {
25412553
let dest_import_resolution;
2542-
match module_.import_resolutions.find(&name) {
2554+
let mut import_resolutions = module_.import_resolutions
2555+
.borrow_mut();
2556+
match import_resolutions.get().find(&name) {
25432557
None => {
25442558
// Create a new import resolution from this child.
25452559
dest_import_resolution = @mut ImportResolution::new(id,
25462560
is_public);
2547-
module_.import_resolutions.insert
2548-
(name, dest_import_resolution);
2561+
import_resolutions.get().insert(name,
2562+
dest_import_resolution);
25492563
}
25502564
Some(&existing_import_resolution) => {
25512565
dest_import_resolution = existing_import_resolution;
@@ -2857,7 +2871,8 @@ impl Resolver {
28572871
// all its imports in the usual way; this is because chains of
28582872
// adjacent import statements are processed as though they mutated the
28592873
// current scope.
2860-
match module_.import_resolutions.find(&name.name) {
2874+
let import_resolutions = module_.import_resolutions.borrow();
2875+
match import_resolutions.get().find(&name.name) {
28612876
None => {
28622877
// Not found; continue.
28632878
}
@@ -3130,7 +3145,8 @@ impl Resolver {
31303145
}
31313146

31323147
// Check the list of resolved imports.
3133-
match module_.import_resolutions.find(&name.name) {
3148+
let import_resolutions = module_.import_resolutions.borrow();
3149+
match import_resolutions.get().find(&name.name) {
31343150
Some(import_resolution) => {
31353151
if import_resolution.is_public &&
31363152
import_resolution.outstanding_references != 0 {
@@ -3315,8 +3331,11 @@ impl Resolver {
33153331
fn add_exports_for_module(&mut self,
33163332
exports2: &mut ~[Export2],
33173333
module_: @Module) {
3318-
for (name, importresolution) in module_.import_resolutions.iter() {
3319-
if !importresolution.is_public { continue }
3334+
let import_resolutions = module_.import_resolutions.borrow();
3335+
for (name, importresolution) in import_resolutions.get().iter() {
3336+
if !importresolution.is_public {
3337+
continue
3338+
}
33203339
let xs = [TypeNS, ValueNS];
33213340
for &ns in xs.iter() {
33223341
match importresolution.target_for_namespace(ns) {
@@ -4673,7 +4692,9 @@ impl Resolver {
46734692
}
46744693

46754694
// Next, search import resolutions.
4676-
match containing_module.import_resolutions.find(&name.name) {
4695+
let import_resolutions = containing_module.import_resolutions
4696+
.borrow();
4697+
match import_resolutions.get().find(&name.name) {
46774698
Some(import_resolution) if import_resolution.is_public => {
46784699
match (*import_resolution).target_for_namespace(namespace) {
46794700
Some(target) => {
@@ -5300,7 +5321,10 @@ impl Resolver {
53005321
}
53015322

53025323
// Look for imports.
5303-
for (_, &import_resolution) in search_module.import_resolutions.iter() {
5324+
let import_resolutions = search_module.import_resolutions
5325+
.borrow();
5326+
for (_, &import_resolution) in import_resolutions.get()
5327+
.iter() {
53045328
match import_resolution.target_for_namespace(TypeNS) {
53055329
None => {
53065330
// Continue.
@@ -5493,7 +5517,8 @@ impl Resolver {
54935517
}
54945518

54955519
debug!("Import resolutions:");
5496-
for (name, import_resolution) in module_.import_resolutions.iter() {
5520+
let import_resolutions = module_.import_resolutions.borrow();
5521+
for (name, import_resolution) in import_resolutions.get().iter() {
54975522
let value_repr;
54985523
match import_resolution.target_for_namespace(ValueNS) {
54995524
None => { value_repr = ~""; }

0 commit comments

Comments
 (0)