Skip to content

Commit 5e47cd4

Browse files
committed
Fix rebase
Move some code into `build_reduced_graph.rs` to keep `BuildReducedGraphVisitor` it private Also move the def collector call to `build_reduced_graph.rs`, it belongs there.
1 parent ab4cc2d commit 5e47cd4

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/librustc_resolve/build_reduced_graph.rs

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{ResolutionError, Determinacy, PathResult, CrateLint};
1616
use rustc::bug;
1717
use rustc::hir::def::{self, *};
1818
use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId};
19+
use rustc::hir::map::DefCollector;
1920
use rustc::ty;
2021
use rustc::middle::cstore::CrateStore;
2122
use rustc_metadata::cstore::LoadedMacro;
@@ -162,10 +163,20 @@ impl<'a> Resolver<'a> {
162163
crate fn build_reduced_graph(
163164
&mut self, fragment: &AstFragment, parent_scope: ParentScope<'a>
164165
) -> LegacyScope<'a> {
166+
fragment.visit_with(&mut DefCollector::new(&mut self.definitions, parent_scope.expansion));
165167
let mut visitor = BuildReducedGraphVisitor { r: self, parent_scope };
166168
fragment.visit_with(&mut visitor);
167169
visitor.parent_scope.legacy
168170
}
171+
172+
crate fn build_reduced_graph_external(&mut self, module: Module<'a>) {
173+
let def_id = module.def_id().expect("unpopulated module without a def-id");
174+
for child in self.cstore.item_children_untracked(def_id, self.session) {
175+
let child = child.map_id(|_| panic!("unexpected id"));
176+
BuildReducedGraphVisitor { r: self, parent_scope: ParentScope::module(module) }
177+
.build_reduced_graph_for_external_crate_res(child);
178+
}
179+
}
169180
}
170181

171182
struct BuildReducedGraphVisitor<'a, 'b> {

src/librustc_resolve/lib.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ use std::collections::BTreeSet;
5959
use rustc_data_structures::ptr_key::PtrKey;
6060
use rustc_data_structures::sync::Lrc;
6161

62-
use build_reduced_graph::BuildReducedGraphVisitor;
6362
use diagnostics::{Suggestion, ImportSuggestion};
6463
use diagnostics::{find_span_of_binding_until_next_binding, extend_span_to_previous_binding};
6564
use late::{PathSource, Rib, RibKind::*};
@@ -1261,12 +1260,7 @@ impl<'a> Resolver<'a> {
12611260
fn resolutions(&mut self, module: Module<'a>) -> &'a Resolutions<'a> {
12621261
if module.populate_on_access.get() {
12631262
module.populate_on_access.set(false);
1264-
let def_id = module.def_id().expect("unpopulated module without a def-id");
1265-
for child in self.cstore.item_children_untracked(def_id, self.session) {
1266-
let child = child.map_id(|_| panic!("unexpected id"));
1267-
BuildReducedGraphVisitor { parent_scope: self.dummy_parent_scope(), r: self }
1268-
.build_reduced_graph_for_external_crate_res(module, child);
1269-
}
1263+
self.build_reduced_graph_external(module);
12701264
}
12711265
&module.lazy_resolutions
12721266
}

src/librustc_resolve/macros.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::{ModuleOrUniformRoot, KNOWN_TOOLS};
88
use crate::Namespace::*;
99
use crate::resolve_imports::ImportResolver;
1010
use rustc::hir::def::{self, DefKind, NonMacroAttrKind};
11-
use rustc::hir::map::DefCollector;
1211
use rustc::middle::stability;
1312
use rustc::{ty, lint, span_bug};
1413
use syntax::ast::{self, Ident};
@@ -131,7 +130,6 @@ impl<'a> base::Resolver for Resolver<'a> {
131130
parent_scope.module.unresolved_invocations.borrow_mut().extend(derives);
132131

133132
// Integrate the new AST fragment into all the definition and module structures.
134-
fragment.visit_with(&mut DefCollector::new(&mut self.definitions, expansion));
135133
let output_legacy_scope = self.build_reduced_graph(fragment, parent_scope);
136134
self.output_legacy_scopes.insert(expansion, output_legacy_scope);
137135
}

0 commit comments

Comments
 (0)