Change:
The PR improved the situation about documenting proc macros. Thanks for that! However, I noticed a bug with it. I'm using . Running results in this: ! Looks like a simple typo or off-by-one or something like that bug. When using only and not s, everything looks good to me. CC
Oh, and also, running prints: Not sure if this warning is expected there. And not sure if related to this bug.
This is a consequence of the fact that has not yet been merged. Once it gets merged, and rust updates its Cargo submodule, this issue should go away.
It turns out that this issue was unrelated. I've opened a PR to fix it.
I see. Thanks for your work on this :)

Discussion:
fn raw_proc_macro(&self, id: DefIndex) -> &ProcMacro { // DefIndex's in root.proc_macro_data have a one-to-one correspondence <del> // with items in 'raw_proc_macros' </del> <ins> // with items in 'raw_proc_macros'. // NOTE: If you update the order of macros in 'proc_macro_data' for any reason, // you must also update src/libsyntax_ext/proc_macro_harness.rs // Failing to do so will result in incorrect data being associated // with proc macros when deserialized. </ins> let pos = self.root.proc_macro_data.unwrap().decode(self).position(|i| i == id).unwrap(); &self.raw_proc_macros.unwrap()[pos] }

attrs: Vec<ast::Name>, } <ins> enum ProcMacroDefType { Attr, Bang } </ins> struct ProcMacroDef { function_name: Ident, span: Span, <ins> def_type: ProcMacroDefType } enum ProcMacro { Derive(ProcMacroDerive), Def(ProcMacroDef) </ins> } struct CollectProcMacros<'a> { <del> derives: Vec<ProcMacroDerive>, attr_macros: Vec<ProcMacroDef>, bang_macros: Vec<ProcMacroDef>, </del> <ins> macros: Vec<ProcMacro>, </ins> in_root: bool, handler: &'a errors::Handler, is_proc_macro_crate: bool,

