Skip to content

Commit a1ee381

Browse files
committed
librustc: De-@mut resolve::Module::kind
1 parent 7522838 commit a1ee381

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/librustc/middle/resolve.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use syntax::opt_vec::OptVec;
2929
use syntax::visit;
3030
use syntax::visit::Visitor;
3131

32+
use std::cell::Cell;
3233
use std::uint;
3334
use std::hashmap::{HashMap, HashSet};
3435
use std::util;
@@ -416,7 +417,7 @@ enum ModuleKind {
416417
struct Module {
417418
parent_link: ParentLink,
418419
def_id: Option<DefId>,
419-
kind: ModuleKind,
420+
kind: Cell<ModuleKind>,
420421
is_public: bool,
421422

422423
children: @mut HashMap<Name, @mut NameBindings>,
@@ -463,11 +464,11 @@ impl Module {
463464
kind: ModuleKind,
464465
external: bool,
465466
is_public: bool)
466-
-> Module {
467+
-> Module {
467468
Module {
468469
parent_link: parent_link,
469470
def_id: def_id,
470-
kind: kind,
471+
kind: Cell::new(kind),
471472
is_public: is_public,
472473
children: @mut HashMap::new(),
473474
imports: @mut ~[],
@@ -581,7 +582,7 @@ impl NameBindings {
581582
type_span: None,
582583
})
583584
}
584-
Some(module_def) => module_def.kind = kind,
585+
Some(module_def) => module_def.kind.set(kind),
585586
}
586587
}
587588
}
@@ -1238,7 +1239,7 @@ impl Resolver {
12381239
// It already exists
12391240
Some(&child) if child.get_module_if_available()
12401241
.is_some() &&
1241-
child.get_module().kind ==
1242+
child.get_module().kind.get() ==
12421243
ImplModuleKind => {
12431244
ModuleReducedGraphParent(child.get_module())
12441245
}
@@ -1805,7 +1806,7 @@ impl Resolver {
18051806

18061807
// Mark it as an impl module if
18071808
// necessary.
1808-
type_module.kind = ImplModuleKind;
1809+
type_module.kind.set(ImplModuleKind);
18091810
}
18101811
Some(_) | None => {
18111812
let parent_link =
@@ -2649,7 +2650,7 @@ impl Resolver {
26492650
// import, do not allow traits and impls
26502651
// to be selected.
26512652
match (name_search_type,
2652-
module_def.kind) {
2653+
module_def.kind.get()) {
26532654
(ImportSearch, TraitModuleKind) |
26542655
(ImportSearch, ImplModuleKind) => {
26552656
self.resolve_error(
@@ -2879,7 +2880,7 @@ impl Resolver {
28792880
ModuleParentLink(parent_module_node, _) => {
28802881
match search_through_modules {
28812882
DontSearchThroughModules => {
2882-
match search_module.kind {
2883+
match search_module.kind.get() {
28832884
NormalModuleKind => {
28842885
// We stop the search here.
28852886
debug!("(resolving item in lexical \
@@ -2987,7 +2988,7 @@ impl Resolver {
29872988
NoParentLink => return None,
29882989
ModuleParentLink(new_module, _) |
29892990
BlockParentLink(new_module, _) => {
2990-
match new_module.kind {
2991+
match new_module.kind.get() {
29912992
NormalModuleKind => return Some(new_module),
29922993
ExternModuleKind |
29932994
TraitModuleKind |
@@ -3004,7 +3005,7 @@ impl Resolver {
30043005
fn get_nearest_normal_module_parent_or_self(&mut self,
30053006
module_: @mut Module)
30063007
-> @mut Module {
3007-
match module_.kind {
3008+
match module_.kind.get() {
30083009
NormalModuleKind => return module_,
30093010
ExternModuleKind |
30103011
TraitModuleKind |
@@ -4702,7 +4703,7 @@ impl Resolver {
47024703
(def, last_private.or(lp))
47034704
}
47044705
};
4705-
match containing_module.kind {
4706+
match containing_module.kind.get() {
47064707
TraitModuleKind | ImplModuleKind => {
47074708
match self.method_map.find(&ident.name) {
47084709
Some(s) => {

0 commit comments

Comments
 (0)