-
Notifications
You must be signed in to change notification settings - Fork 13k
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
typeck: note other end-point when checking range pats #67287
Conversation
| ----------------------- this match expression has type `std::ops::Range<{integer}>` | ||
LL | [..9, 99..100, _] => {}, | ||
| -- ^^^ expected struct `std::ops::Range`, found integer | ||
| | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand what's happening here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first error above is for 99
and the other one is for 100
. They now occur twice because the spans are different and so there's no de-duplication. The type error happens because 99..105
is at type Range<{integer}>
whereas 99..100
is a range pattern at type {integer}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my version I tried changing "this match expression has" to "this match expression requires" in an attempt to clarify these errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to change that, but that can be in a different PR than this (e.g. yours).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I have with this wording is "expected struct std::ops::Range
, found integer", but now I see that the thing being matched is [5..4, 99..105, 43..44]
and not [5, 99, 43]
, which accounts for the weirdness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, and that part hasn't changed as you can see from the diff. :)
This comment has been minimized.
This comment has been minimized.
bec6b77
to
196c27d
Compare
This comment has been minimized.
This comment has been minimized.
196c27d
to
01599fc
Compare
@bors r+ |
📌 Commit 01599fc has been approved by |
⌛ Testing commit 01599fc with merge 85fcf56a2c6d69af187ac70bf5007c7e074578ce... |
…, r=estebank typeck: note other end-point when checking range pats Fixes rust-lang#57389, alternative to rust-lang#67214 that should be less invasive to type checking logic. r? @estebank
This comment has been minimized.
This comment has been minimized.
…, r=estebank typeck: note other end-point when checking range pats Fixes rust-lang#57389, alternative to rust-lang#67214 that should be less invasive to type checking logic. r? @estebank
Rollup of 12 pull requests Successful merges: - #67112 (Refactor expression parsing thoroughly) - #67192 (Various const eval and pattern matching ICE fixes) - #67287 (typeck: note other end-point when checking range pats) - #67459 (prune ill-conceived BTreeMap iter_mut assertion and test its mutability) - #67576 (reuse `capacity` variable in slice::repeat) - #67602 (Use issue = "none" instead of "0" in intrinsics) - #67614 (Set callbacks globally) - #67617 (Remove `compiler_builtins_lib` documentation) - #67629 (Remove redundant link texts) - #67632 (Convert collapsed to shortcut reference links) - #67633 (Update .mailmap) - #67635 (Document safety of Path casting) Failed merges: r? @ghost
This comment has been minimized.
This comment has been minimized.
01599fc
to
c4b6de2
Compare
@bors r=estebank |
📌 Commit c4b6de2 has been approved by |
…, r=estebank typeck: note other end-point when checking range pats Fixes rust-lang#57389, alternative to rust-lang#67214 that should be less invasive to type checking logic. r? @estebank
Rollup of 10 pull requests Successful merges: - #64273 (Stabilize attribute macros on inline modules) - #67287 (typeck: note other end-point when checking range pats) - #67564 (docs: Iterator adapters have unspecified results after a panic) - #67622 (Some keyword documentation.) - #67657 (Clean up const-hack PRs now that const if / match exist.) - #67677 (resolve: Minor cleanup of duplicate macro reexports) - #67687 (Do not ICE on lifetime error involving closures) - #67698 (Move reachable_set and diagnostic_items to librustc_passes.) - #67701 (tidy: Enforce formatting rather than just check it if `--bless` is specified) - #67715 (Typo fix) Failed merges: r? @ghost
Fixes #57389, alternative to #67214 that should be less invasive to type checking logic.
r? @estebank