Skip to content

Commit

Permalink
Rollup merge of rust-lang#56637 - ollie27:rustdoc_proc_macro_local_re…
Browse files Browse the repository at this point in the history
…export, r=QuietMisdreavus

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.

r? @QuietMisdreavus
  • Loading branch information
pietroalbini committed Dec 11, 2018
2 parents 286c3cc + 0bb075f commit 4674c10
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,8 @@ impl DocFolder for Cache {
clean::FunctionItem(..) | clean::ModuleItem(..) |
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
clean::ConstantItem(..) | clean::StaticItem(..) |
clean::UnionItem(..) | clean::ForeignTypeItem | clean::MacroItem(..)
clean::UnionItem(..) | clean::ForeignTypeItem |
clean::MacroItem(..) | clean::ProcMacroItem(..)
if !self.stripped_mod => {
// Re-exported items mean that the same id can show up twice
// in the rustdoc ast that we're looking at. We know,
Expand Down
7 changes: 4 additions & 3 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,11 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
hir::ItemKind::Use(ref path, kind) => {
let is_glob = kind == hir::UseKind::Glob;

// Struct and variant constructors always show up alongside their definitions, we've
// already processed them so just discard these.
// 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.def {
Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) => return,
Def::StructCtor(..) | Def::VariantCtor(..) | Def::SelfCtor(..) |
Def::Macro(_, MacroKind::ProcMacroStub) => return,
_ => {}
}

Expand Down
13 changes: 13 additions & 0 deletions src/test/rustdoc/proc-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,16 @@ pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
pub fn some_derive(_item: TokenStream) -> TokenStream {
TokenStream::new()
}

// @has some_macros/foo/index.html
pub mod foo {
// @has - '//code' 'pub use some_proc_macro;'
// @has - '//a/@href' '../../some_macros/macro.some_proc_macro.html'
pub use some_proc_macro;
// @has - '//code' 'pub use some_proc_attr;'
// @has - '//a/@href' '../../some_macros/attr.some_proc_attr.html'
pub use some_proc_attr;
// @has - '//code' 'pub use some_derive;'
// @has - '//a/@href' '../../some_macros/derive.SomeDerive.html'
pub use some_derive;
}

0 comments on commit 4674c10

Please sign in to comment.