Skip to content

Commit 167ceff

Browse files
committed
Auto merge of #56407 - GuillaumeGomez:missing-docs-reexported-macros, r=varkor
check missing docs for reexported macros as well Fixes #56334.
2 parents d22fa2d + 0b272e7 commit 167ceff

8 files changed

+100
-21
lines changed

src/libcore/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
#![feature(reverse_bits)]
123123
#![feature(non_exhaustive)]
124124
#![feature(structural_match)]
125+
#![feature(abi_unadjusted)]
126+
#![cfg_attr(not(stage0), feature(adx_target_feature))]
125127

126128
#[prelude_import]
127129
#[allow(unused)]

src/librustc_lint/builtin.rs

+29-20
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,26 @@ pub struct MissingDoc {
297297
private_traits: FxHashSet<ast::NodeId>,
298298
}
299299

300+
fn has_doc(attr: &ast::Attribute) -> bool {
301+
if !attr.check_name("doc") {
302+
return false;
303+
}
304+
305+
if attr.is_value_str() {
306+
return true;
307+
}
308+
309+
if let Some(list) = attr.meta_item_list() {
310+
for meta in list {
311+
if meta.check_name("include") || meta.check_name("hidden") {
312+
return true;
313+
}
314+
}
315+
}
316+
317+
false
318+
}
319+
300320
impl MissingDoc {
301321
pub fn new() -> MissingDoc {
302322
MissingDoc {
@@ -335,26 +355,6 @@ impl MissingDoc {
335355
}
336356
}
337357

338-
fn has_doc(attr: &ast::Attribute) -> bool {
339-
if !attr.check_name("doc") {
340-
return false;
341-
}
342-
343-
if attr.is_value_str() {
344-
return true;
345-
}
346-
347-
if let Some(list) = attr.meta_item_list() {
348-
for meta in list {
349-
if meta.check_name("include") {
350-
return true;
351-
}
352-
}
353-
}
354-
355-
false
356-
}
357-
358358
let has_doc = attrs.iter().any(|a| has_doc(a));
359359
if !has_doc {
360360
cx.span_lint(MISSING_DOCS,
@@ -389,6 +389,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
389389

390390
fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
391391
self.check_missing_docs_attrs(cx, None, &krate.attrs, krate.span, "crate");
392+
393+
for macro_def in &krate.exported_macros {
394+
let has_doc = macro_def.attrs.iter().any(|a| has_doc(a));
395+
if !has_doc {
396+
cx.span_lint(MISSING_DOCS,
397+
cx.tcx.sess.source_map().def_span(macro_def.span),
398+
"missing documentation for macro");
399+
}
400+
}
392401
}
393402

394403
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {

src/libstd/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ macro_rules! dbg {
322322
}
323323
}
324324

325+
/// A macro to await on an async call.
325326
#[macro_export]
326327
#[unstable(feature = "await_macro", issue = "50547")]
327328
#[allow_internal_unstable]

src/stdsimd

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(missing_docs)] //~ ERROR
12+
13+
pub struct Foo; //~ ERROR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: missing documentation for crate
2+
--> $DIR/deny-missing-docs-crate.rs:11:1
3+
|
4+
LL | / #![deny(missing_docs)] //~ ERROR
5+
LL | |
6+
LL | | pub struct Foo; //~ ERROR
7+
| |_______________^
8+
|
9+
note: lint level defined here
10+
--> $DIR/deny-missing-docs-crate.rs:11:9
11+
|
12+
LL | #![deny(missing_docs)] //~ ERROR
13+
| ^^^^^^^^^^^^
14+
15+
error: missing documentation for a struct
16+
--> $DIR/deny-missing-docs-crate.rs:13:1
17+
|
18+
LL | pub struct Foo; //~ ERROR
19+
| ^^^^^^^^^^^^^^^
20+
21+
error: Compilation failed, aborting rustdoc
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! foo
12+
13+
#![deny(missing_docs)]
14+
15+
#[macro_export]
16+
macro_rules! foo { //~ ERROR
17+
() => {}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: missing documentation for macro
2+
--> $DIR/deny-missing-docs-macro.rs:16:1
3+
|
4+
LL | macro_rules! foo { //~ ERROR
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
note: lint level defined here
8+
--> $DIR/deny-missing-docs-macro.rs:13:9
9+
|
10+
LL | #![deny(missing_docs)]
11+
| ^^^^^^^^^^^^
12+
13+
error: Compilation failed, aborting rustdoc
14+

0 commit comments

Comments
 (0)