rustdoc: Fix link title attribute value when field of enum variants
Fixes https://github.com/rust-lang/rust/issues/161028.
The issue was that we link to parent page, we generate a "fragment" to the parent item (so here the enum), because we forgot to take into account that there might be two levels: enum variants can have fields. So in case it's an enum and the `DefId` is a field, we add the field's parent name (so the enum variant) to the title.
r? @Urgau
Simply replace the parameter name and `#[rustc_splat]` attribute with an ellipsis. This preserves the type information of the splat while still documenting the variadic nature of the function.
Fix, simplify, and document doc meta finalize mode
Follow up https://github.com/rust-lang/rust/pull/159415#discussion_r3605070232
Get rid of the mode where you can finalize the CCI and generate more docs at the same time. It isn't used in Cargo, and probably won't be used elsewhere?
Fixes a bug where the crate index, settings page, and help page aren’t generated at finalize time.
Update documentation.
Move CCI tests to run-make, so that we can test the finalize step’s CLI.
Allow only implementing `Read::read_buf`
This PR allows users to only implement `Read::read_buf`, without the need for implementing `Read::read`. `rustc_must_implement_one_of` annotation ensures that **at least** one of the methods is implemented, so that the default impls don't create infinite recursion.
Note that `Read::read_buf` is unstable, so this doesn't change anything on stable, there you still need to implement `Read::read`, since you can't implement `Read::read_buf`. Thus, we don't expose `rustc_must_implement_one_of` to stable.
r? @thomcc
`EscapeBodyTextWithWbr` iterates `text.grapheme_indices(true)`, so `i` is the
start of a grapheme cluster, but the `_`/`:` word-break arm sliced at `i + 1` --
assuming a cluster containing `_` or `:` is exactly one byte long.
UAX#29 GB9b joins a `Prepend`-class character (U+0600-U+0605, U+0D4E, U+111C2,
...) with the character that follows it, so a cluster can start with a
multi-byte character and still contain `_`. `i + 1` then lands inside that
character and `str` indexing panics. U+0D4E is `XID_Continue`, so this is
reachable from an item name rustc accepts, e.g. `pub struct abc<U+0D4E>_defgh;`,
and rustdoc ICEs instead of documenting the crate.
Break after the whole cluster (`i + s.len()`) instead. The adjacent CamelCase
arm already slices at `i`, which is always a cluster boundary, so it is
unaffected.
This also stops the `<wbr>` from being inserted between `_` and a combining
mark that trails it, which split a grapheme cluster without panicking.
Rustdoc label badge for notable traits
- Part of rust-lang/rust#156865
- [x] reuse notable trait feature to feed badge data
- [x] render it in html
- [x] add some html tests
- [x] Render a color from a hash from `its full path`
- [x] fixed oklch hue-driven palette checked against wcag/apca
Should the following be out of scope ?
- [ ] Parse color (`#[doc(notable_trait(color="0xff0000")]`)
- [ ] display a small colored indicator (with a hover/first letter?) when a type implementing a notable trait is listed outside of its main page
- [ ] Some Integration with rust analyzer
<img width="315" height="222" alt="Screenshot 2026-05-28 at 14 06 01" src="https://github.com/user-attachments/assets/2b7c19c4-0d6e-4ed7-8901-f82fba7fc122" />
## Color discussion
I went for the higher chroma, even though some values use a fallback, I'm not opposed to go for a less chromatic palette, but that's very bikeshedding so I'll defer to authority.
with chroma 0.21:
<img width="1048" height="274" alt="Screenshot 2026-06-30 at 21 57 27" src="https://github.com/user-attachments/assets/9f374295-4eb3-43ee-bffa-51276ffa39d2" />
with chroma 0.090:
<img width="1037" height="274" alt="Screenshot 2026-06-30 at 21 58 38" src="https://github.com/user-attachments/assets/81d9c5b5-02a8-4f75-969f-0d4fc62bebd0" />
## History
Initially, this PR added a new feature "label_trait", it was then decided in [rustdoc meeting](https://hackmd.io/CxdTcVFTQPmBUrx-PWXTAw?view) to reuse current notable_trait feature.
rustdoc: Only analyze head of self type when deciding impl inlining
We only care about whether the self type is a generic or an item (inlined) in
the current crate, so we don't actually need to compute the param_env, which is
expensive when done to every external impl. This PR avoids computing the
param_env until we actually decide to inline the impl. Moreover, it adds
specialized cleaning logic for types that stops after the "head" (the top-level
structure) is constructed, which is enough for the self type-based impl
inlining analysis.
std::sync::poison: disable auto_cfg on PoisonError::new
`PoisonError::new` is defined twice, once for `#[cfg(panic = "unwind")]` and once for its negation. While exactly one definition survives expansion in any given build, the method itself is actually present in every configuration.
Currently, rustdoc's `auto_cfg` only looks at whichever `cfg` survived expansion and tags the method accordingly, generating a misleading "Available on panic=unwind only" portability badge in the docs.
This is the same `auto_cfg` limitation previously addressed in rust-lang/rust#153964, rust-lang/rust#154311, and rust-lang/rust#156426: when an item is split into mutually-exclusive `cfg` variants that collectively cover all builds, rustdoc incorrectly marks it as conditionally available. Issue rust-lang/rust#149786 pointed out `PoisonError::new` as another case of this pattern, but it hadn't been touched yet.
This PR applies the same fix as rust-lang/rust#156426 (adding `#[doc(auto_cfg = false)]` to both variants) and adds a regression test to cover this pattern going forward.
r? @GuillaumeGomez
Since we're getting rid of the ability to do finalize and document at
the same time, we can't actually do this in the rustdoc-html test build
system and need to do it this way instead.
PoisonError::new is defined twice, once under #[cfg(panic = "unwind")]
and once under its negation, so exactly one definition exists in any
given build. rustdoc's auto_cfg only sees whichever cfg survived
expansion and tags the method as available under that cfg only, even
though it is callable in every configuration - it just panics under
panic=abort instead of returning.
Disable auto_cfg on both variants so the portability note stops
implying the method doesn't exist elsewhere. The doc comment already
explains the panic=abort behavior in prose, so the cfg doesn't need to
leak into the generated badge.
Add a minimal regression test.
rustdoc: Only build extern trait impls if needed
or, finally remove the `BadImplStripper`!
Building inlined impls is expensive, and most of them end up being
unneeded and stripped later in this function. So we should filter them
ahead of time. This requires inlining external auto traits when we
construct auto impls, since this no longer happens as a side effect.
We inline external impls when they are
* for generics (i.e., blanket impls)
* for primitive types (probably this should be handled below really)
* for a type (inlined) in the current crate
* of a trait (inlined) in the current crate
* of `Deref`
These rules are based on the existing filtering rules that are applied
after building the inlined impls.
After doing the filtering ahead of time, we can remove the downstream
filtering. Thus, we can finally remove `BadImplStripper` and unused
deref-following logic. It appears that all this `Deref` logic was pointless
in the first place since following derefs already happens elsewhere in
rustdoc, where it is actually needed.
The code predating this PR was actually incorrect since it did not keep
these impls. However, removing the redundant deref-following logic had
the side effect of breaking a GUI test for the notable traits tooltip.
It seems like previously an unrelated type with a deref impl to
`Vec<u8>` ended up causing the impl of `Write` for it to be kept.
In fact, this change required some snapshot tests to be updated because
it fixed a latent bug where the notable trait tooltip would not appear
for many external traits (if they didn't happen to get pulled in like
`Write for Vec<u8>` did).
implement #![feature(macroless_generic_const_args)]
tracking issue: https://github.com/rust-lang/rust/issues/159006
lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :)
the test situation is that after discussion with boxy of whether our mgca tests should be:
- keep them under only `min_generic_const_args`, and add `direct_const_arg!()` where it's needed
- keep the code contents as-is, and add `#![feature(macroless_generic_const_args)]` where it's needed
the second seems more desirable, so that's what I did. There are still quite a few tests that only have `min_generic_const_args` without `macroless_generic_const_args` (140 of them, to be exact - `rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l`, and now 90 with `macroless_generic_const_args`)
r? @BoxyUwU
rustdoc: Fix auto trait normalization env
Fixesrust-lang/rust#159065
rustdoc ICEs on #[doc(inline)] pub use std as other; with -Znext-solver=globally -Znormalize-docs. The synthetic auto-trait code builds a ParamEnv for the generated where-clauses, but nested type normalization still reads cx.param_env (via `clean_predicate` -> `clean_middle_ty` -> `normalize`). In the inline std case that env can be empty, so the solver later idk's the type of the placeholder const.
Use that synthetic auto-trait ParamEnv while cleaning the generated where-clauses. imo this is the least weird place to do it: the clauses came from that env, so their normalization should use it too. btw, the added rustdoc-html test is just the reduced issue case, fyi.
rustdoc: Show use-site paths for unevaluated const array lengths
After rust-lang/rust#158171, I noticed a few additional issues with the rendering of consts in rustdoc. This PR fixes them. When rendering array lengths, avoid inlining the full definition of unevaluated constants via `print_inlined_const`. Instead, fall back to `Const::to_string()` for use-site rendering, matching the behavior already used for projections without bodies.
r? camelid
QNX target renaming
This PR renames two QNX targets:
- `aarch64-unknown-nto-qnx800` becomes simply `aarch64-unknown-qnx`
- `x86_64-pc-nto-qnx800` becomes simply `x86_64-pc-qnx`
In addition:
- references to *QNX OS* and *QNX Neutrino RTOS* are replaced with *QNX SDP* for uniformity
- the `spec::base::nto_qnx` module is renamed to `base::spec::qnx_sdp` to match the above
- the `target_os` of the QNX SDP 8.0 targets is changed to `qnx` to match the target name
- a *lot* of code is then touched to handle `any(target_os = "nto", target_os = "qnx")`
I think it's worth noting that *QNX Software Development Platform* is the *build environment* that you download and install, and you can use it to create a custom *run-time environment*. In SDP 7.x the run-time environment was based on *QNX Neutrino 7.x*, but in SDP 8.0 the run-time environment is based on *QNX OS 8.0*. I think it was weird to users to see the two different run-time environments in the docs, and referring to the build environment just seems to make more sense anyway because that's what users install, it's where the headers live, and ultimately it's what the toolchain will care about.
The new target names match those reported by `clang` running *on* the [self-hosted *QNX Developer Desktop*](https://www.qnx.com/developers/docs/qnxeverywhere/com.qnx.doc.qdd/topic/about.html).
```console
$ clang --version
QNX clang version 21.1.3
Target: x86_64-pc-qnx
Thread model: posix
InstalledDir: /usr/bin
```
Once the compiler knows about the new target names, `libc`, `backtrace` and `cc-rs` can be updated to match, and then building `libstd` for the new targets can be fixed. This rename will cause a bit of churn, but it seemed important to get it changed before anyone tries to finish libstd support for QNX SDP 8.0 (it's currently noted as "in-progress"). It's also Tier 3 so we have fairly broad latitude to do this I think, and aligning with QNX's build of clang just makes sense.
With these changes I can run:
```console
$ ./x build library/std --stage 2 --target x86_64-pc-nto-qnx710,aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710_iosock,aarch64-unknown-nto-qnx710_iosock,aarch64-unknown-nto-qnx700
$ ./x build library/core --stage 1 --target x86_64-pc-qnx,aarch64-unknown-qnx
```
The QNX SDP 7.x targets retain their old names, and their `target_os = "nto", target_env = "qnx710"` configuration, to avoid breakage.
- aarch64-unknown-nto-qnx800 becomes simply aarch64-unknown-qnx
- x86_64-pc-nto-qnx800 becomes simply x86_64-pc-qnx
- references to QNX OS and QNX Neutrino RTOS are replaced with QNX SDP for uniformity
- various nto_qnx modules are named to qnx_sdp to match the above
The new target names are more consistent with those used by the QNX SDP 8.0 toolchain, and reflect a level on ongoing API stability similar to that for macOS and Linux (which simply have minimum supported versions record for their targets).
Once the compiler knows about the new target names, libc and backtrace can be updated to match, and then building libstd for the new targets can be fixed.
With these changes I can run:
```console
$ ./x build library/std --stage 2 --target x86_64-pc-nto-qnx710,aarch64-unknown-nto-qnx710,x86_64-pc-nto-qnx710_iosock,aarch64-unknown-nto-qnx710_iosock,aarch64-unknown-nto-qnx700
$ ./x build library/core --stage 1 --target x86_64-pc-qnx,aarch64-unknown-qnx
```
rustdoc: show impl Trait<Box<Local>> for Foreign, etc on Local's docs
This is a generalization of rust-lang/rust#92940: that PR handled cases like `impl Foreign for Box<Local>`, but was missing handling for a few other closely related cases.
My particular interest was with showing `impl From<Box<Utf8Path>> for Box<Path>` in camino's documentation. But I ended up handling a bunch of related cases along the way.
I'm new to rustdoc so please let me know if I got anything wrong :) took a bit to fully understand how this worked.
<img width="1733" height="483" alt="image" src="https://github.com/user-attachments/assets/4b987c61-bdac-4de3-a491-c0577e06fa7c" />
This is a generalization of PR 92940: that PR handled cases like `impl Foreign for Box<Local>`, but was missing handling for a few other closely related cases.
My particular interest was with showing `impl From<Box<Utf8Path>> for Box<Path>` in camino's documentation. But I ended up handling a bunch of related cases along the way.
I'm new to rustdoc so please let me know if I got anything wrong :) took a bit to fully understand how this worked.