add new rustdoc::hidden_intra_doc_links lint by lolbinarycat · Pull Request #144750 · rust-lang/rust (original) (raw)

current issue: reexports. an item is only truly "hidden" if there are no non-hidden paths to it. there doesn't seem to be any easy queries to find all the reexports of an item, so the only way to do this would be traversing the entire crate, like how strip_hidden works.

one potential workaround that would get rid of false positives at the cost of way more false negatives would be to only emit the lint if we only emit the lint when linking from something that is not hidden anywhere in the path to something that is directly marked as hidden.

i think the correct solution however is to rework how the strip_hidden pass works to always run, and in --document-hidden-items mode, collect a DefIdSet of all the hidden items.

the lint could also just be based on if an item is actually going to be documented, but then it doesn't work consistently in --document-hidden-items mode...

EDIT: we apparently collect the paths of things before stripping, so that doesn't work, but strip_hidden only runs on non-local crates, so that doesn't work either.