Skip to content

Commit a308155

Browse files
committed
EII nameres changes
1 parent 8d05677 commit a308155

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
@@ -299,7 +299,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
299299
ignore_binding: Option<NameBinding<'ra>>,
300300
diag_metadata: Option<&DiagMetadata<'_>>,
301301
) -> Option<LexicalScopeBinding<'ra>> {
302-
assert!(ns == TypeNS || ns == ValueNS);
303302
let orig_ident = ident;
304303
let (general_span, normalized_span) = if ident.name == kw::SelfUpper {
305304
// 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
}
@@ -1061,6 +1068,12 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc
10611068
};
10621069
debug!("(resolving function) entering function");
10631070

1071+
if let FnKind::Fn(_, _, f) = fn_kind {
1072+
for EiiImpl { node_id, eii_macro_path, .. } in &f.eii_impls {
1073+
self.smart_resolve_path(*node_id, &None, &eii_macro_path, PathSource::Macro);
1074+
}
1075+
}
1076+
10641077
// Create a value rib for the function.
10651078
self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| {
10661079
// Create a label rib for the function.
@@ -2133,7 +2146,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
21332146
| PathSource::TraitItem(..)
21342147
| PathSource::Type
21352148
| PathSource::PreciseCapturingArg(..)
2136-
| PathSource::ReturnTypeNotation => false,
2149+
| PathSource::ReturnTypeNotation
2150+
| PathSource::Macro => false,
21372151
PathSource::Expr(..)
21382152
| PathSource::Pat
21392153
| 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)