Skip to content

Suggest similar target names on unrecognized --target#155132

Open
jakedrew wants to merge 1 commit intorust-lang:mainfrom
jakedrew:fix/suggest-similar-target-on-unrecognized-155085
Open

Suggest similar target names on unrecognized --target#155132
jakedrew wants to merge 1 commit intorust-lang:mainfrom
jakedrew:fix/suggest-similar-target-on-unrecognized-155085

Conversation

@jakedrew
Copy link
Copy Markdown

@jakedrew jakedrew commented Apr 10, 2026

When an unrecognized --target is passed check the list of available targets and suggest the closest matching built-in target as a help message.

Before

    error: error loading target specification: could not find specification for target "x86_64-linux-gnu"
      = help: run `rustc --print target-list` for a list of built-in targets

After

    error: error loading target specification: could not find specification for target "x86_64-linux-gnu"
      = help: run `rustc --print target-list` for a list of built-in targets
      = help: did you mean `x86_64-unknown-linux-gnu`?

Regarding the expected test case in #155085 (comment) the edit_distance_with_substrings was used over edit_distance because in the case of x86_64-linux-gnu the edit_distance would return x86_64-linux-android instead of x86_64-unknown-linux-gnu

#155085

@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? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
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 11 candidates

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented Apr 11, 2026

thanks!

r? me @bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 11, 2026

📌 Commit 1137762 has been approved by Kivooeo

It is now in the queue for this repository.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 11, 2026
@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 11, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 11, 2026
…t-on-unrecognized-155085, r=Kivooeo

Suggest similar target names on unrecognized `--target`

When an unrecognized `--target` is passed check the list of available targets and suggest the closest matching built-in target as a help message.

### Before

```
    error: error loading target specification: could not find specification for target "x86_64-linux-gnu"
      = help: run `rustc --print target-list` for a list of built-in targets
```

### After

```
    error: error loading target specification: could not find specification for target "x86_64-linux-gnu"
      = help: run `rustc --print target-list` for a list of built-in targets
      = help: did you mean `x86_64-unknown-linux-gnu`?
```

Regarding the expected test case in rust-lang#155085 (comment) the `edit_distance_with_substrings` was used over `edit_distance` because in the case of `x86_64-linux-gnu` the `edit_distance` would return `x86_64-linux-android` instead of `x86_64-unknown-linux-gnu`

rust-lang#155085
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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