Skip to content

fix(core): use closest_msg to suggest similar member name for mistyped -p#16844

Merged
weihanglo merged 2 commits intorust-lang:masterfrom
raushan728:fix-15561
Apr 10, 2026
Merged

fix(core): use closest_msg to suggest similar member name for mistyped -p#16844
weihanglo merged 2 commits intorust-lang:masterfrom
raushan728:fix-15561

Conversation

@raushan728
Copy link
Copy Markdown
Contributor

@raushan728 raushan728 commented Apr 7, 2026

Fixes: #15561

Use closest_msg to suggest similar workspace member name when -p <typo> triggers the outside-of-workspace features error.

@rustbot rustbot added A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 7, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 7, 2026

r? @weihanglo

rustbot has assigned @weihanglo.
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: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@raushan728
Copy link
Copy Markdown
Contributor Author

r? @epage

@rustbot rustbot assigned epage and unassigned weihanglo Apr 7, 2026
Comment thread src/cargo/core/workspace.rs Outdated
})
.min_by_key(|(distance, _)| *distance)
.map(|(_, member)| {
format!(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use closest and closest_msg from edit_distance.rs for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried closest_msg first but it uses distance 3 which caused false positives in non_member and non_member_feature tests. Kept distance 2 to avoid noisy hints.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should then either

  • change the tests so we remain consistent in our closest matching logic
  • change closest_msg to be smarter about matches

I would view changing closest_msg to be out of scope for this change though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switching to closest_msg and updating the affected test assertions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@raushan728 raushan728 changed the title fix(core): add typo hint for -p with feature flags fix(core): use closest_msg to suggest similar member name for mistyped -p Apr 8, 2026
@raushan728 raushan728 requested review from arlosi and epage April 8, 2026 08:17
Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weihanglo weihanglo added this pull request to the merge queue Apr 10, 2026
Merged via the queue into rust-lang:master with commit 3185f58 Apr 10, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2026
@raushan728 raushan728 deleted the fix-15561 branch April 10, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-workspaces Area: workspaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misleading error message/diagnostic when package name is wrong

5 participants