let ecfg = ExpansionConfig::default("proc_macro".to_string()); let mut cx = ExtCtxt::new(sess, ecfg, resolver); <del> let (derives, attr_macros, bang_macros) = { let mut collect = CollectProcMacros { derives: Vec::new(), attr_macros: Vec::new(), bang_macros: Vec::new(), in_root: true, handler, is_proc_macro_crate, is_test_crate, }; if has_proc_macro_decls || is_proc_macro_crate { visit::walk_crate(&mut collect, &krate); } (collect.derives, collect.attr_macros, collect.bang_macros) </del> <ins> let mut collect = CollectProcMacros { macros: Vec::new(), in_root: true, handler, is_proc_macro_crate, is_test_crate, </ins> }; <ins> if has_proc_macro_decls || is_proc_macro_crate { visit::walk_crate(&mut collect, &krate); } // NOTE: If you change the order of macros in this vec // for any reason, you must also update 'raw_proc_macro' // in src/librustc_metadata/decoder.rs let macros = collect.macros; </ins> if !is_proc_macro_crate { return krate }

return krate; } <del> krate.module.items.push(mk_decls(&mut cx, &derives, &attr_macros, &bang_macros)); </del> <ins> krate.module.items.push(mk_decls(&mut cx, &macros)); </ins> krate }

}; if self.in_root && item.vis.node.is_pub() { <del> self.derives.push(ProcMacroDerive { </del> <ins> self.macros.push(ProcMacro::Derive(ProcMacroDerive { </ins> span: item.span, trait_name: trait_ident.name, function_name: item.ident, attrs: proc_attrs, <del> }); </del> <ins> })); </ins> } else { let msg = if !self.in_root { "functions tagged with `#[proc_macro_derive]` must 

fn collect_attr_proc_macro(&mut self, item: &'a ast::Item) { if self.in_root && item.vis.node.is_pub() { <del> self.attr_macros.push(ProcMacroDef { </del> <ins> self.macros.push(ProcMacro::Def(ProcMacroDef { </ins> span: item.span, function_name: item.ident, <del> }); </del> <ins> def_type: ProcMacroDefType::Attr })); </ins> } else { let msg = if !self.in_root { "functions tagged with `#[proc_macro_attribute]` must 

fn collect_bang_proc_macro(&mut self, item: &'a ast::Item) { if self.in_root && item.vis.node.is_pub() { <del> self.bang_macros.push(ProcMacroDef { </del> <ins> self.macros.push(ProcMacro::Def(ProcMacroDef { </ins> span: item.span, function_name: item.ident, <del> }); </del> <ins> def_type: ProcMacroDefType::Bang })); </ins> } else { let msg = if !self.in_root { "functions tagged with `#[proc_macro]` must 

//      } fn mk_decls( cx: &mut ExtCtxt<'_>, <del> custom_derives: &[ProcMacroDerive], custom_attrs: &[ProcMacroDef], custom_macros: &[ProcMacroDef], </del> <ins> macros: &[ProcMacro], </ins> ) -> P<ast::Item> { let expn_id = cx.resolver.expansion_for_ast_pass( DUMMY_SP,

let proc_macro_ty_method_path = |method| cx.expr_path(cx.path(span, vec![ proc_macro, bridge, client, proc_macro_ty, method, ])); <del> custom_derives.iter().map(|cd| { cx.expr_call(span, proc_macro_ty_method_path(custom_derive), vec![ cx.expr_str(cd.span, cd.trait_name), cx.expr_vec_slice( span, cd.attrs.iter().map(|&s| cx.expr_str(cd.span, s)).collect::<Vec<_>>() ), local_path(cd.span, cd.function_name), ]) }).chain(custom_attrs.iter().map(|ca| { cx.expr_call(span, proc_macro_ty_method_path(attr), vec![ cx.expr_str(ca.span, ca.function_name.name), local_path(ca.span, ca.function_name), ]) })).chain(custom_macros.iter().map(|cm| { cx.expr_call(span, proc_macro_ty_method_path(bang), vec![ cx.expr_str(cm.span, cm.function_name.name), local_path(cm.span, cm.function_name), ]) })).collect() </del> <ins> macros.iter().map(|m| { match m { ProcMacro::Derive(cd) => { cx.expr_call(span, proc_macro_ty_method_path(custom_derive), vec![ cx.expr_str(cd.span, cd.trait_name), cx.expr_vec_slice( span, cd.attrs.iter().map(|&s| cx.expr_str(cd.span, s)).collect::<Vec<_>>() ), local_path(cd.span, cd.function_name), ]) }, ProcMacro::Def(ca) => { let ident = match ca.def_type { ProcMacroDefType::Attr => attr, ProcMacroDefType::Bang => bang }; cx.expr_call(span, proc_macro_ty_method_path(ident), vec![ cx.expr_str(ca.span, ca.function_name.name), local_path(ca.span, ca.function_name), ]) } } }).collect() </ins> }; let decls_static = cx.item_static(

// @has proc_macro/macro.some_proc_macro.html // @has proc_macro/attr.some_proc_attr.html // @has proc_macro/derive.SomeDerive.html <del> pub use some_macros::{some_proc_macro, some_proc_attr, SomeDerive}; </del> <ins> // @has proc_macro/macro.some_proc_macro.html // @has - 'a proc-macro that swallows its input and does nothing.' pub use some_macros::some_proc_macro; </ins> // @has proc_macro/macro.reexported_macro.html // @has - 'Doc comment from the original crate' pub use some_macros::reexported_macro; <ins> // @has proc_macro/attr.some_proc_attr.html // @has - 'a proc-macro attribute that passes its item through verbatim.' pub use some_macros::some_proc_attr; // @has proc_macro/derive.SomeDerive.html // @has - 'a derive attribute that adds nothing to its input.' pub use some_macros::SomeDerive; </ins>