-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Match ergonomics 2024: let &
patterns eat &mut
#124567
Conversation
This comment has been minimized.
This comment has been minimized.
compiler/rustc_hir_typeck/src/pat.rs
Outdated
let pat_info = if r_mutbl == Mutability::Not | ||
&& ((pat.span.at_least_rust_2024() | ||
&& self.tcx.features().ref_pat_eat_one_layer_2024) | ||
|| self.tcx.features().ref_pat_everywhere) | ||
{ | ||
PatInfo { max_ref_mutbl: MutblCap::Not, ..pat_info } |
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.
Could this be done in calc_default_binding_mode
? I think you have all the required info there
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.
Hmm… check_pat_ref
uses shallow_resolve
to get the reference type, but other parts of the module use try_structurally_resolve_type
instead. Do you know what the difference is? Does it matter which one I use?
(Also, I'm not sure moving to calc_default_binding_mode
would be cleaner. Right now, calc_default_binding_mode
manages inherited references and check_pat_ref
manages non-inherited references, which is a reasonably clean separation. Maybe we could do a wider refactor where check_pat_ref
assumes responsibility for all &
/&mut
pattern logic, but that is best left to a future PR I think.)
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 don't know the difference but I don't think it matters here.
The reason I think it's better over on calc_default_binding_mode
is that you already do some max_ref_mutbl
capping there. It would be easier to track in one place. In fact I think this one (line 2213) partially overrides the one on line 359.
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.
a wider refactor where
check_pat_ref
assumes responsibility for all&
/&mut
pattern logic
I did this.
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.
That's great, ty
☔ The latest upstream changes (presumably #124961) made this pull request unmergeable. Please resolve the merge conflicts. |
compiler/rustc_hir_typeck/src/pat.rs
Outdated
let pat_info = if r_mutbl == Mutability::Not | ||
&& ((pat.span.at_least_rust_2024() | ||
&& self.tcx.features().ref_pat_eat_one_layer_2024) | ||
|| self.tcx.features().ref_pat_everywhere) | ||
{ | ||
PatInfo { max_ref_mutbl: MutblCap::Not, ..pat_info } |
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.
That's great, ty
- Only show error when move-check would not be triggered - Add structured suggestion
292dfdc
to
7951311
Compare
Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
Ty! @bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (35c5e67): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 673.288s -> 674.634s (0.20%) |
…4-migration-lint, r=Nadrieril Match ergonomics 2024: migration lint Depends on rust-lang#124567 r? `@Nadrieril` cc rust-lang#123076 `@rustbot` label A-edition-2024 A-patterns
r? @Nadrieril
cc #123076
@rustbot label A-edition-2024 A-patterns