Skip to content

[beta regression] missing_docs lint ignores items generated by external macros #53537

Closed
@durka

Description

@durka

On beta and nightly, items generated by macros in external crates do not have to be documented, even in the presence of #![deny(missing_docs)].

Consider this code: https://gist.github.com/0dda35f371bdde94780fc65bb99c4bf0

Now observe the reaction! Compiling with stable:

$ cargo +stable build
   Compiling b v0.1.0 (file:///Users/alex/Documents/work/macdoc/b)
   Compiling a v0.1.0 (file:///Users/alex/Documents/work/macdoc/a)
error: missing documentation for a function
  --> src/lib.rs:8:9
   |
8  |         pub fn $f() {}
   |         ^^^^^^^^^^^
...
14 | a!(bar, Bar);
   | ------------- in this macro invocation
   |
note: lint level defined here
  --> src/lib.rs:1:9
   |
1  | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^

error: missing documentation for a struct
  --> src/lib.rs:10:9
   |
10 |         pub struct $g;
   |         ^^^^^^^^^^^^^^
...
14 | a!(bar, Bar);
   | ------------- in this macro invocation

error: missing documentation for a function
  --> src/lib.rs:15:1
   |
15 | b!(foo, Foo);
   | ^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: missing documentation for a struct
  --> src/lib.rs:15:1
   |
15 | b!(foo, Foo);
   | ^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 4 previous errors

error: Could not compile `a`.

To learn more, run the command again with --verbose.

And with beta:

$ cargo +beta build
   Compiling b v0.1.0 (file:///Users/alex/Documents/work/macdoc/b)
   Compiling a v0.1.0 (file:///Users/alex/Documents/work/macdoc/a)
error: missing documentation for a function
  --> src/lib.rs:8:9
   |
8  |         pub fn $f() {}
   |         ^^^^^^^^^^^
...
14 | a!(bar, Bar);
   | ------------- in this macro invocation
   |
note: lint level defined here
  --> src/lib.rs:1:9
   |
1  | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^

error: missing documentation for a struct
  --> src/lib.rs:10:9
   |
10 |         pub struct $g;
   |         ^^^^^^^^^^^^^^
...
14 | a!(bar, Bar);
   | ------------- in this macro invocation

error: aborting due to 2 previous errors

error: Could not compile `a`.

To learn more, run the command again with --verbose.

Note only the two errors!

cc: @Dylan-DPC

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions