Skip to content

Suggest similar targets on unrecognized --target#155119

Closed
iyernaveenr wants to merge 1 commit intorust-lang:mainfrom
iyernaveenr:naveen_r_iyer/target_suggestion_on_unrecognized
Closed

Suggest similar targets on unrecognized --target#155119
iyernaveenr wants to merge 1 commit intorust-lang:mainfrom
iyernaveenr:naveen_r_iyer/target_suggestion_on_unrecognized

Conversation

@iyernaveenr
Copy link
Copy Markdown
Contributor

@iyernaveenr iyernaveenr commented Apr 10, 2026

When an unrecognized target is passed to --target, use edit_distance_with_substrings to find the closest built-in target and suggest it in the error message.

Before:
error: could not find specification for target "riscv64-unknown-linux-gnu"

After:
error: could not find specification for target "riscv64-unknown-linux-gnu".
Did you mean riscv64gc-unknown-linux-gnu?

This helps with common mistakes like typos, missing components (e.g. x86_64-linux-gnu -> x86_64-unknown-linux-gnu), or swapped characters. No suggestion is shown when the input is too far from any known target.

Fixes #155085

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 10, 2026

These commits modify compiler targets.
(See the Target Tier Policy.)

@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 Apr 10, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 10, 2026

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
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 69 candidates
  • Random selection from 12 candidates

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

When an unrecognized target is passed to `--target`, use
`edit_distance_with_substrings` to find the closest built-in target
and suggest it in the error message.

Before:
  error: could not find specification for target "riscv64-unknown-linux-gnu"

After:
  error: could not find specification for target "riscv64-unknown-linux-gnu".
         Did you mean `riscv64gc-unknown-linux-gnu`?

This helps with common mistakes like typos, missing components
(e.g. `x86_64-linux-gnu` -> `x86_64-unknown-linux-gnu`), or
swapped characters. No suggestion is shown when the input is too
far from any known target.

Signed-off-by: Naveen Iyer <iyernaveenr@gmail.com>
@iyernaveenr iyernaveenr force-pushed the naveen_r_iyer/target_suggestion_on_unrecognized branch from 0bd001e to 6823123 Compare April 10, 2026 18:17
@TaKO8Ki
Copy link
Copy Markdown
Member

TaKO8Ki commented Apr 14, 2026

Thank you for the contribution, but #155132 already resolved this issue, so I will close this pul request.

@TaKO8Ki TaKO8Ki closed this Apr 14, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Unrecognized --target could suggest similar targets

4 participants