Skip to content

Commit 59d50cd

Browse files
committed
EII nameres changes
1 parent 3d38d9f commit 59d50cd

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
314314
ignore_binding: Option<NameBinding<'ra>>,
315315
diag_metadata: Option<&DiagMetadata<'_>>,
316316
) -> Option<LexicalScopeBinding<'ra>> {
317-
assert!(ns == TypeNS || ns == ValueNS);
318317
let orig_ident = ident;
319318
let (general_span, normalized_span) = if ident.name == kw::SelfUpper {
320319
// FIXME(jseyfried) improve `Self` hygiene

compiler/rustc_resolve/src/late.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ pub(crate) enum PathSource<'a, 'ast, 'ra> {
447447
ReturnTypeNotation,
448448
/// Paths from `#[define_opaque]` attributes
449449
DefineOpaques,
450+
/// Resolving a macro
451+
Macro,
450452
}
451453

452454
impl PathSource<'_, '_, '_> {
@@ -463,6 +465,7 @@ impl PathSource<'_, '_, '_> {
463465
| PathSource::ReturnTypeNotation => ValueNS,
464466
PathSource::TraitItem(ns, _) => ns,
465467
PathSource::PreciseCapturingArg(ns) => ns,
468+
PathSource::Macro => MacroNS,
466469
}
467470
}
468471

@@ -478,7 +481,8 @@ impl PathSource<'_, '_, '_> {
478481
| PathSource::TraitItem(..)
479482
| PathSource::DefineOpaques
480483
| PathSource::Delegation
481-
| PathSource::PreciseCapturingArg(..) => false,
484+
| PathSource::PreciseCapturingArg(..)
485+
| PathSource::Macro => false,
482486
}
483487
}
484488

@@ -520,6 +524,7 @@ impl PathSource<'_, '_, '_> {
520524
},
521525
PathSource::ReturnTypeNotation | PathSource::Delegation => "function",
522526
PathSource::PreciseCapturingArg(..) => "type or const parameter",
527+
PathSource::Macro => "macro",
523528
}
524529
}
525530

@@ -614,6 +619,7 @@ impl PathSource<'_, '_, '_> {
614619
Res::Def(DefKind::TyParam, _) | Res::SelfTyParam { .. } | Res::SelfTyAlias { .. }
615620
),
616621
PathSource::PreciseCapturingArg(MacroNS) => false,
622+
PathSource::Macro => matches!(res, Res::Def(DefKind::Macro(_), _)),
617623
}
618624
}
619625

@@ -633,6 +639,7 @@ impl PathSource<'_, '_, '_> {
633639
(PathSource::TraitItem(..) | PathSource::ReturnTypeNotation, false) => E0576,
634640
(PathSource::PreciseCapturingArg(..), true) => E0799,
635641
(PathSource::PreciseCapturingArg(..), false) => E0800,
642+
(PathSource::Macro, _) => E0425,
636643
}
637644
}
638645
}
@@ -1058,6 +1065,12 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc
10581065
};
10591066
debug!("(resolving function) entering function");
10601067

1068+
if let FnKind::Fn(_, _, f) = fn_kind {
1069+
for EiiImpl { node_id, eii_macro_path, .. } in &f.eii_impls {
1070+
self.smart_resolve_path(*node_id, &None, &eii_macro_path, PathSource::Macro);
1071+
}
1072+
}
1073+
10611074
// Create a value rib for the function.
10621075
self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| {
10631076
// Create a label rib for the function.
@@ -2130,7 +2143,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
21302143
| PathSource::TraitItem(..)
21312144
| PathSource::Type
21322145
| PathSource::PreciseCapturingArg(..)
2133-
| PathSource::ReturnTypeNotation => false,
2146+
| PathSource::ReturnTypeNotation
2147+
| PathSource::Macro => false,
21342148
PathSource::Expr(..)
21352149
| PathSource::Pat
21362150
| PathSource::Struct(_)
@@ -2887,6 +2901,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
28872901
let def_id = self.r.local_def_id(item.id);
28882902
self.parent_scope.macro_rules = self.r.macro_rules_scopes[&def_id];
28892903
}
2904+
2905+
if let Some(EiiExternTarget { extern_item_path, impl_unsafe: _, span: _ }) =
2906+
&macro_def.eii_extern_target
2907+
{
2908+
self.smart_resolve_path(
2909+
item.id,
2910+
&None,
2911+
extern_item_path,
2912+
PathSource::Expr(None),
2913+
);
2914+
}
28902915
}
28912916

28922917
ItemKind::ForeignMod(_) | ItemKind::GlobalAsm(_) => {

0 commit comments

Comments
 (0)