Rustdoc lints don't fire for pub re-exports #77230
Labels
A-cross-crate-reexports
Area: Documentation that has been re-exported from a different crate
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
This is the general form of #77200, since it appears this was unintentional. It came up again in #77119 (comment).
I tried this code:
I expected to see this happen: Rustdoc gives an error that
RawWakerVTable
is missing examples.Instead, this happened: Rustdoc ignores the re-export.
Meta
rustdoc --version
: rustdoc 1.48.0-nightly (8b40853 2020-09-23)Possible Cause
@GuillaumeGomez and I found yesterday that rustdoc does not generate an
ImportItem
for pub re-exports. Instead it generates anStructItem
, which has theDefId
of the original item, not theHirId
of an item in the current crate. This means that anywhere that needs a HirId, like lints, is out of luck.Relevant pieces of code:
rust/src/librustdoc/passes/calculate_doc_coverage.rs
Lines 184 to 188 in dadde88
rust/src/librustdoc/passes/doc_test_lints.rs
Lines 76 to 82 in 2e7ca73
https://github.com/rust-lang/rust/blob/f9546afbe1300fa3780470db1d10eb60c2cd3bbc/src/librustdoc/passes/html_tags.rs#L106-L112
check_code_block_syntax
doesn't have this issue, but only by sidestepping the lint machinery altogether and being impossible to silence.rust/src/librustdoc/passes/check_code_block_syntax.rs
Line 60 in 2e7ca73
I'm not yet sure what's causing the issues in
clean
- it looks like it should be making anImportItem
but it's not happening in practice.rust/src/librustdoc/clean/mod.rs
Lines 2284 to 2293 in 0bcc96d
Below is some debug output from the original code sample. There are various other
RawWakerVTable
items being skipped but they're either fields or impls, so I didn't include them here. In particular there are noImportItem
s.Debug output
The text was updated successfully, but these errors were encountered: