about summary refs log tree commit diff
path: root/src/test/debuginfo/enum-thinlto.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-08-12 10:58:15 +0200
committerGitHub <noreply@github.com>2019-08-12 10:58:15 +0200
commitab2d7e9a50746cdc21c78336c5e868b6ab834588 (patch)
treea2ae50dda1e6258b66846c35946a1eaf9fad40a3 /src/test/debuginfo/enum-thinlto.rs
parente9615f2487dc2acdad2d1dd7668808728f99e310 (diff)
parent30db4ebdc225521853889b50cc5164646bbe66ed (diff)
downloadrust-ab2d7e9a50746cdc21c78336c5e868b6ab834588.tar.gz
rust-ab2d7e9a50746cdc21c78336c5e868b6ab834588.zip
Rollup merge of #63406 - jakubadamw:resolve-inconsistent-names-suggest-qualified-path, r=petrochenkov
Suggest using a qualified path in patterns with inconsistent bindings

A program like the following one:

```rust
enum E { A, B, C }
fn f(x: E) -> bool {
    match x {
        A | B => false,
        C => true
    }
}
```

is rejected by the compiler due to `E` variant paths not being in scope.
In this case `A`, `B` are resolved as pattern bindings and consequently
the pattern is considered invalid as the inner or-patterns do not bind
to the same set of identifiers.

This is expected but the compiler errors that follow could be surprising
or confusing to some users. This commit adds a help note explaining that
if the user desired to match against variants or consts, they should use
a qualified path. The help note is restricted to cases where the identifier
starts with an upper-case sequence so as to reduce the false negatives.

Since this happens during resolution, there's no clean way to check what
it is the patterns match against. The syntactic criterium, however, is in line
with the convention that's assumed by the `non-camel-case-types` lint.

Fixes #50831.
Diffstat (limited to 'src/test/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions