Deprioritize doc(hidden) re-exports in diagnostic paths#153630
Conversation
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors r+ |
Rollup of 4 pull requests Successful merges: - #155171 (Patch musl's CVE-2026-6042 and CVE-2026-40200) - #153630 (Deprioritize doc(hidden) re-exports in diagnostic paths) - #152613 (unsafe keyword docs: bring back unsafe_op_in_unsafe_fn lint discussion) - #155142 (impl const Residual for ControlFlow)
Rollup merge of #153630 - arferreira:fix-doc-hidden-reexport-diagnostic-path, r=jackh726 Deprioritize doc(hidden) re-exports in diagnostic paths Fixes #153477. This is the other half of #99698, which fixed the case where the *parent module* is `#[doc(hidden)]` but left the case where the re-export itself is `#[doc(hidden)]` as a FIXME (with a tracking test in `dont-suggest-doc-hidden-variant-for-enum/hidden-child.rs`). The problem: when a crate does `#[doc(hidden)] pub use core::error::Error`, diagnostics pick up the hidden re-export path instead of the canonical one. For example, `snafu::Error` instead of `std::error::Error`. Two changes: In `visible_parent_map`, the `add_child` closure now checks whether the re-export itself is `#[doc(hidden)]` via `reexport_chain` and sends it to `fallback_map`, same treatment as doc-hidden parents and underscore re-exports. `should_encode_attrs` now returns `true` for `DefKind::Use`. Without this, `#[doc(hidden)]` on `use` items was never written to crate metadata, so `is_doc_hidden` always returned `false` cross-crate. This was the actual root cause, the check in `visible_parent_map` alone isn't enough if the attribute isn't in the metadata. The existing FIXME test now serves as the regression test. The `.stderr` goes from suggesting `hidden_child::__private::Some(1i32)` to just `Some(1i32)`. cc @eggyal
|
perf triage: Looks like this has caused a perf regression in #155185. Was this expected or is it somehow justified? Can we reduce the impact? The impact doesn't seem that big to me (regressions are small and mostly in tiny secondary benchmarks), so I don't think it's worth a revert, but we shuold at least pay some attention to it. This is probably caused by encoding more metadata. Detailed results show regressions are in metadata related queries. Some of it is also more calls to |
Fixes #153477.
This is the other half of #99698, which fixed the case where the parent module is
#[doc(hidden)]but left the case where the re-export itself is#[doc(hidden)]as a FIXME (with a tracking test indont-suggest-doc-hidden-variant-for-enum/hidden-child.rs).The problem: when a crate does
#[doc(hidden)] pub use core::error::Error, diagnostics pick up the hidden re-export path instead of the canonical one. For example,snafu::Errorinstead ofstd::error::Error.Two changes:
In
visible_parent_map, theadd_childclosure now checks whether the re-export itself is#[doc(hidden)]viareexport_chainand sends it tofallback_map, same treatment as doc-hidden parents and underscore re-exports.should_encode_attrsnow returnstrueforDefKind::Use. Without this,#[doc(hidden)]onuseitems was never written to crate metadata, sois_doc_hiddenalways returnedfalsecross-crate. This was the actual root cause, the check invisible_parent_mapalone isn't enough if the attribute isn't in the metadata.The existing FIXME test now serves as the regression test. The
.stderrgoes from suggestinghidden_child::__private::Some(1i32)to justSome(1i32).cc @eggyal