Skip to content

Commit

Permalink
Fix rebase
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petrochenkov committed Aug 16, 2019
1 parent ab4cc2d commit 5e47cd4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
11 changes: 11 additions & 0 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{ResolutionError, Determinacy, PathResult, CrateLint};
use rustc::bug;
use rustc::hir::def::{self, *};
use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId};
use rustc::hir::map::DefCollector;
use rustc::ty;
use rustc::middle::cstore::CrateStore;
use rustc_metadata::cstore::LoadedMacro;
Expand Down Expand Up @@ -162,10 +163,20 @@ impl<'a> Resolver<'a> {
crate fn build_reduced_graph(
&mut self, fragment: &AstFragment, parent_scope: ParentScope<'a>
) -> LegacyScope<'a> {
fragment.visit_with(&mut DefCollector::new(&mut self.definitions, parent_scope.expansion));
let mut visitor = BuildReducedGraphVisitor { r: self, parent_scope };
fragment.visit_with(&mut visitor);
visitor.parent_scope.legacy
}

crate fn build_reduced_graph_external(&mut self, module: Module<'a>) {
let def_id = module.def_id().expect("unpopulated module without a def-id");
for child in self.cstore.item_children_untracked(def_id, self.session) {
let child = child.map_id(|_| panic!("unexpected id"));
BuildReducedGraphVisitor { r: self, parent_scope: ParentScope::module(module) }
.build_reduced_graph_for_external_crate_res(child);
}
}
}

struct BuildReducedGraphVisitor<'a, 'b> {
Expand Down
8 changes: 1 addition & 7 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ use std::collections::BTreeSet;
use rustc_data_structures::ptr_key::PtrKey;
use rustc_data_structures::sync::Lrc;

use build_reduced_graph::BuildReducedGraphVisitor;
use diagnostics::{Suggestion, ImportSuggestion};
use diagnostics::{find_span_of_binding_until_next_binding, extend_span_to_previous_binding};
use late::{PathSource, Rib, RibKind::*};
Expand Down Expand Up @@ -1261,12 +1260,7 @@ impl<'a> Resolver<'a> {
fn resolutions(&mut self, module: Module<'a>) -> &'a Resolutions<'a> {
if module.populate_on_access.get() {
module.populate_on_access.set(false);
let def_id = module.def_id().expect("unpopulated module without a def-id");
for child in self.cstore.item_children_untracked(def_id, self.session) {
let child = child.map_id(|_| panic!("unexpected id"));
BuildReducedGraphVisitor { parent_scope: self.dummy_parent_scope(), r: self }
.build_reduced_graph_for_external_crate_res(module, child);
}
self.build_reduced_graph_external(module);
}
&module.lazy_resolutions
}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::{ModuleOrUniformRoot, KNOWN_TOOLS};
use crate::Namespace::*;
use crate::resolve_imports::ImportResolver;
use rustc::hir::def::{self, DefKind, NonMacroAttrKind};
use rustc::hir::map::DefCollector;
use rustc::middle::stability;
use rustc::{ty, lint, span_bug};
use syntax::ast::{self, Ident};
Expand Down Expand Up @@ -131,7 +130,6 @@ impl<'a> base::Resolver for Resolver<'a> {
parent_scope.module.unresolved_invocations.borrow_mut().extend(derives);

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

0 comments on commit 5e47cd4

Please sign in to comment.