Files
rust/tests/ui/suggestions
Matthias Krüger 56ecb157e2 Rollup merge of #153630 - arferreira:fix-doc-hidden-reexport-diagnostic-path, r=jackh726
Deprioritize doc(hidden) re-exports in diagnostic paths

Fixes rust-lang/rust#153477.

This is the other half of rust-lang/rust#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
2026-04-12 08:15:46 +02:00
..
2025-11-27 14:13:58 -05:00
2025-04-03 21:41:58 +00:00
2024-02-07 10:42:01 +08:00
2024-02-04 11:34:10 +08:00
2023-05-19 20:58:06 +02:00
2026-02-17 16:51:44 +00:00
2025-07-13 13:50:01 +00:00
2026-03-28 16:18:11 +09:00
2026-03-28 16:18:11 +09:00
2023-05-19 20:58:06 +02:00
2023-08-15 10:58:33 +00:00
2023-05-01 16:15:13 +08:00
2024-02-07 10:42:01 +08:00
2025-11-27 11:19:00 -05:00
2024-03-13 23:05:17 +00:00
2025-06-26 03:43:01 +00:00
2023-11-20 23:44:37 +00:00
2023-05-01 16:15:13 +08:00
2025-06-03 10:52:32 -07:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00