rust/compiler/rustc_resolve/src
bors beef07fe8f Auto merge of #113958 - lukas-code:doc-links, r=GuillaumeGomez,petrochenkov
fix intra-doc links on nested `use` and `extern crate` items

This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example:
```rust
/// Re-export [`fmt`] and [`io`].
pub use std::{fmt, io}; // "nested" use = use with braces

/// Re-export [`std`].
pub extern crate std;
```

Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`.

<details>

During AST->HIR lowering, nested `use` items are desugared like this:
```rust
pub use std::{}; // "list stem"
pub use std::fmt;
pub use std::io;
```
Each of these HIR nodes has it's own effective visibility and the list stem is always considered private.
To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items.

</details>

For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places.

As as side effect of fixing `extern crate`, i've turned
```rust
#[doc(masked)]
extern crate self as _;
```
into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus.

fixes https://github.com/rust-lang/rust/issues/113896
2023-07-25 01:35:53 +00:00
..
diagnostics Implement the unused_macro_rules lint 2022-05-05 19:13:00 +02:00
late Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
build_reduced_graph.rs Replace RPITIT current impl with new strategy that lowers as a GAT 2023-07-08 18:21:34 -03:00
check_unused.rs Make it clearer that edition functions are >=, not == 2023-07-19 16:38:35 +00:00
def_collector.rs Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
diagnostics.rs fix clippy::useless_format 2023-07-23 11:14:52 +02:00
effective_visibilities.rs resolve: Use Interned for NameBinding 2023-07-05 13:47:36 +03:00
errors.rs Add translatable diagnostic for import resolution strings 2023-06-25 08:29:28 +01:00
ident.rs Make it clearer that edition functions are >=, not == 2023-07-19 16:38:35 +00:00
imports.rs Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
late.rs Auto merge of #113958 - lukas-code:doc-links, r=GuillaumeGomez,petrochenkov 2023-07-25 01:35:53 +00:00
lib.rs Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
macros.rs Use features() over features_untracked() where possible 2023-07-22 20:09:40 +02:00
rustdoc.rs rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence 2023-04-18 12:22:13 -07:00