Skip to content

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

@lolbinarycat

Description

@lolbinarycat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-searchArea: Rustdoc's search featureT-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions