diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-08-24 19:22:51 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-08-25 15:16:25 +0000 |
| commit | 8dbdb1760b23112f87aedad37e4dad97559bc750 (patch) | |
| tree | dd2cd17a9704e56eac5416f6c5c9883ebd6deaf5 /tests/ui/resolve | |
| parent | 41a79f1862aa6b81bac674598e275e80e9f09eb9 (diff) | |
| download | rust-8dbdb1760b23112f87aedad37e4dad97559bc750.tar.gz rust-8dbdb1760b23112f87aedad37e4dad97559bc750.zip | |
On binding not present in all patterns, suggest potential typo
```
error[E0408]: variable `Ban` is not bound in all patterns
--> f12.rs:9:9
|
9 | (Foo,Bar)|(Ban,Foo) => {}
| ^^^^^^^^^ --- variable not in all patterns
| |
| pattern doesn't bind `Ban`
|
help: you might have meant to use the similarly named previously used binding `Bar`
|
9 - (Foo,Bar)|(Ban,Foo) => {}
9 + (Foo,Bar)|(Bar,Foo) => {}
|
```
Diffstat (limited to 'tests/ui/resolve')
| -rw-r--r-- | tests/ui/resolve/resolve-inconsistent-names.rs | 6 | ||||
| -rw-r--r-- | tests/ui/resolve/resolve-inconsistent-names.stderr | 46 |
2 files changed, 33 insertions, 19 deletions
diff --git a/tests/ui/resolve/resolve-inconsistent-names.rs b/tests/ui/resolve/resolve-inconsistent-names.rs index 9a40b20346c..bf74a4ba0f3 100644 --- a/tests/ui/resolve/resolve-inconsistent-names.rs +++ b/tests/ui/resolve/resolve-inconsistent-names.rs @@ -10,8 +10,10 @@ pub mod m { fn main() { let y = 1; match y { - a | b => {} //~ ERROR variable `a` is not bound in all patterns - //~| ERROR variable `b` is not bound in all patterns + a | b => {} //~ ERROR variable `a` is not bound in all patterns + //~| ERROR variable `b` is not bound in all patterns + //~| HELP you might have meant to use the similarly named previously used binding `a` + //~| HELP you might have meant to use the similarly named previously used binding `b` } let x = (E::A, E::B); diff --git a/tests/ui/resolve/resolve-inconsistent-names.stderr b/tests/ui/resolve/resolve-inconsistent-names.stderr index 5fac622eef2..152c16ad404 100644 --- a/tests/ui/resolve/resolve-inconsistent-names.stderr +++ b/tests/ui/resolve/resolve-inconsistent-names.stderr @@ -1,21 +1,33 @@ error[E0408]: variable `b` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:13:8 + --> $DIR/resolve-inconsistent-names.rs:13:9 + | +LL | a | b => {} + | ^ - variable not in all patterns + | | + | pattern doesn't bind `b` + | +help: you might have meant to use the similarly named previously used binding `a` + | +LL - a | b => {} +LL + a | a => {} | -LL | a | b => {} - | ^ - variable not in all patterns - | | - | pattern doesn't bind `b` error[E0408]: variable `a` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:13:12 + --> $DIR/resolve-inconsistent-names.rs:13:13 + | +LL | a | b => {} + | - ^ pattern doesn't bind `a` + | | + | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `b` + | +LL - a | b => {} +LL + b | b => {} | -LL | a | b => {} - | - ^ pattern doesn't bind `a` - | | - | variable not in all patterns error[E0408]: variable `c` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:19:9 + --> $DIR/resolve-inconsistent-names.rs:21:9 | LL | (A, B) | (ref B, c) | (c, A) => () | ^^^^^^ - - variable not in all patterns @@ -24,7 +36,7 @@ LL | (A, B) | (ref B, c) | (c, A) => () | pattern doesn't bind `c` error[E0408]: variable `A` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:19:18 + --> $DIR/resolve-inconsistent-names.rs:21:18 | LL | (A, B) | (ref B, c) | (c, A) => () | - ^^^^^^^^^^ - variable not in all patterns @@ -38,7 +50,7 @@ LL | (E::A, B) | (ref B, c) | (c, A) => () | +++ error[E0408]: variable `B` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:19:31 + --> $DIR/resolve-inconsistent-names.rs:21:31 | LL | (A, B) | (ref B, c) | (c, A) => () | - - ^^^^^^ pattern doesn't bind `B` @@ -47,7 +59,7 @@ LL | (A, B) | (ref B, c) | (c, A) => () | variable not in all patterns error[E0409]: variable `B` is bound inconsistently across alternatives separated by `|` - --> $DIR/resolve-inconsistent-names.rs:19:23 + --> $DIR/resolve-inconsistent-names.rs:21:23 | LL | (A, B) | (ref B, c) | (c, A) => () | - ^ bound in different ways @@ -55,7 +67,7 @@ LL | (A, B) | (ref B, c) | (c, A) => () | first binding error[E0408]: variable `Const2` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:31:9 + --> $DIR/resolve-inconsistent-names.rs:33:9 | LL | (CONST1, _) | (_, Const2) => () | ^^^^^^^^^^^ ------ variable not in all patterns @@ -68,7 +80,7 @@ LL | (CONST1, _) | (_, m::Const2) => () | +++ error[E0408]: variable `CONST1` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:31:23 + --> $DIR/resolve-inconsistent-names.rs:33:23 | LL | (CONST1, _) | (_, Const2) => () | ------ ^^^^^^^^^^^ pattern doesn't bind `CONST1` @@ -82,7 +94,7 @@ LL | const CONST1: usize = 10; | ^^^^^^^^^^^^^^^^^^^^^^^^^ not accessible error[E0308]: mismatched types - --> $DIR/resolve-inconsistent-names.rs:19:19 + --> $DIR/resolve-inconsistent-names.rs:21:19 | LL | match x { | - this expression has type `(E, E)` |
