Searching for `Type::prefix` does not prioritize methods on `Type` over doc aliases that start with `prefix` on a different type
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
// lib.rs of a normal cargo project `cargo new --lib rustdoc_repro`
pub struct Foo;
impl Foo {
pub fn bar_first() {}
pub fn bar_last() {}
}
pub struct Quux;
impl Quux {
#[doc(alias = "bar_first")]
pub fn phooey1() {}
#[doc(alias = "bar_etc")]
pub fn phooey2() {}
}
Reproduction Steps
cargo +nightly doc --open- Search for
Foo::bar
Expected Outcome
When searching Foo::bar, Foo::bar_first and Foo::bar_last should be prioritized over Quux::phooey1 and Quux::phooey2 (if those are shown at all).
Actual Output
The methods are shown in this order in the search results:
bar_etc - see rustdoc_repro::Quux::phooey2rustdoc_repro::Foo::bar_lastbar_first - see rustdoc_repro::Quux::phooey1rustdoc_repro::Foo::bar_first
Version
$ rustdoc +nightly --version --verbose
rustdoc 1.91.0-nightly (69b76df90 2025-08-23)
binary: rustdoc
commit-hash: 69b76df90c7ea63b5350d1865f92902a0b27c9a2
commit-date: 2025-08-23
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
@rustbot label A-rustdoc-search
Additional Details
Related to #140968, but in that example there is no leading type, and that issue has been since before 1.87.0.
Bisected: the behavior changed in https://github.com/rust-lang/rust/pull/144476, before that count_ones didn't show up in the search results for BTreeSet::pop at all.
This is minimzed from the stdlib nightly docs, where I searched for BTreeSet::pop and got 18 different popcnt - see integer::count_ones methods before BTreeSet::pop_first and BTreeSet::pop_last (which were what I was looking for).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimized rustdoc_repro crate and run cargo +nightly doc --open, then search for Foo::bar in the generated rustdoc. Compare the ordering of Foo methods with Quux doc aliases, and use the related issue and bisected pull request as context. Done means type-qualified methods are prioritized over unrelated aliases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation, search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100