Auto merge of #38539 - jseyfried:fix_resolve_hang, r=eddyb

resolve: fix non-termination

Fixes #34324.
r? @eddyb
This commit is contained in:
bors 2016-12-25 18:13:54 +00:00
commit 20b6c160ca
2 changed files with 5 additions and 2 deletions

View File

@ -2931,6 +2931,7 @@ impl<'a> Resolver<'a> {
let mut lookup_results = Vec::new(); let mut lookup_results = Vec::new();
let mut worklist = Vec::new(); let mut worklist = Vec::new();
let mut seen_modules = FxHashSet();
worklist.push((self.graph_root, Vec::new(), false)); worklist.push((self.graph_root, Vec::new(), false));
while let Some((in_module, while let Some((in_module,
@ -2976,7 +2977,7 @@ impl<'a> Resolver<'a> {
if !in_module_is_extern || name_binding.vis == ty::Visibility::Public { if !in_module_is_extern || name_binding.vis == ty::Visibility::Public {
// add the module to the lookup // add the module to the lookup
let is_extern = in_module_is_extern || name_binding.is_extern_crate(); let is_extern = in_module_is_extern || name_binding.is_extern_crate();
if !worklist.iter().any(|&(m, ..)| m.def() == module.def()) { if seen_modules.insert(module.def_id().unwrap()) {
worklist.push((module, path_segments, is_extern)); worklist.push((module, path_segments, is_extern));
} }
} }

View File

@ -10,6 +10,8 @@
// aux-build:recursive_reexports.rs // aux-build:recursive_reexports.rs
fn f() -> recursive_reexports::S {} //~ ERROR undeclared extern crate recursive_reexports;
fn f() -> recursive_reexports::S {} //~ ERROR type name `recursive_reexports::S` is undefined
fn main() {} fn main() {}