Skip to content

nightly-2024-09-11 #[test] code complains about missing_docs when missing-docs = "deny" lint is configured #130240

@ytmimi

Description

@ytmimi

When trying to run tests with cargo +nightly-2024-09-11 test I'm seeing errors when the missing-docs = "deny" lint is configured in Cargo.toml.

I've put together this minimal repo that reproduces the issue:

I tried running:

cargo +nightly-2024-09-11 test                                       

I believe this is happening because of the test macro expansion and the recent changes to emit missing_doc lints during tests (33855f8)

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (0ee7cb5e3 2024-09-10)
binary: rustc
commit-hash: 0ee7cb5e3633502d9a90a85c3c367eccd59a0aba
commit-date: 2024-09-10
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.0
Backtrace

   Compiling deny_missing_docs v0.1.0 (deny_missing_docs)
error: missing documentation for the crate
 --> src/main.rs:1:1
  |
1 | / fn main() {
2 | |     println!("Hello, world!");
3 | | }
  | |_^
  |
  = note: requested on the command line with `-D missing-docs`

error: missing documentation for the crate
 --> tests/integration.rs:1:1
  |
1 | / #[test]
2 | | fn do_nothing() {}
  | |__________________^
  |
  = note: requested on the command line with `-D missing-docs`

error: could not compile `deny_missing_docs` (bin "deny_missing_docs") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: missing documentation for a constant
 --> tests/integration.rs:2:1
  |
1 | #[test]
  | ------- in this procedural macro expansion
2 | fn do_nothing() {}
  | ^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `deny_missing_docs` (bin "deny_missing_docs" test) due to 1 previous error
error: could not compile `deny_missing_docs` (test "integration") due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions