Skip to content

When suggesting method names, prefer *exact* doc aliases over similar names - #160369

Open
joshtriplett wants to merge 2 commits into
rust-lang:mainfrom
joshtriplett:suggest-exact-alias-before-similar-name
Open

When suggesting method names, prefer *exact* doc aliases over similar names#160369
joshtriplett wants to merge 2 commits into
rust-lang:mainfrom
joshtriplett:suggest-exact-alias-before-similar-name

Conversation

@joshtriplett

@joshtriplett joshtriplett commented Aug 2, 2026

Copy link
Copy Markdown
Member

We currently prefer candidates from a similarity search over doc aliases or rustc_confusables, even though the latter requires an exact match. Reverse this order, so that an exactly matching doc alias or rustc_confusables entry will take precedence.

The net result of this is that read_exact_buf will now produce a suggestion for read_buf_exact, not read_exact, if both exist and the former has a doc alias for read_exact_buf.

Note that this makes method searches consistent with standalone function searches, because for the latter we already prefer doc aliases over similarity searches.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 2, 2026
@rustbot

rustbot commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

@rust-log-analyzer

This comment has been minimized.

… names

We currently prefer candidates from a similarity search over doc aliases
or `rustc_confusables`, even though the latter requires an *exact*
match. Reverse this order, so that an exactly matching doc alias or
`rustc_confusables` entry will take precedence.

The net result of this is that `read_exact_buf` will now produce a
suggestion for `read_buf_exact`, not `read_exact`, if both exist and the
former has a doc alias for `read_exact_buf`.
@joshtriplett
joshtriplett force-pushed the suggest-exact-alias-before-similar-name branch from d08b388 to 32c2ca0 Compare August 2, 2026 07:49
@joshtriplett

joshtriplett commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Fixed. One other test changed, for the better I think. An attempt to call .size() now suggests only .len(), rather than .resize(...). That seems much more likely to be what the user wants, which is why we have a rustc_confusables on len.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 32c2ca0 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 3, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
…efore-similar-name, r=petrochenkov

When suggesting method names, prefer *exact* doc aliases over similar names

We currently prefer candidates from a similarity search over doc aliases or `rustc_confusables`, even though the latter requires an *exact* match. Reverse this order, so that an exactly matching doc alias or `rustc_confusables` entry will take precedence.

The net result of this is that `read_exact_buf` will now produce a suggestion for `read_buf_exact`, not `read_exact`, if both exist and the former has a doc alias for `read_exact_buf`.

Note that this makes method searches consistent with standalone function searches, because for the latter we already prefer doc aliases over similarity searches.
JonathanBrouwer pushed a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
…uf_at`

When fingers really want to type `read_exact`, that naturally leads to
the typo `read_exact_buf` instead of `read_buf_exact`, and
`read_exact_buf_at` instead of `read_buf_exact_at`.

Add doc aliases.

These will help people find them in rustdoc, and once
rust-lang#160369 goes in, it'll also help
people find them as rustfix suggestions.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
… r=Mark-Simulacrum

Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`

When fingers really want to type `read_exact`, that naturally leads to
the typo `read_exact_buf` instead of `read_buf_exact`, and
`read_exact_buf_at` instead of `read_buf_exact_at`.

Add doc aliases.

These will help people find them in rustdoc, and once
rust-lang#160369 goes in, it'll also help
people find them as rustfix suggestions.
rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159844 (Subtree cg_gcc sync (2026-07-24))
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160007 (allow `-Ldependency` search paths for panic runtimes)
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160165 (reject `...` without pattern post-expansion)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
…efore-similar-name, r=petrochenkov

When suggesting method names, prefer *exact* doc aliases over similar names

We currently prefer candidates from a similarity search over doc aliases or `rustc_confusables`, even though the latter requires an *exact* match. Reverse this order, so that an exactly matching doc alias or `rustc_confusables` entry will take precedence.

The net result of this is that `read_exact_buf` will now produce a suggestion for `read_buf_exact`, not `read_exact`, if both exist and the former has a doc alias for `read_exact_buf`.

Note that this makes method searches consistent with standalone function searches, because for the latter we already prefer doc aliases over similarity searches.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
… r=Mark-Simulacrum

Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`

When fingers really want to type `read_exact`, that naturally leads to
the typo `read_exact_buf` instead of `read_buf_exact`, and
`read_exact_buf_at` instead of `read_buf_exact_at`.

Add doc aliases.

These will help people find them in rustdoc, and once
rust-lang#160369 goes in, it'll also help
people find them as rustfix suggestions.
rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160007 (allow `-Ldependency` search paths for panic runtimes)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160435 (bump tracing-tree)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
…efore-similar-name, r=petrochenkov

When suggesting method names, prefer *exact* doc aliases over similar names

We currently prefer candidates from a similarity search over doc aliases or `rustc_confusables`, even though the latter requires an *exact* match. Reverse this order, so that an exactly matching doc alias or `rustc_confusables` entry will take precedence.

The net result of this is that `read_exact_buf` will now produce a suggestion for `read_buf_exact`, not `read_exact`, if both exist and the former has a doc alias for `read_exact_buf`.

Note that this makes method searches consistent with standalone function searches, because for the latter we already prefer doc aliases over similarity searches.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
… r=Mark-Simulacrum

Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`

