diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-05-13 21:36:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-13 21:36:52 +0200 |
| commit | e952b52a16e14fd18b95c0e6cef48ead82d1c266 (patch) | |
| tree | 41bc42155771fa9dc160bfd79e391e35bd075e39 | |
| parent | c8ef512480296b1398640088fe16759ac9614d81 (diff) | |
| parent | 5ccf2fb985b5581fdc3f1a3a647b0d613da996d3 (diff) | |
| download | rust-e952b52a16e14fd18b95c0e6cef48ead82d1c266.tar.gz rust-e952b52a16e14fd18b95c0e6cef48ead82d1c266.zip | |
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.
| -rw-r--r-- | src/libsyntax_ext/proc_macro_decls.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/no-missing-docs.rs | 16 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/libsyntax_ext/proc_macro_decls.rs b/src/libsyntax_ext/proc_macro_decls.rs index 5ced1400acb..1eab739cf64 100644 --- a/src/libsyntax_ext/proc_macro_decls.rs +++ b/src/libsyntax_ext/proc_macro_decls.rs @@ -328,6 +328,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { // Creates a new module which looks like: // +// #[doc(hidden)] // mod $gensym { // extern crate proc_macro; // @@ -361,6 +362,10 @@ fn mk_decls( }); let span = DUMMY_SP.apply_mark(mark); + let hidden = cx.meta_list_item_word(span, Symbol::intern("hidden")); + let doc = cx.meta_list(span, Symbol::intern("doc"), vec![hidden]); + let doc_hidden = cx.attribute(span, doc); + let proc_macro = Ident::from_str("proc_macro"); let krate = cx.item(span, proc_macro, @@ -425,7 +430,7 @@ fn mk_decls( span, span, ast::Ident::with_empty_ctxt(Symbol::gensym("decls")), - vec![], + vec![doc_hidden], vec![krate, decls_static], ).map(|mut i| { i.vis = respan(span, ast::VisibilityKind::Public); diff --git a/src/test/ui/proc-macro/no-missing-docs.rs b/src/test/ui/proc-macro/no-missing-docs.rs new file mode 100644 index 00000000000..e5a5f8beb45 --- /dev/null +++ b/src/test/ui/proc-macro/no-missing-docs.rs @@ -0,0 +1,16 @@ +//! Verify that the `decls` module implicitly added by the compiler does not cause `missing_docs` +//! warnings. + +// compile-pass +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![deny(missing_docs)] + +extern crate proc_macro; +use proc_macro::*; + +/// Foo1. +#[proc_macro] +pub fn foo1(input: TokenStream) -> TokenStream { input } |
