Remove MacroKind::ProcMacroStub
It's internal to resolve and always results in `Res::Err` outside of resolve. Instead put `DefKind::Fn`s themselves into the macro namespace, it's ok. Proc macro stubs are items placed into macro namespase for functions that define proc macros. https://github.com/rust-lang/rust/pull/52383 The rustdoc test is changed because the old test didn't actually reproduce the ICE it was supposed to reproduce.
This commit is contained in:
parent
c6a9e766f9
commit
48635226d8
10 changed files with 35 additions and 53 deletions
|
|
@ -4199,7 +4199,6 @@ pub fn register_res(cx: &DocContext<'_>, res: Res) -> DefId {
|
|||
MacroKind::Bang => (i, TypeKind::Macro),
|
||||
MacroKind::Attr => (i, TypeKind::Attr),
|
||||
MacroKind::Derive => (i, TypeKind::Derive),
|
||||
MacroKind::ProcMacroStub => unreachable!(),
|
||||
},
|
||||
Res::Def(DefKind::TraitAlias, i) => (i, TypeKind::TraitAlias),
|
||||
Res::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait),
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ impl<'a> From<&'a clean::Item> for ItemType {
|
|||
MacroKind::Bang => ItemType::Macro,
|
||||
MacroKind::Attr => ItemType::ProcAttribute,
|
||||
MacroKind::Derive => ItemType::ProcDerive,
|
||||
MacroKind::ProcMacroStub => unreachable!(),
|
||||
}
|
||||
clean::StrippedItem(..) => unreachable!(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2471,7 +2471,6 @@ impl<'a> fmt::Display for Item<'a> {
|
|||
MacroKind::Bang => write!(fmt, "Macro ")?,
|
||||
MacroKind::Attr => write!(fmt, "Attribute Macro ")?,
|
||||
MacroKind::Derive => write!(fmt, "Derive Macro ")?,
|
||||
MacroKind::ProcMacroStub => unreachable!(),
|
||||
}
|
||||
clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
|
||||
clean::StaticItem(..) | clean::ForeignStaticItem(..) => write!(fmt, "Static ")?,
|
||||
|
|
@ -5092,7 +5091,6 @@ fn item_proc_macro(w: &mut fmt::Formatter<'_>, cx: &Context, it: &clean::Item, m
|
|||
}
|
||||
write!(w, "</pre>")?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
document(w, cx, it)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -429,15 +429,11 @@ fn macro_resolve(cx: &DocContext<'_>, path_str: &str) -> Option<Res> {
|
|||
let segment = ast::PathSegment::from_ident(Ident::from_str(path_str));
|
||||
let path = ast::Path { segments: vec![segment], span: DUMMY_SP };
|
||||
cx.enter_resolver(|resolver| {
|
||||
let parent_scope = resolver.dummy_parent_scope();
|
||||
if let Ok(res) = resolver.resolve_macro_to_res_inner(&path, MacroKind::Bang,
|
||||
&parent_scope, false, false) {
|
||||
if let Res::Def(DefKind::Macro(MacroKind::ProcMacroStub), _) = res {
|
||||
// skip proc-macro stubs, they'll cause `get_macro` to crash
|
||||
} else {
|
||||
if let SyntaxExtensionKind::LegacyBang(..) = resolver.get_macro(res).kind {
|
||||
return Some(res.map_id(|_| panic!("unexpected id")));
|
||||
}
|
||||
if let Ok(res @ Res::Def(DefKind::Macro(_), _)) = resolver.resolve_macro_to_res_inner(
|
||||
&path, MacroKind::Bang, &resolver.dummy_parent_scope(), false, false
|
||||
) {
|
||||
if let SyntaxExtensionKind::LegacyBang { .. } = resolver.get_macro(res).kind {
|
||||
return Some(res.map_id(|_| panic!("unexpected id")));
|
||||
}
|
||||
}
|
||||
if let Some(res) = resolver.all_macros.get(&Symbol::intern(path_str)) {
|
||||
|
|
|
|||
|
|
@ -406,11 +406,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
|
||||
// Struct and variant constructors and proc macro stubs always show up alongside
|
||||
// their definitions, we've already processed them so just discard these.
|
||||
match path.res {
|
||||
Res::Def(DefKind::Ctor(..), _)
|
||||
| Res::SelfCtor(..)
|
||||
| Res::Def(DefKind::Macro(MacroKind::ProcMacroStub), _) => return,
|
||||
_ => {}
|
||||
if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = path.res {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there was a private module in the current path then don't bother inlining
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue