Skip to content

Commit 5ccf2fb

Browse files
committed
Add #[doc(hidden)] attribute on compiler generated proc-macro module.
Stops unavoidable `missing_docs` warning/error on proc-macro crates. Resolves #42008.
1 parent 5f1924c commit 5ccf2fb

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/libsyntax_ext/proc_macro_decls.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
324324

325325
// Creates a new module which looks like:
326326
//
327+
// #[doc(hidden)]
327328
// mod $gensym {
328329
// extern crate proc_macro;
329330
//
@@ -357,6 +358,10 @@ fn mk_decls(
357358
});
358359
let span = DUMMY_SP.apply_mark(mark);
359360

361+
let hidden = cx.meta_list_item_word(span, Symbol::intern("hidden"));
362+
let doc = cx.meta_list(span, Symbol::intern("doc"), vec![hidden]);
363+
let doc_hidden = cx.attribute(span, doc);
364+
360365
let proc_macro = Ident::from_str("proc_macro");
361366
let krate = cx.item(span,
362367
proc_macro,
@@ -421,7 +426,7 @@ fn mk_decls(
421426
span,
422427
span,
423428
ast::Ident::with_empty_ctxt(Symbol::gensym("decls")),
424-
vec![],
429+
vec![doc_hidden],
425430
vec![krate, decls_static],
426431
).map(|mut i| {
427432
i.vis = respan(span, ast::VisibilityKind::Public);
+16
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)