Skip to content

Commit 0bed9ae

Browse files
committed
Make populate_module_if_necessary a method of resolver
1 parent 77f0f4a commit 0bed9ae

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,6 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
532532
}
533533
}
534534

535-
/// Ensures that the reduced graph rooted at the given external module
536-
/// is built, building it if it is not.
537-
fn populate_module_if_necessary(&mut self, module: Module<'b>) {
538-
if module.populated.get() { return }
539-
for child in self.session.cstore.item_children(module.def_id().unwrap()) {
540-
self.build_reduced_graph_for_external_crate_def(module, child);
541-
}
542-
module.populated.set(true)
543-
}
544-
545535
/// Builds the reduced graph rooted at the 'use' directive for an external
546536
/// crate.
547537
fn build_reduced_graph_for_external_crate(&mut self, root: Module<'b>) {
@@ -585,6 +575,19 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
585575
}
586576
}
587577

578+
impl<'a, 'tcx> Resolver<'a, 'tcx> {
579+
/// Ensures that the reduced graph rooted at the given external module
580+
/// is built, building it if it is not.
581+
pub fn populate_module_if_necessary(&mut self, module: Module<'a>) {
582+
if module.populated.get() { return }
583+
let mut builder = GraphBuilder { resolver: self };
584+
for child in self.session.cstore.item_children(module.def_id().unwrap()) {
585+
builder.build_reduced_graph_for_external_crate_def(module, child);
586+
}
587+
module.populated.set(true)
588+
}
589+
}
590+
588591
struct BuildReducedGraphVisitor<'a, 'b: 'a, 'tcx: 'b> {
589592
builder: GraphBuilder<'a, 'b, 'tcx>,
590593
parent: Module<'b>,
@@ -617,8 +620,3 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
617620
pub fn build_reduced_graph(resolver: &mut Resolver, krate: &hir::Crate) {
618621
GraphBuilder { resolver: resolver }.build_reduced_graph(krate);
619622
}
620-
621-
pub fn populate_module_if_necessary<'a, 'tcx>(resolver: &mut Resolver<'a, 'tcx>,
622-
module: Module<'a>) {
623-
GraphBuilder { resolver: resolver }.populate_module_if_necessary(module);
624-
}

src/librustc_resolve/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15421542
-> ResolveResult<&'a NameBinding<'a>> {
15431543
debug!("(resolving name in module) resolving `{}` in `{}`", name, module_to_string(module));
15441544

1545-
build_reduced_graph::populate_module_if_necessary(self, module);
1545+
self.populate_module_if_necessary(module);
15461546
match use_lexical_scope {
15471547
true => module.resolve_name_in_lexical_scope(name, namespace)
15481548
.map(Success).unwrap_or(Failed(None)),
@@ -3363,7 +3363,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33633363
while let Some((in_module,
33643364
path_segments,
33653365
in_module_is_extern)) = worklist.pop() {
3366-
build_reduced_graph::populate_module_if_necessary(self, &in_module);
3366+
self.populate_module_if_necessary(in_module);
33673367

33683368
in_module.for_each_child(|name, ns, name_binding| {
33693369

src/librustc_resolve/resolve_imports.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use UseLexicalScopeFlag;
2121
use {names_to_string, module_to_string};
2222
use {resolve_error, ResolutionError};
2323

24-
use build_reduced_graph;
25-
2624
use rustc::lint;
2725
use rustc::middle::def::*;
2826

@@ -610,7 +608,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
610608
let msg = "Cannot glob-import a module into itself.".into();
611609
return Failed(Some((directive.span, msg)));
612610
}
613-
build_reduced_graph::populate_module_if_necessary(self.resolver, target_module);
611+
self.resolver.populate_module_if_necessary(target_module);
614612

615613
if directive.is_prelude {
616614
*module_.prelude.borrow_mut() = Some(target_module);

0 commit comments

Comments
 (0)