Skip to content
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

Merged
merged 9 commits into from
May 11, 2024

Conversation

Jules-Bertholet
Copy link
Contributor

r? @Nadrieril

cc #123076

@rustbot label A-edition-2024 A-patterns

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-edition-2024 Area: The 2024 edition A-patterns Relating to patterns and pattern matching labels Apr 30, 2024
compiler/rustc_hir_typeck/src/pat.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_typeck/src/pat.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_typeck/src/pat.rs Show resolved Hide resolved
compiler/rustc_hir_typeck/src/pat.rs Outdated Show resolved Hide resolved
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 4, 2024
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 4, 2024
Comment on lines 2208 to 2213
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 }
Copy link
Member

@Nadrieril Nadrieril May 5, 2024

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

Copy link
Contributor Author

@Jules-Bertholet Jules-Bertholet May 5, 2024

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.)

Copy link
Member

@Nadrieril Nadrieril May 5, 2024

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great, ty

@bors
Copy link
Contributor

bors commented May 10, 2024

☔ The latest upstream changes (presumably #124961) made this pull request unmergeable. Please resolve the merge conflicts.

compiler/rustc_hir_typeck/src/pat.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_typeck/src/pat.rs Show resolved Hide resolved
Comment on lines 2208 to 2213
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 }
Copy link
Member

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
Co-authored-by: Guillaume Boisseau <[email protected]>
@Nadrieril
Copy link
Member

Ty!

@bors r+

@bors
Copy link
Contributor

bors commented May 11, 2024

📌 Commit 6d5c6f5 has been approved by Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 11, 2024
@bors
Copy link
Contributor

bors commented May 11, 2024

⌛ Testing commit 6d5c6f5 with merge 35c5e67...

@bors
Copy link
Contributor

bors commented May 11, 2024

☀️ Test successful - checks-actions
Approved by: Nadrieril
Pushing 35c5e67 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 11, 2024
@bors bors merged commit 35c5e67 into rust-lang:master May 11, 2024
7 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 11, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (35c5e67): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This 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.

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 673.288s -> 674.634s (0.20%)
Artifact size: 316.02 MiB -> 315.86 MiB (-0.05%)

@Jules-Bertholet Jules-Bertholet deleted the and-eats-andmut branch May 11, 2024 15:12
bors added a commit to rust-lang-ci/rust that referenced this pull request May 12, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2024 Area: The 2024 edition A-patterns Relating to patterns and pattern matching merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants