Skip to content

Match ergonomics 2024: mut doesn't reset binding mode #123535

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

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 6, 2024
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@Nadrieril Nadrieril left a comment

Choose a reason for hiding this comment

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

LGTM modulo one detail and one question

EDIT: oops I was only looking at the first commit

@@ -529,6 +529,8 @@ declare_features! (
(unstable, more_qualified_paths, "1.54.0", Some(86935)),
/// Allows the `#[must_not_suspend]` attribute.
(unstable, must_not_suspend, "1.57.0", Some(83310)),
/// Make `mut` not reset the binding mode on edition >= 2024.
(unstable, mut_dont_reset_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)),
Copy link
Member

Choose a reason for hiding this comment

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

This should be incomplete instead of unstable

Copy link
Member

@Nadrieril Nadrieril Apr 13, 2024

Choose a reason for hiding this comment

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

Maybe mut_preserve_binding_mode_2024 to avoid the double negation? I'm fine either way.

Comment on lines 636 to 652
BindingAnnotation(ByRef::No, Mutability::Not) => def_bm,
_ => ba,
BindingAnnotation(ByRef::No, Mutability::Mut)
if !(pat.span.at_least_rust_2024()
&& self.tcx.features().mut_dont_reset_binding_mode_2024)
&& matches!(def_br, ByRef::Yes(_)) =>
{
// `mut x` resets the binding mode in edition <= 2021.
BindingAnnotation(ByRef::No, Mutability::Mut)
}
BindingAnnotation(ByRef::No, mutbl) => BindingAnnotation(def_br, mutbl),
BindingAnnotation(ByRef::Yes(_), _) => ba,
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't preserve old behavior in the case where ba is BindingAnnotation(ByRef::No, Mutability::Not) and def_bm.1 is Mutability::Mut. I guess that can't happen, right? Could we store just a ByRef in PatInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we store just a ByRef in PatInfo?

I think we can, but it would require changes to calc_default_binding_mode, so I'll do it in a later PR so as not to conflict with #123512

Copy link
Member

@Nadrieril Nadrieril left a comment

Choose a reason for hiding this comment

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

Now I've reviewed all commits 👍

@@ -529,6 +529,8 @@ declare_features! (
(unstable, more_qualified_paths, "1.54.0", Some(86935)),
/// Allows the `#[must_not_suspend]` attribute.
(unstable, must_not_suspend, "1.57.0", Some(83310)),
/// Make `mut` not reset the binding mode on edition >= 2024.
(unstable, mut_dont_reset_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)),
Copy link
Member

@Nadrieril Nadrieril Apr 13, 2024

Choose a reason for hiding this comment

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

Maybe mut_preserve_binding_mode_2024 to avoid the double negation? I'm fine either way.

@Nadrieril Nadrieril 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 Apr 13, 2024
@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 Apr 14, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Apr 16, 2024

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

Jules-Bertholet and others added 7 commits April 15, 2024 23:26
Rustfix remains TODO
The lint is unstable, and the lint group `rust_2024_compatibility` must keep working on stable
Co-authored-by: Guillaume Boisseau <Nadrieril@users.noreply.github.com>
@Jules-Bertholet Jules-Bertholet force-pushed the mut_dont_reset_binding_mode_2024 branch from 9f9b051 to 7a32117 Compare April 16, 2024 03:31
@Nadrieril
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 16, 2024

📌 Commit 7a32117 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 Apr 16, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 16, 2024
…ding_mode_2024, r=Nadrieril

Match ergonomics 2024: `mut` doesn't reset binding mode

r? `@Nadrieril`

cc rust-lang#123076

`@rustbot` label A-edition-2024 A-patterns
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#122632 (fetch submodule before checking llvm stamp)
 - rust-lang#123355 (Support type '/' to search)
 - rust-lang#123501 (Stabilize checking of cfgs at compile-time: `--check-cfg` option)
 - rust-lang#123535 (Match ergonomics 2024: `mut` doesn't reset binding mode)
 - rust-lang#123711 (drop `changelog-seen`)
 - rust-lang#123969 (The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes`)
 - rust-lang#124007 (Miri subtree update)
 - rust-lang#124017 (Change a diagnostics-path-only `DefineOpaqueTypes` to `Yes`.)
 - rust-lang#124018 (interpret: pass MemoryKind to before_memory_deallocation)
 - rust-lang#124024 (interpret: remove outdated comment)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit dc40da8 into rust-lang:master Apr 16, 2024
@rustbot rustbot added this to the 1.79.0 milestone Apr 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
Rollup merge of rust-lang#123535 - Jules-Bertholet:mut_dont_reset_binding_mode_2024, r=Nadrieril

Match ergonomics 2024: `mut` doesn't reset binding mode

r? ``@Nadrieril``

cc rust-lang#123076

``@rustbot`` label A-edition-2024 A-patterns
@Jules-Bertholet Jules-Bertholet deleted the mut_dont_reset_binding_mode_2024 branch April 16, 2024 20:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-edition-2024 Area: The 2024 edition A-patterns Relating to patterns and pattern matching 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.

5 participants