Skip to content

Suggest similar target names on unrecognized --target#155132

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
jakedrew:fix/suggest-similar-target-on-unrecognized-155085
Apr 11, 2026
Merged

Suggest similar target names on unrecognized --target#155132
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
jakedrew:fix/suggest-similar-target-on-unrecognized-155085

Conversation

@jakedrew
Copy link
Copy Markdown
Contributor

@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

Fixes #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
rust-bors bot pushed a commit that referenced this pull request Apr 11, 2026
Rollup of 4 pull requests

Successful merges:

 - #149357 (Implement `-Z allow-partial-mitigations` (RFC 3855))
 - #154661 (Semantic checks of `impl` restrictions)
 - #155132 (Suggest similar target names on unrecognized `--target`)
 - #155136 (Tweak comment about intrinsics in cross-crate-inlinable)
rust-bors bot pushed a commit that referenced this pull request Apr 11, 2026
Rollup of 3 pull requests

Successful merges:

 - #154661 (Semantic checks of `impl` restrictions)
 - #155132 (Suggest similar target names on unrecognized `--target`)
 - #155136 (Tweak comment about intrinsics in cross-crate-inlinable)
@rust-bors rust-bors bot merged commit 9237f14 into rust-lang:main Apr 11, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 11, 2026
rust-timer added a commit that referenced this pull request Apr 11, 2026
Rollup merge of #155132 - jakedrew:fix/suggest-similar-target-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 #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
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.

Unrecognized --target could suggest similar targets

4 participants