Skip to content

Commit 9071206

Browse files
committed
Add field module.unresolved_invocations.
1 parent ba872f2 commit 9071206

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,9 @@ pub struct BuildReducedGraphVisitor<'a, 'b: 'a> {
638638

639639
impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
640640
fn visit_invoc(&mut self, id: ast::NodeId) -> &'b InvocationData<'b> {
641-
let invocation = self.resolver.invocations[&Mark::from_placeholder_id(id)];
641+
let mark = Mark::from_placeholder_id(id);
642+
self.resolver.current_module.unresolved_invocations.borrow_mut().insert(mark);
643+
let invocation = self.resolver.invocations[&mark];
642644
invocation.module.set(self.resolver.current_module);
643645
invocation.legacy_scope.set(self.legacy_scope);
644646
invocation

src/librustc_resolve/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,9 @@ pub struct ModuleS<'a> {
799799

800800
resolutions: RefCell<FxHashMap<(Name, Namespace), &'a RefCell<NameResolution<'a>>>>,
801801

802+
// Macro invocations that can expand into items in this module.
803+
unresolved_invocations: RefCell<FxHashSet<Mark>>,
804+
802805
no_implicit_prelude: bool,
803806

804807
glob_importers: RefCell<Vec<&'a ImportDirective<'a>>>,
@@ -822,6 +825,7 @@ impl<'a> ModuleS<'a> {
822825
kind: kind,
823826
normal_ancestor_id: None,
824827
resolutions: RefCell::new(FxHashMap()),
828+
unresolved_invocations: RefCell::new(FxHashSet()),
825829
no_implicit_prelude: false,
826830
glob_importers: RefCell::new(Vec::new()),
827831
globs: RefCell::new((Vec::new())),

src/librustc_resolve/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ impl<'a> base::Resolver for Resolver<'a> {
131131
self.collect_def_ids(invocation, expansion);
132132

133133
self.current_module = invocation.module.get();
134+
self.current_module.unresolved_invocations.borrow_mut().remove(&mark);
134135
let mut visitor = BuildReducedGraphVisitor {
135136
resolver: self,
136137
legacy_scope: LegacyScope::Invocation(invocation),

src/librustc_resolve/resolve_imports.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'a> Resolver<'a> {
192192
}
193193

194194
// If the resolution doesn't depend on glob definability, check privacy and return.
195-
if let Some(result) = self.try_result(&resolution, ns) {
195+
if let Some(result) = self.try_result(&resolution, module, ns) {
196196
return result.and_then(|binding| {
197197
if self.is_accessible(binding.vis) && !is_disallowed_private_import(binding) ||
198198
binding.is_extern_crate() { // c.f. issue #37020
@@ -222,7 +222,7 @@ impl<'a> Resolver<'a> {
222222

223223
// Returns Some(the resolution of the name), or None if the resolution depends
224224
// on whether more globs can define the name.
225-
fn try_result(&mut self, resolution: &NameResolution<'a>, ns: Namespace)
225+
fn try_result(&mut self, resolution: &NameResolution<'a>, module: Module<'a>, ns: Namespace)
226226
-> Option<ResolveResult<&'a NameBinding<'a>>> {
227227
match resolution.binding {
228228
Some(binding) if !binding.is_glob_import() =>
@@ -250,6 +250,10 @@ impl<'a> Resolver<'a> {
250250
SingleImports::MaybeOne(_) | SingleImports::None => {},
251251
}
252252

253+
if !module.unresolved_invocations.borrow().is_empty() {
254+
return Some(Indeterminate);
255+
}
256+
253257
resolution.binding.map(Success)
254258
}
255259

0 commit comments

Comments
 (0)