mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
9237f14282
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 https://github.com/rust-lang/rust/issues/155085#issuecomment-4222050023 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/rust#155085