diff options
| author | Esteban Kuber <esteban@kuber.com.ar> | 2021-11-17 19:37:46 +0000 |
|---|---|---|
| committer | Esteban Kuber <esteban@kuber.com.ar> | 2022-04-30 02:27:25 +0000 |
| commit | 09f3ea16928d7a61ef8805bc2ad69a3bd2f7db18 (patch) | |
| tree | 92d0f42c519575ffe8133266bc378750ff0e4ad5 /src/test | |
| parent | 05c07386b45fbc540ec8cdc1bc41ae9c062b453b (diff) | |
| download | rust-09f3ea16928d7a61ef8805bc2ad69a3bd2f7db18.tar.gz rust-09f3ea16928d7a61ef8805bc2ad69a3bd2f7db18.zip | |
When encountering a binding that could be a const or unit variant, suggest the right path
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/or-patterns/missing-bindings.stderr | 32 | ||||
| -rw-r--r-- | src/test/ui/resolve/resolve-inconsistent-names.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/resolve/resolve-inconsistent-names.stderr | 22 | ||||
| -rw-r--r-- | src/test/ui/span/issue-39698.stderr | 20 |
4 files changed, 40 insertions, 43 deletions
diff --git a/src/test/ui/or-patterns/missing-bindings.stderr b/src/test/ui/or-patterns/missing-bindings.stderr index c173a3a9aba..8fafa275b5c 100644 --- a/src/test/ui/or-patterns/missing-bindings.stderr +++ b/src/test/ui/or-patterns/missing-bindings.stderr @@ -103,6 +103,22 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | | | pattern doesn't bind `c` +error[E0408]: variable `d` is not bound in all patterns + --> $DIR/missing-bindings.rs:45:33 + | +LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; + | - ^^^^ pattern doesn't bind `d` + | | + | variable not in all patterns + +error[E0408]: variable `e` is not bound in all patterns + --> $DIR/missing-bindings.rs:45:10 + | +LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; + | ^^^^^^^^^^^^^^^^^^^^ - variable not in all patterns + | | + | pattern doesn't bind `e` + error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:45:33 | @@ -127,22 +143,6 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | | | variable not in all patterns -error[E0408]: variable `d` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:33 - | -LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | - ^^^^ pattern doesn't bind `d` - | | - | variable not in all patterns - -error[E0408]: variable `e` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:10 - | -LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | ^^^^^^^^^^^^^^^^^^^^ - variable not in all patterns - | | - | pattern doesn't bind `e` - error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:61:29 | diff --git a/src/test/ui/resolve/resolve-inconsistent-names.rs b/src/test/ui/resolve/resolve-inconsistent-names.rs index b9202f556d1..989d2d45230 100644 --- a/src/test/ui/resolve/resolve-inconsistent-names.rs +++ b/src/test/ui/resolve/resolve-inconsistent-names.rs @@ -2,9 +2,9 @@ enum E { A, B, c } -mod m { +pub mod m { const CONST1: usize = 10; - const Const2: usize = 20; + pub const Const2: usize = 20; } fn main() { @@ -22,15 +22,14 @@ fn main() { //~| ERROR variable `B` is bound inconsistently //~| ERROR mismatched types //~| ERROR variable `c` is not bound in all patterns - //~| HELP consider making the path in the pattern qualified: `?::A` + //~| HELP if you meant to match on unit variant `E::A`, use the full path in the pattern } let z = (10, 20); match z { (CONST1, _) | (_, Const2) => () //~^ ERROR variable `CONST1` is not bound in all patterns - //~| HELP consider making the path in the pattern qualified: `?::CONST1` //~| ERROR variable `Const2` is not bound in all patterns - //~| HELP consider making the path in the pattern qualified: `?::Const2` + //~| HELP if you meant to match on constant `m::Const2`, use the full path in the pattern } } diff --git a/src/test/ui/resolve/resolve-inconsistent-names.stderr b/src/test/ui/resolve/resolve-inconsistent-names.stderr index 70e9c2e5bf5..9de191f7d32 100644 --- a/src/test/ui/resolve/resolve-inconsistent-names.stderr +++ b/src/test/ui/resolve/resolve-inconsistent-names.stderr @@ -23,11 +23,10 @@ LL | (A, B) | (ref B, c) | (c, A) => () | | pattern doesn't bind `A` | variable not in all patterns | -help: if you meant to match on a variant or a `const` item, consider making the path in the pattern qualified: `?::A` - --> $DIR/resolve-inconsistent-names.rs:19:10 +help: if you meant to match on unit variant `E::A`, use the full path in the pattern | -LL | (A, B) | (ref B, c) | (c, A) => () - | ^ +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 @@ -63,11 +62,11 @@ LL | (CONST1, _) | (_, Const2) => () | | | variable not in all patterns | -help: if you meant to match on a variant or a `const` item, consider making the path in the pattern qualified: `?::CONST1` - --> $DIR/resolve-inconsistent-names.rs:30:10 +note: you might have meant to match on constant `m::CONST1`, which exists but is inaccessible + --> $DIR/resolve-inconsistent-names.rs:6:5 | -LL | (CONST1, _) | (_, Const2) => () - | ^^^^^^ +LL | const CONST1: usize = 10; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not accessible error[E0408]: variable `Const2` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:30:9 @@ -77,11 +76,10 @@ LL | (CONST1, _) | (_, Const2) => () | | | pattern doesn't bind `Const2` | -help: if you meant to match on a variant or a `const` item, consider making the path in the pattern qualified: `?::Const2` - --> $DIR/resolve-inconsistent-names.rs:30:27 +help: if you meant to match on constant `m::Const2`, use the full path in the pattern | -LL | (CONST1, _) | (_, Const2) => () - | ^^^^^^ +LL | (CONST1, _) | (_, m::Const2) => () + | ~~~~~~~~~ error[E0308]: mismatched types --> $DIR/resolve-inconsistent-names.rs:19:19 diff --git a/src/test/ui/span/issue-39698.stderr b/src/test/ui/span/issue-39698.stderr index 445df90d395..25c35fd5479 100644 --- a/src/test/ui/span/issue-39698.stderr +++ b/src/test/ui/span/issue-39698.stderr @@ -1,3 +1,13 @@ +error[E0408]: variable `d` is not bound in all patterns + --> $DIR/issue-39698.rs:10:37 + | +LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } + | - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d` + | | | | + | | | pattern doesn't bind `d` + | | variable not in all patterns + | variable not in all patterns + error[E0408]: variable `a` is not bound in all patterns --> $DIR/issue-39698.rs:10:23 | @@ -28,16 +38,6 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | pattern doesn't bind `c` | pattern doesn't bind `c` -error[E0408]: variable `d` is not bound in all patterns - --> $DIR/issue-39698.rs:10:37 - | -LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } - | - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d` - | | | | - | | | pattern doesn't bind `d` - | | variable not in all patterns - | variable not in all patterns - error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0408`. |
