The "Available on ..." badges about target-exclusive documentation items generated by the doc_cfg feature are not sorted and appear to reuse the order of predicates as they appear in the source code. This is problematic because:
- Popular, widely used targets can be buried among many niche ones
- A particular target a user is looking for could appear at any point in the list depending on what choices the author of the relevant
cfg block in the source made.
Code
#![feature(doc_cfg)]
#[cfg(any(
target_os = "android",
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "nto",
target_vendor = "apple",
target_os = "cygwin"
))]
pub fn foo() {}
The cfg is taken from UnixStream::peer_cred.
Reproduction Steps
cargo +nightly doc with the above code.
Expected Outcome
The lists are sorted in a deterministic and useful manner, e.g. in descending order of popularity/tier status and alphabetically.
An example ordered by tier status and alphabetically would be:
Available on Apple or Linux or FreeBSD or NetBSD or Android or Cygwin or Dragonfly BSD or OpenBSD or QNX Neutrino only.
Actual Output
Screenshots of the rendered docs listed under Code:
Note where the major targets Linux and Apple that many people will be looking for appear in the list.
Version
rustdoc 1.97.0-nightly (82bee9650 2026-05-09)
The "Available on ..." badges about target-exclusive documentation items generated by the
doc_cfgfeature are not sorted and appear to reuse the order of predicates as they appear in the source code. This is problematic because:cfgblock in the source made.Code
The
cfgis taken fromUnixStream::peer_cred.Reproduction Steps
cargo +nightly docwith the above code.Expected Outcome
The lists are sorted in a deterministic and useful manner, e.g. in descending order of popularity/tier status and alphabetically.
An example ordered by tier status and alphabetically would be:
Actual Output
Screenshots of the rendered docs listed under Code:
Note where the major targets Linux and Apple that many people will be looking for appear in the list.
Version
rustdoc 1.97.0-nightly (82bee9650 2026-05-09)