Code change:
Given the example code: I get a really nice warning message about what I did wrong: However, if I change the main function to match multiple patterns: The error message is really confusing with no hint how to fix it: Please expand the error message for the second case to look a bit more like the first case.
Triage: no change. We need to supply the line in E0408.
so I thought I would implement the change you've proposed but have been thinking how best to restrict the kinds of cases where this help note would be appended to the error as I figured it may be rather noisy and/or confusing within the context of some false negatives. So during resolution we of course cannot look at the types to see if it's possible we're matching against an enum. But what do you think about having the help note kick in only if the binding starts with an upper case letter? I know this is a convention that should not really be a concern of the compiler but seeing that using it would only make the diagnostic note a bit more fine-grained, perhaps it's not a terrible idea?
we already do that in some places, like the parser to infer intent, but in this case how would you figure out that you want to suggest and without resolving ? I believe a more holistic solution would be to detect "variable not bound in all patterns" errors where all bindings are single idents, record that fact while throwing the current error and recovering as if there had been a single variable, and later when we have access to the machinery uses emit a warning suggesting and . It is a bit more involved but if we recover as if only had been present the current diagnostic should kick in suggesting (leaving without a suggestion). Edit: that won't work as things stand, as the warning won't be emitted today if there are errors, I think. That would also need to be changed to make it always be emitted :-/
no, I didn't mean to say we need to suggest possible variants. I too concluded that it's non-trivial with the current ordering of passes and the early bailout (indeed, type checking is impossible without resolution succeeding). I was going to add the help note you proposed back in May, just that I would make it dependent on bindings having a Variant-alike naming. From what you're saying there's a precedent in , so I guess this is an acceptable solution? I'll make a PR then.
sorry, I misunderstood. Go ahead, it sounds good.
no, it's likely me who wasn't clear enough. :) I submitted a PR.

Related discussion:
text: |        variable not in all patterns error[E0408]: variable `b` is not bound in all patterns <del> --> $DIR/resolve-inconsistent-names.rs:4:8 </del> <ins> --> $DIR/resolve-inconsistent-names.rs:13:8 </ins> | LL |        a | b => {} |        ^   - variable not in all patterns |        | |        pattern doesn't bind `b` <del> error: aborting due to 2 previous errors </del> <ins> error[E0408]: variable `A` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:19:18 | LL |         (A, B) | (ref B, c) | (c, A) => () |          -       ^^^^^^^^^^       - variable not in all patterns |          |       | |          |       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 | LL |         (A, B) | (ref B, c) | (c, A) => () |          ^ error[E0408]: variable `B` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:19:31 | LL |         (A, B) | (ref B, c) | (c, A) => () |             -         -       ^^^^^^ pattern doesn't bind `B` |             |         | |             |         variable not in all patterns |             variable not in all patterns error[E0408]: variable `c` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:19:9 | LL |         (A, B) | (ref B, c) | (c, A) => () |         ^^^^^^           -     - variable not in all patterns |         |                | |         |                variable not in all patterns |         pattern doesn't bind `c` error[E0409]: variable `B` is bound in inconsistent ways within the same match arm --> $DIR/resolve-inconsistent-names.rs:19:23 | LL |         (A, B) | (ref B, c) | (c, A) => () |             -         ^ bound in different ways |             | |             first binding error[E0408]: variable `CONST1` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:30:23 | LL |         (CONST1, _) | (_, Const2) => () |          ------       ^^^^^^^^^^^ pattern doesn't bind `CONST1` |          | |          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 | LL |         (CONST1, _) | (_, Const2) => () |          ^^^^^^ error[E0408]: variable `Const2` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:30:9 | LL |         (CONST1, _) | (_, Const2) => () |         ^^^^^^^^^^^       ------ variable not in all patterns |         | |         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 | LL |         (CONST1, _) | (_, Const2) => () |                           ^^^^^^ error[E0308]: mismatched types --> $DIR/resolve-inconsistent-names.rs:19:19 | LL |         (A, B) | (ref B, c) | (c, A) => () |                   ^^^^^ expected enum `E`, found &E | = note: expected type `E` found type `&E` error: aborting due to 9 previous errors </ins> <del> For more information about this error, try `rustc --explain E0408`. </del> <ins> Some errors have detailed explanations: E0308, E0408, E0409. For more information about an error, try `rustc --explain E0308`. </ins>