Suggest using a qualified path in patterns with inconsistent bindings#63406
Merged
bors merged 2 commits intorust-lang:masterfrom Aug 12, 2019
jakubadamw:resolve-inconsistent-names-suggest-qualified-path
Merged
Suggest using a qualified path in patterns with inconsistent bindings#63406bors merged 2 commits intorust-lang:masterfrom jakubadamw:resolve-inconsistent-names-suggest-qualified-path
bors merged 2 commits intorust-lang:masterfrom
jakubadamw:resolve-inconsistent-names-suggest-qualified-path
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A program like the following one:
is rejected by the compiler due to
Evariant paths not being in scope.In this case
A,Bare resolved as pattern bindings and consequentlythe 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-typeslint.Fixes #50831.