Skip to content

Commit f6fe6eb

Browse files
committed
Fix false positive with missing_docs and #[test]
Since #130025, the compiler don't ignore missing_docs when compiling the tests. But there is now a false positive warning for every `#[test]` For example, this code ```rust //! Crate docs fn just_a_test() {} ``` Would emit this warning when running `cargo test` ``` warning: missing documentation for a constant --> src/lib.rs:5:1 | 4 | #[test] | ------- in this procedural macro expansion 5 | fn just_a_test() {} | ^^^^^^^^^^^^^^^^^^^ ```
1 parent 4c5fc2c commit f6fe6eb

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ pub(crate) fn expand_test_or_bench(
277277
cx.attr_nested_word(sym::cfg, sym::test, attr_sp),
278278
// #[rustc_test_marker = "test_case_sort_key"]
279279
cx.attr_name_value_str(sym::rustc_test_marker, test_path_symbol, attr_sp),
280+
// #[allow(missing_docs)]
281+
cx.attr_nested_word(sym::allow, sym::missing_docs, attr_sp),
280282
],
281283
// const $ident: test::TestDescAndFn =
282284
ast::ItemKind::Const(

tests/ui/lint/lint-missing-doc-test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
44
//@ check-pass
55
//@ compile-flags: --test -Dmissing_docs
6+
7+
#[test]
8+
fn test() {}

0 commit comments

Comments
 (0)