-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Always capture slice when pattern requires checking the length #111831
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
Conversation
|
r? @eholk (rustbot has picked a reviewer for you, use r? to override) |
tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr
Outdated
Show resolved
Hide resolved
981cdea to
f5ae107
Compare
f5ae107 to
403dce4
Compare
|
Nice. I didn't have time during weekend. |
tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs
Outdated
Show resolved
Hide resolved
403dce4 to
e6bab70
Compare
e6bab70 to
ace794c
Compare
|
Thanks! |
…illot Always capture slice when pattern requires checking the length Fixes rust-lang#111751 cc `@zirconium-n,` I see you were assigned to this but I've fixed some similar issues in the past and had an idea on how to investigate this.
…mpiler-errors Rollup of 7 pull requests Successful merges: - rust-lang#107522 (Add Median of Medians fallback to introselect) - rust-lang#111152 (update `pulldown-cmark` to `0.9.3`) - rust-lang#111757 (Consider lint check attributes on match arms) - rust-lang#111831 (Always capture slice when pattern requires checking the length) - rust-lang#111929 (Don't print newlines in APITs) - rust-lang#111945 (Migrate GUI colors test to original CSS color format) - rust-lang#111950 (Remove ExpnKind::Inlined.) r? `@ghost` `@rustbot` modify labels: rollup
| if matches!((lhs, wild, rhs), (&[], Some(_), &[])) | ||
| // Arrays have a statically known size, so | ||
| // there is no need to read their length | ||
| || discr_place.place.base_ty.is_array() |
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.
Does this cause us to emit reads when matching on &[T; N]? If so that might be the cause of #112607
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 doesn't matter if this is the cause, gce is free to be broken
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 does yes. I'll fix it now, since this is definitely incorrect right now
…gillot Don't capture `&[T; N]` when contents isn't read Fixes the check in rust-lang#111831 Fixes rust-lang#112607, although I decided to test the root cause rather than including the example in the issue as a test. cc `@BoxyUwU`
Fixes #111751
cc @zirconium-n, I see you were assigned to this but I've fixed some similar issues in the past and had an idea on how to investigate this.