Skip to content

Fix handling of const patterns #3262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2020
Merged

Conversation

flodiebold
Copy link
Member

E.g. in match x { None => ... }, None is a path pattern (resolving to the
option variant), not a binding. To determine this, we need to try to resolve the
name during lowering. This isn't too hard since we already need to resolve names
for macro expansion anyway (though maybe a bit hacky).

Fixes #1618.

E.g. in `match x { None => ... }`, `None` is a path pattern (resolving to the
option variant), not a binding. To determine this, we need to try to resolve the
name during lowering. This isn't too hard since we already need to resolve names
for macro expansion anyway (though maybe a bit hacky).

Fixes rust-lang#1618.
@flodiebold flodiebold requested a review from matklad February 21, 2020 16:02
@matklad
Copy link
Member

matklad commented Feb 22, 2020

Heh, this is surprisingly straightforward! Much simpler than when I've tried to do this myself :)

bors r+

@bors
Copy link
Contributor

bors bot commented Feb 22, 2020

Build succeeded

  • Rust (macos-latest)
  • Rust (ubuntu-latest)
  • Rust (windows-latest)
  • TypeScript

@bors bors bot merged commit baf832d into rust-lang:master Feb 22, 2020
SomeoneToIgnore pushed a commit to SomeoneToIgnore/rust-analyzer that referenced this pull request Feb 22, 2020
3262: Fix handling of const patterns r=matklad a=flodiebold

E.g. in `match x { None => ... }`, `None` is a path pattern (resolving to the
option variant), not a binding. To determine this, we need to try to resolve the
name during lowering. This isn't too hard since we already need to resolve names
for macro expansion anyway (though maybe a bit hacky).

Fixes rust-lang#1618.

Co-authored-by: Florian Diebold <[email protected]>
@flodiebold flodiebold deleted the const-patterns branch February 22, 2020 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Distinguish between constants and bindings in patterns
2 participants