mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
afb3f3d243
rustdoc: Fix `redundant_explicit_links` incorrectly firing (or not firing) under certain scenarios Hi! I found some issues with the `rustdoc::redundant_explicit_links` lint while working on a personal project. - After skipping a link that contains inline markups, the lint would incorrectly skip all the remaining links. For example, with the following snippet, the lint is fired for `[Option][Option]`, but not `[Result][Result]`: ```rs //! [Option][Option] //! [**u8**][u8] (skipped) //! [Result][Result] ``` Happening because of a `?` causing a loop to bail early: https://github.com/rust-lang/rust/blob/a4a37ed163a6c1d227b58047d91457589c611cf8/src/librustdoc/passes/lint/redundant_explicit_links.rs#L107 - The lint is fired for links that specify titles (like `[link](link "title")`), except that wouldn't be applicable because it's not possible to specify a title without there also being an explicit target. For example: ``` error: redundant explicit link target --> <anon>:5:12 | 5 | /// [drop](drop "This function is not magic") | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant | | | because label contains path that resolves to same destination | = note: when a link's destination is not specified, the label is used to resolve intra-doc links help: remove explicit link target | 5 - /// [drop](drop "This function is not magic") 5 + /// [drop] | ``` These are found as of: ``` rustdoc 1.97.0-nightly (1b8f2e46e2026-04-17) binary: rustdoc commit-hash:1b8f2e46e1commit-date: 2026-04-17 host: aarch64-apple-darwin release: 1.97.0-nightly LLVM version: 22.1.2 ``` (Note: I ran `./x test tests/rustdoc-ui` locally, but not `./x tidy` due to my slow internet. There was an unrelated failed test at `tests/rustdoc-ui/ice-bug-report-url.rs` which I'm not sure about)