提交 6db9a8c5 编写于 作者: P Patrick Walton

librustc: De-`@mut` `resolve::Module::def_id`

上级 d503fff2
......@@ -416,7 +416,7 @@ enum ModuleKind {
/// One node in the tree of modules.
struct Module {
parent_link: ParentLink,
def_id: Option<DefId>,
def_id: Cell<Option<DefId>>,
kind: Cell<ModuleKind>,
is_public: bool,
......@@ -467,7 +467,7 @@ fn new(parent_link: ParentLink,
-> Module {
Module {
parent_link: parent_link,
def_id: def_id,
def_id: Cell::new(def_id),
kind: Cell::new(kind),
is_public: is_public,
children: @mut HashMap::new(),
......@@ -668,7 +668,7 @@ fn def_for_namespace(&self, namespace: Namespace) -> Option<Def> {
None => {
match type_def.module_def {
Some(module) => {
match module.def_id {
match module.def_id.get() {
Some(did) => Some(DefMod(did)),
None => None,
}
......@@ -1591,7 +1591,7 @@ fn handle_external_def(&mut self,
let is_public = vis == ast::public;
let is_exported = is_public && match new_parent {
ModuleReducedGraphParent(module) => {
match module.def_id {
match module.def_id.get() {
None => true,
Some(did) => self.external_exports.contains(&did)
}
......@@ -1607,7 +1607,7 @@ fn handle_external_def(&mut self,
Some(TypeNsDef { module_def: Some(module_def), .. }) => {
debug!("(building reduced graph for external crate) \
already created module");
module_def.def_id = Some(def_id);
module_def.def_id.set(Some(def_id));
}
Some(_) | None => {
debug!("(building reduced graph for \
......@@ -1869,7 +1869,7 @@ fn populate_external_module(&mut self, module: @mut Module) {
debug!("(populating external module) attempting to populate {}",
self.module_to_str(module));
let def_id = match module.def_id {
let def_id = match module.def_id.get() {
None => {
debug!("(populating external module) ... no def ID!");
return
......@@ -1904,7 +1904,10 @@ fn populate_module_if_necessary(&mut self, module: @mut Module) {
fn build_reduced_graph_for_external_crate(&mut self,
root: @mut Module) {
csearch::each_top_level_item_of_crate(self.session.cstore,
root.def_id.unwrap().crate,
root.def_id
.get()
.unwrap()
.crate,
|def_like, ident, visibility| {
self.build_reduced_graph_for_external_crate_def(root,
def_like,
......@@ -2568,7 +2571,7 @@ fn resolve_glob_import(&mut self,
}
// Record the destination of this import
match containing_module.def_id {
match containing_module.def_id.get() {
Some(did) => {
self.def_map.insert(id, DefMod(did));
self.last_private.insert(id, lp);
......@@ -2667,7 +2670,8 @@ fn resolve_module_path_from_root(&mut self,
// resolving this import chain.
if !used_proxy &&
!search_module.is_public {
match search_module.def_id {
match search_module.def_id
.get() {
Some(did) => {
closest_private =
DependsOn(did);
......@@ -2787,7 +2791,9 @@ fn resolve_module_path(&mut self,
Success(PrefixFound(containing_module, index)) => {
search_module = containing_module;
start_index = index;
last_private = DependsOn(containing_module.def_id.unwrap());
last_private = DependsOn(containing_module.def_id
.get()
.unwrap());
}
}
......@@ -3196,7 +3202,7 @@ fn record_exports_for_module_subtree(&mut self,
// If this isn't a local crate, then bail out. We don't need to record
// exports for nonlocal crates.
match module_.def_id {
match module_.def_id.get() {
Some(def_id) if def_id.crate == LOCAL_CRATE => {
// OK. Continue.
debug!("(recording exports for module subtree) recording \
......@@ -3241,7 +3247,7 @@ fn record_exports_for_module(&mut self, module_: @mut Module) {
let mut exports2 = ~[];
self.add_exports_for_module(&mut exports2, module_);
match module_.def_id {
match module_.def_id.get() {
Some(def_id) => {
self.export_map2.insert(def_id.node, exports2);
debug!("(computing exports) writing exports for {} (some)",
......@@ -4644,7 +4650,7 @@ fn resolve_definition_of_name_in_module(&mut self,
match containing_module.external_module_children.find(&name.name) {
None => {}
Some(module) => {
match module.def_id {
match module.def_id.get() {
None => {} // Continue.
Some(def_id) => {
let lp = if module.is_public {AllPublic} else {
......@@ -4707,7 +4713,7 @@ fn resolve_module_relative_path(&mut self,
TraitModuleKind | ImplModuleKind => {
match self.method_map.find(&ident.name) {
Some(s) => {
match containing_module.def_id {
match containing_module.def_id.get() {
Some(def_id) if s.contains(&def_id) => {
debug!("containing module was a trait or impl \
and name was a method -> not resolved");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册