rust-lang / rust-lang/rust

rustdoc search: path distance algorithm is bad when crate and type share name

Open
#144,834 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-rustdoc-search T-rustdoc-frontend
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

#![crate_name = "badranking"]

pub mod m {
    pub fn foo() {}

    pub struct BadRanking;

    impl BadRanking {
        pub fn foo() {}
    }
}

Reproduction Steps

  • cargo doc --open
  • search BadRanking::new

Expected Outcome

the method badranking::m::BadRanking::foo is the first result

Actual Output

the method badranking::m::BadRanking::foo is nowhere to be found, only badranking::m::foo is shown.

screenshot of bad output

Version

rustdoc 1.88.0 (6b00bc388 2025-06-23)

Additional Details

discovered when searching for BitVec::new and it wasn't the first result.

on nightly both methods are show at least, but the order is still bad:

screenshot of nightly search results

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown crate by running cargo doc --open and searching for BadRanking::new, then inspect rustdoc's search-ranking entry point and compare stable with nightly results. Done means badranking::m::BadRanking::foo appears in the results and ranks first for the query.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.