-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Matching a const Range #76191
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-patterns
Relating to patterns and pattern matching
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
This is probably #76001 |
Sort of, integrating consts properly into pattern matching has been a long story. #74446 has been the latest chapter. |
This is currently the intended behavior of const patterns – they just compare the matched expression with the constant. The diagnostic could be improved though. |
jonas-schievink
added
A-diagnostics
Area: Messages for errors, warnings, and lints
A-patterns
Relating to patterns and pattern matching
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Sep 1, 2020
I might take a look at improving this diagnostic (fair warning, would be my first contribution) |
Dylan-DPC-zz
pushed a commit
to Dylan-DPC-zz/rust
that referenced
this issue
Sep 12, 2020
Give better suggestion when const Range*'s are used as patterns Fixes rust-lang#76191 let me know if there is more/different information you want to show in this case
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-patterns
Relating to patterns and pattern matching
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
When I was doing rustlings, I found out it is possible to match with a range which is coded like this:
but when I trying to replace the range with a const,
the compiler gives error:
I have no idea why matching a literal range is possible but not matching a constant which type is RangeInclusive.
The text was updated successfully, but these errors were encountered: