Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Namespace::*;
use rustc_ast::{self as ast, NodeId};
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::{DefKind, MacroKinds, Namespace, NonMacroAttrKind, PartialRes, PerNS};
use rustc_middle::bug;
use rustc_middle::{bug, span_bug};
use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
use rustc_session::parse::feature_err;
use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext};
Expand Down Expand Up @@ -677,14 +677,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
innermost_binding,
binding,
)
|| flags.contains(Flags::MACRO_RULES)
&& innermost_flags.contains(Flags::MODULE)
&& !this.disambiguate_macro_rules_vs_modularized(
binding,
innermost_binding,
)
{
Some(AmbiguityKind::MacroRulesVsModularized)
} else if flags.contains(Flags::MACRO_RULES)
&& innermost_flags.contains(Flags::MODULE)
{
// should be impossible because of visitation order in
// visit_scopes
//
// we visit all macro_rules scopes (e.g. textual scope macros)
// before we visit any modules (e.g. path-based scope macros)
span_bug!(
orig_ident.span,
"ambiguous scoped macro resolutions with path-based \
scope resolution as first candidate"
)
} else if innermost_binding.is_glob_import() {
Some(AmbiguityKind::GlobVsOuter)
} else if innermost_binding
Expand Down
18 changes: 8 additions & 10 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2226,16 +2226,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// Some non-controversial subset of ambiguities "modularized macro name" vs "macro_rules"
// is disambiguated to mitigate regressions from macro modularization.
// Scoping for `macro_rules` behaves like scoping for `let` at module level, in general.
match (
self.binding_parent_modules.get(&macro_rules),
self.binding_parent_modules.get(&modularized),
) {
(Some(macro_rules), Some(modularized)) => {
macro_rules.nearest_parent_mod() == modularized.nearest_parent_mod()
&& modularized.is_ancestor_of(*macro_rules)
}
_ => false,
}
//
// panic on index should be impossible, the only name_bindings passed in should be from
// `resolve_ident_in_scope_set` which will always refer to a local binding from an
// import or macro definition
let macro_rules = &self.binding_parent_modules[&macro_rules];
let modularized = &self.binding_parent_modules[&modularized];
macro_rules.nearest_parent_mod() == modularized.nearest_parent_mod()
&& modularized.is_ancestor_of(*macro_rules)
}

fn extern_prelude_get_item<'r>(
Expand Down
Loading