When fingers really want to type `read_exact`, that naturally leads to
the typo `read_exact_buf` instead of `read_buf_exact`, and
`read_exact_buf_at` instead of `read_buf_exact_at`.

Add doc aliases.

These will help people find them in rustdoc, and once
rust-lang#160369 goes in, it'll also help
people find them as rustfix suggestions.
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
…uwer

Rollup of 26 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #158727 (std: use `readdir` on nearly all UNIX platforms)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 4, 2026
…efore-similar-name, r=petrochenkov

When suggesting method names, prefer *exact* doc aliases over similar names

We currently prefer candidates from a similarity search over doc aliases or `rustc_confusables`, even though the latter requires an *exact* match. Reverse this order, so that an exactly matching doc alias or `rustc_confusables` entry will take precedence.

The net result of this is that `read_exact_buf` will now produce a suggestion for `read_buf_exact`, not `read_exact`, if both exist and the former has a doc alias for `read_exact_buf`.

Note that this makes method searches consistent with standalone function searches, because for the latter we already prefer doc aliases over similarity searches.
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 4, 2026
… r=Mark-Simulacrum

Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`

When fingers really want to type `read_exact`, that naturally leads to
the typo `read_exact_buf` instead of `read_buf_exact`, and
`read_exact_buf_at` instead of `read_buf_exact_at`.

Add doc aliases.

These will help people find them in rustdoc, and once
rust-lang#160369 goes in, it'll also help
people find them as rustfix suggestions.
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 4, 2026
…efore-similar-name, r=petrochenkov

When suggesting method names, prefer *exact* doc aliases over similar names

We currently prefer candidates from a similarity search over doc aliases or `rustc_confusables`, even though the latter requires an *exact* match. Reverse this order, so that an exactly matching doc alias or `rustc_confusables` entry will take precedence.

The net result of this is that `read_exact_buf` will now produce a suggestion for `read_buf_exact`, not `read_exact`, if both exist and the former has a doc alias for `read_exact_buf`.

Note that this makes method searches consistent with standalone function searches, because for the latter we already prefer doc aliases over similarity searches.
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 4, 2026
… r=Mark-Simulacrum

Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`

When fingers really want to type `read_exact`, that naturally leads to
the typo `read_exact_buf` instead of `read_buf_exact`, and
`read_exact_buf_at` instead of `read_buf_exact_at`.

Add doc aliases.

These will help people find them in rustdoc, and once
rust-lang#160369 goes in, it'll also help
people find them as rustfix suggestions.
@joshtriplett joshtriplett added the relnotes Marks issues that should be documented in the release notes of the next release. label Aug 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 28 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 28 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 28 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
Kobzol added a commit to Kobzol/rust that referenced this pull request Aug 4, 2026
…efore-similar-name, r=petrochenkov

When suggesting method names, prefer *exact* doc aliases over similar names

We currently prefer candidates from a similarity search over doc aliases or `rustc_confusables`, even though the latter requires an *exact* match. Reverse this order, so that an exactly matching doc alias or `rustc_confusables` entry will take precedence.

The net result of this is that `read_exact_buf` will now produce a suggestion for `read_buf_exact`, not `read_exact`, if both exist and the former has a doc alias for `read_exact_buf`.

Note that this makes method searches consistent with standalone function searches, because for the latter we already prefer doc aliases over similarity searches.
Kobzol added a commit to Kobzol/rust that referenced this pull request Aug 4, 2026
… r=Mark-Simulacrum

Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`

When fingers really want to type `read_exact`, that naturally leads to
the typo `read_exact_buf` instead of `read_buf_exact`, and
`read_exact_buf_at` instead of `read_buf_exact_at`.

Add doc aliases.

These will help people find them in rustdoc, and once
rust-lang#160369 goes in, it'll also help
people find them as rustfix suggestions.
rust-bors Bot pushed a commit that referenced this pull request Aug 4, 2026
Rollup of 29 pull requests

Successful merges:

 - #153749 (Account for ownership mismatch on argument that doesn't meet bound)
 - #159130 (a bit optimize four-digit chunks in integer formatting)
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160184 (Add -Zinstrument-mcount={fentry-nop-record,fentry-record})
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #160434 (Avoid Docker push when the image did not change)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160011 (remove InterpError::map_err_info)
 - #160165 (reject `...` without pattern post-expansion)
 - #160172 (tests: Enable `feature(stmt_expr_attributes)` in `2229_closure_analysis` tests)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
 - #160412 (Move duplicate-names check for #[rustc_must_implement_one_of] to attribute parser)
 - #160427 (Run try builds on EC2 by default)
 - #160435 (bump tracing-tree)
 - #160449 (Fix lookup of object files)
 - #160477 (Update the tracking issue for `borrowed_buf_init`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants