about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-06-18 22:23:13 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-07-11 00:12:07 +0300
commit48635226d8d71f18b09ea40f5cdbe34dbaaf378f (patch)
tree18c6d28bd7c6eecd2ebdfff76834f07d9947ad44 /src/librustdoc
parentc6a9e766f90a5271c2356fbc7941e38559200ab5 (diff)
downloadrust-48635226d8d71f18b09ea40f5cdbe34dbaaf378f.tar.gz
rust-48635226d8d71f18b09ea40f5cdbe34dbaaf378f.zip
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.
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/clean/mod.rs1
-rw-r--r--src/librustdoc/html/item_type.rs1
-rw-r--r--src/librustdoc/html/render.rs2
-rw-r--r--src/librustdoc/passes/collect_intra_doc_links.rs14
-rw-r--r--src/librustdoc/visit_ast.rs7
5 files changed, 7 insertions, 18 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 350bcc9dbc6..72e6614dc06 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -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),
diff --git a/src/librustdoc/html/item_type.rs b/src/librustdoc/html/item_type.rs
index 5f1a1b31616..9affc08141d 100644
--- a/src/librustdoc/html/item_type.rs
+++ b/src/librustdoc/html/item_type.rs
@@ -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!(),
         }
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 2d69c29dfae..5c6847b4141 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -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)
 }
diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs
index bb85fe898da..acf7a951856 100644
--- a/src/librustdoc/passes/collect_intra_doc_links.rs
+++ b/src/librustdoc/passes/collect_intra_doc_links.rs
@@ -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)) {
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index fa5faaf3ff5..009d681ed83 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -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