diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-08-30 01:44:40 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-08-30 02:54:46 +0000 |
| commit | cb9cd8f8306e6e1b16661704aed8d6f09aa5db73 (patch) | |
| tree | 50f3097e6aecf08566feec04f4dcde97bd733d9d /compiler/rustc_resolve/src/errors.rs | |
| parent | bd0ea615f73e433c43457374e76a16793b73bc9c (diff) | |
| download | rust-cb9cd8f8306e6e1b16661704aed8d6f09aa5db73.tar.gz rust-cb9cd8f8306e6e1b16661704aed8d6f09aa5db73.zip | |
On binding not present in all patterns, look at consts and unit structs/variants for suggestions
When encountering an or-pattern with a binding not available in all patterns, look for consts and unit struct/variants that have similar names as the binding to detect typos.
```
error[E0408]: variable `Ban` is not bound in all patterns
--> $DIR/binding-typo.rs:22:9
|
LL | (Foo, _) | (Ban, Foo) => {}
| ^^^^^^^^ --- variable not in all patterns
| |
| pattern doesn't bind `Ban`
|
help: you might have meant to use the similarly named unit variant `Bar`
|
LL - (Foo, _) | (Ban, Foo) => {}
LL + (Foo, _) | (Bar, Foo) => {}
|
```
For items that are not in the immedate scope, suggest the full path for them:
```
error[E0408]: variable `Non` is not bound in all patterns
--> $DIR/binding-typo-2.rs:51:16
|
LL | (Non | Some(_))=> {}
| --- ^^^^^^^ pattern doesn't bind `Non`
| |
| variable not in all patterns
|
help: you might have meant to use the similarly named unit variant `None`
|
LL - (Non | Some(_))=> {}
LL + (core::option::Option::None | Some(_))=> {}
|
```
Diffstat (limited to 'compiler/rustc_resolve/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
