rustdoc search: prefer stable items in search results
fixes https://github.com/rust-lang/rust/issues/138067
this does add a new field to the search index, but since we're only listing unstable items instead of adding a boolean flag to every item, it should only increase the search index size of sysroot crates, since those are the only ones using the staged_api feature, at least as far as the rust project is concerned.
r? @GuillaumeGomez
rustbot has assigned @GuillaumeGomez. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
Some changes occurred in HTML/CSS/JS.
cc @GuillaumeGomez, @jsha, @lolbinarycat
The job x86_64-gnu-llvm-19 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#18 exporting to docker image format
#18 sending tarball 20.4s done
#18 DONE 26.7s
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-19]
[CI_JOB_NAME=x86_64-gnu-llvm-19]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-19', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--set', 'gcc.download-ci-gcc=true', '--enable-new-symbol-mangling']
configure: build.build := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-19/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
[RUSTC-TIMING] proc_macro test:false 5.558
[RUSTC-TIMING] test test:false 9.538
Finished `release` profile [optimized] target(s) in 1m 20s
##[endgroup]
[TIMING] core::build_steps::compile::Std { target: x86_64-unknown-linux-gnu, compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu, forced_compiler: true }, crates: [], force_recompile: false, extra_rust_args: ["-Csymbol-mangling-version=v0", "-Cpanic=abort"], is_for_mir_opt_tests: false } -- 80.198
Testing GCC stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Downloading crates ...
Downloaded boml v0.3.1
Compiling boml v0.3.1
[RUSTC-TIMING] boml test:false 0.771
Compiling y v0.1.0 (/checkout/compiler/rustc_codegen_gcc/build_system)
[RUSTC-TIMING] y test:false 2.957
Finished `release` profile [optimized] target(s) in 4.09s
Running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen/x86_64-unknown-linux-gnu/release/y test --use-backend gcc --gcc-path /checkout/obj/build/x86_64-unknown-linux-gnu/ci-gcc/lib --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc --release --mini-tests --std-tests`
`--gcc-path` was provided, ignoring config file. Using `/checkout/obj/build/x86_64-unknown-linux-gnu/ci-gcc/lib` as path for libgccjit
[BUILD] mini_core
[RUSTC-TIMING] mini_core test:false 0.207
[BUILD] example
[AOT] mini_core_hello_world
[RUSTC-TIMING] mini_core_hello_world test:false 0.182
---
Testing basic.js ... OK
Testing bufread-fill-buf.js ... OK
Testing const-is-nullary-func.js ... OK
Testing core-transmute.js ... FAILED
[ query `generic:T -> generic:U`]==> '{"path":"core::mem","name":"transmute"}' was supposed to be before '{"type":{"inputs":[{"id":-1,"name":"","ty":26,"path":null,"exactPath":null,"generics":[],"bindings":{},"unboxFlag":true}],"output":[{"id":-2,"name":"","ty":26,"path":null,"exactPath":null,"generics":[],"bindings":{},"unboxFlag":true}],"where_clause":[[],[]]},"dist":2,"path_dist":0,"index":0,"desc":"Numerically casts a vector, elementwise.","item":{"crate":"core","ty":7,"name":"simd_cast","path":"core::intrinsics::simd","descShard":{"crate":"core","shard":11,"start":25145,"len":2283,"promise":{}},"descIndex":713,"exactPath":"core::intrinsics::simd","type":{"inputs":[{"id":-1,"name":"","ty":26,"path":null,"exactPath":null,"generics":[],"bindings":{},"unboxFlag":true}],"output":[{"id":-2,"name":"","ty":26,"path":null,"exactPath":null,"generics":[],"bindings":{},"unboxFlag":true}],"where_clause":[[],[]]},"paramNames":["T","U"],"id":37540,"word":"simd_cast","normalizedName":"simdcast","bitIndex":33486,"implDisambiguator":null},"displayPath":"<span>core::</span><span>intrinsics::</span><span>simd::</span>","fullPath":"core::intrinsics::simd::simd_cast|7","href":"../core/intrinsics/simd/fn.simd_cast.html","displayTypeSignature":{},"crate":"core","ty":7,"name":"simd_cast","path":"core::intrinsics::simd","descShard":{"crate":"core","shard":11,"start":25145,"len":2283,"promise":{}},"descIndex":713,"exactPath":"core::intrinsics::simd","paramNames":["T","U"],"id":37540,"word":"simd_cast","normalizedName":"simdcast","bitIndex":33486,"implDisambiguator":null,"displayType":"`T` -> `U`","displayMappedNames":"T = T, U = U","displayWhereClause":""}'
Testing deduplication.js ... OK
Testing enum-option.js ... OK
Testing exact-case.js ... OK
Testing field-is-unary-func.js ... OK
Testing filter-crate.js ... OK
---
Testing unbox-type-result.js ... OK
Testing vec-new.js ... OK
Testing vec-type-signatures.js ... OK
Testing write.js ... OK
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:40:48
local time: Tue May 27 18:32:10 UTC 2025
network time: Tue, 27 May 2025 18:32:11 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
I'm concerned here about the search index size increase. In particular for very big crates like windows. Do you have some before/after numbers?
Nevermind, the only difference is a new array in the search index, so should be very limited, and only an impact on std/core/alloc crates.
@GuillaumeGomez the windows crate will not see any size increase (beyond the 6 bytes of the empty u field), as it does not use thr staged_api feature, and we only store a list of unstable items.
i should look at how much bigger the standard library index is, thought.
@GuillaumeGomez the
windowscrate will not see any size increase (beyond the 6 bytes of the empty u field), as it does not use thr staged_api feature, and we only store a list of unstable items.i should look at how much bigger the standard library index is, thought.
Yeah, after re-reading, I realized I was wrong. So yeah, only impact should be in std/core/alloc crates. Would be nice to have some numbers for them. Although I don't expect the impact to be that big.
So seems like a very good start, just a few nits and it should be ready for merge.
Based on my limited testing, this adds 8KiB to the std search index, which is currently at 1.3MiB, meaning this is an increase in size of 0.6%.
It's a bit worse in terms of compressed size, 0.8%, but it's still not super significant, but it's also only 1.8KB compressed.
It's acceptable, but now we have numbers.
@GuillaumeGomez would it be acceptable to merge this as-is, then do followup perf testing about the best way to handle unstable, deprecated, and empty description items is? I have a hunch that the short circuiting nature of search result sorting might mean this is a situation where worst case algorithmic complexity is not the factor that matters in practice.
:warning: Warning :warning:
-
This PR is based on an upstream commit that is 63 days old.
It's recommended to update your branch according to the rustc-dev-guide.
Thanks!
@bors r+ rollup
:pushpin: Commit fdbc8d08a63a3d34b7aebabb2f18a768462a98c4 has been approved by GuillaumeGomez
It is now in the queue for this repository.
Hi bors this already merged @bors r-
I am bors @rustbot label: -S-waiting-on-author +S-waiting-on-bors +merged-by-bors