Repository navigation
Matching a const Range #76191
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
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.
Reacted by Jubilee- addedA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Sep 1, 2020 I might take a look at improving this diagnostic (fair warning, would be my first contribution)
- added a commit that references this issue
on Sep 12, 2020 - added a commit that references this issue
on Sep 12, 2020
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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.