Skip to content

Commit 0bb075f

Browse files
committed
rustdoc: Fix local reexports of proc macros
Filter out `ProcMacroStub`s to avoid an ICE during cleaning. Also add proc macros to `cache().paths` so it can generate links.
1 parent 9772d02 commit 0bb075f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/librustdoc/html/render.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,8 @@ impl DocFolder for Cache {
15121512
clean::FunctionItem(..) | clean::ModuleItem(..) |
15131513
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
15141514
clean::ConstantItem(..) | clean::StaticItem(..) |
1515-
clean::UnionItem(..) | clean::ForeignTypeItem | clean::MacroItem(..)
1515+
clean::UnionItem(..) | clean::ForeignTypeItem |
1516+
clean::MacroItem(..) | clean::ProcMacroItem(..)
15161517
if !self.stripped_mod => {
15171518
// Re-exported items mean that the same id can show up twice
15181519
// in the rustdoc ast that we're looking at. We know,

src/librustdoc/visit_ast.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
424424
hir::ItemKind::Use(ref path, kind) => {
425425
let is_glob = kind == hir::UseKind::Glob;
426426

427-
// Struct and variant constructors always show up alongside their definitions, we've
428-
// already processed them so just discard these.
427+
// Struct and variant constructors and proc macro stubs always show up alongside
428+
// their definitions, we've already processed them so just discard these.
429429
match path.def {
430-
Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) => return,
430+
Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) |
431+
Def::Macro(_, MacroKind::ProcMacroStub) => return,
431432
_ => {}
432433
}
433434

src/test/rustdoc/proc-macro.rs

+13
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,16 @@ pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
6161
pub fn some_derive(_item: TokenStream) -> TokenStream {
6262
TokenStream::new()
6363
}
64+
65+
// @has some_macros/foo/index.html
66+
pub mod foo {
67+
// @has - '//code' 'pub use some_proc_macro;'
68+
// @has - '//a/@href' '../../some_macros/macro.some_proc_macro.html'
69+
pub use some_proc_macro;
70+
// @has - '//code' 'pub use some_proc_attr;'
71+
// @has - '//a/@href' '../../some_macros/attr.some_proc_attr.html'
72+
pub use some_proc_attr;
73+
// @has - '//code' 'pub use some_derive;'
74+
// @has - '//a/@href' '../../some_macros/derive.SomeDerive.html'
75+
pub use some_derive;
76+
}

0 commit comments

Comments
 (0)