Skip to content

Commit e952b52

Browse files
authored
Rollup merge of #60562 - iliekturtles:proc-macro-missing-docs, r=alexcrichton
Add #[doc(hidden)] attribute on compiler generated module. Resolves unavoidable `missing_docs` warning/error on proc-macro crates. Resolves #42008. Changes not yet tested locally, however I wanted to submit first since `rustc` takes forever to compile.
2 parents c8ef512 + 5ccf2fb commit e952b52

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/libsyntax_ext/proc_macro_decls.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
328328

329329
// Creates a new module which looks like:
330330
//
331+
// #[doc(hidden)]
331332
// mod $gensym {
332333
// extern crate proc_macro;
333334
//
@@ -361,6 +362,10 @@ fn mk_decls(
361362
});
362363
let span = DUMMY_SP.apply_mark(mark);
363364

365+
let hidden = cx.meta_list_item_word(span, Symbol::intern("hidden"));
366+
let doc = cx.meta_list(span, Symbol::intern("doc"), vec![hidden]);
367+
let doc_hidden = cx.attribute(span, doc);
368+
364369
let proc_macro = Ident::from_str("proc_macro");
365370
let krate = cx.item(span,
366371
proc_macro,
@@ -425,7 +430,7 @@ fn mk_decls(
425430
span,
426431
span,
427432
ast::Ident::with_empty_ctxt(Symbol::gensym("decls")),
428-
vec![],
433+
vec![doc_hidden],
429434
vec![krate, decls_static],
430435
).map(|mut i| {
431436
i.vis = respan(span, ast::VisibilityKind::Public);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! Verify that the `decls` module implicitly added by the compiler does not cause `missing_docs`
2+
//! warnings.
3+
4+
// compile-pass
5+
// force-host
6+
// no-prefer-dynamic
7+
8+
#![crate_type = "proc-macro"]
9+
#![deny(missing_docs)]
10+
11+
extern crate proc_macro;
12+
use proc_macro::*;
13+
14+
/// Foo1.
15+
#[proc_macro]
16+
pub fn foo1(input: TokenStream) -> TokenStream { input }

0 commit comments

Comments
 (0)