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

mark min_exhaustive_patterns as complete #120742

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

Nadrieril
Copy link
Member

This is step 1 and 2 of my proposal to move min_exhaustive_patterns forward. The vast majority of in-tree use cases of exhaustive_patterns are covered by min_exhaustive_patterns. There are a few cases that still require exhaustive_patterns in tests and they're all behind references.

r? @ghost

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 7, 2024
@@ -271,7 +271,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
PatKind::Variant { adt_def, args, variant_index, ref subpatterns } => {
let irrefutable = adt_def.variants().iter_enumerated().all(|(i, v)| {
i == variant_index || {
self.tcx.features().exhaustive_patterns
(self.tcx.features().exhaustive_patterns
Copy link
Member

Choose a reason for hiding this comment

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

what does this do specifically?

Copy link
Member Author

Choose a reason for hiding this comment

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

The following: if the pattern is SomeEnum::Variant3 and all the other variants are uninhabited, then we skip the discriminant test. I don't fully understand why we only do this when the feature is on, my guess is someone was overly-conservative.

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't just for efficiency, this affects closure captures because let Ok((x, _)) = ...; in a closure knows that it only captures the lhs of the tuple. Which I guess is pretty wild.

Copy link
Member Author

Choose a reason for hiding this comment

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

@compiler-errors
Copy link
Member

compiler-errors commented Feb 8, 2024

If you pull 51ada89, b9a1b41, e1df69a into a separate PR, I can approve that immediately. There's nobody you need to ask permission to use a feature in the compiler except for someone from the compiler, so that doesn't need T-lang approval or anything.

I would recommend then 0e76047 landing separately with approval from T-libs after that, along with pointing them to the relevant tracking issues or anything that would increase their confidence that this is a sound subset of the exhaustive patterns feature for use in libcore.

As for 464d5e7, I wonder if all of the modified tests should instead be made into ones that have two revisions between min and full.

@Nadrieril Nadrieril added the F-exhaustive_patterns `#![feature(exhaustive_patterns)]` label Feb 8, 2024
@Nadrieril
Copy link
Member Author

Thank you! I'm thinking I do need approval for marking it as complete because it's a requirement of the T-lang "experimental feature" process I've been using: "This flag has to stay until an RFC is accepted, even if the implementation is in good shape".

@compiler-errors
Copy link
Member

oh huh, didn't know that

@Nadrieril
Copy link
Member Author

I've essentially been side-stepping T-lang to make progress on this (mostly for the never patterns stuff tbh), so I gotta check back with them at some point

@Nadrieril
Copy link
Member Author

I've split off what doesn't require T-lang over there: #120775

@Nadrieril Nadrieril removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 8, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 8, 2024
…piler-errors

Make `min_exhaustive_patterns` match `exhaustive_patterns` better

Split off from rust-lang#120742.

There remained two edge cases where `min_exhaustive_patterns` wasn't behaving like `exhaustive_patterns`. This fixes them, and tests the feature in a bunch more cases. I essentially went through all uses of `exhaustive_patterns` to see which ones would be interesting to compare between the two features.

r? `@compiler-errors`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 8, 2024
Rollup merge of rust-lang#120775 - Nadrieril:more-min_exh_pats, r=compiler-errors

Make `min_exhaustive_patterns` match `exhaustive_patterns` better

Split off from rust-lang#120742.

There remained two edge cases where `min_exhaustive_patterns` wasn't behaving like `exhaustive_patterns`. This fixes them, and tests the feature in a bunch more cases. I essentially went through all uses of `exhaustive_patterns` to see which ones would be interesting to compare between the two features.

r? `@compiler-errors`
@Nadrieril Nadrieril changed the title WIP: use min_exhaustive_patterns where possible mark min_exhaustive_patterns as complete Feb 13, 2024
@Nadrieril
Copy link
Member Author

The FCP is in final comment period. So very likely that in 10 days this can be allowed to be merged.

I've split off the std/core changes to a later PR. What remains is pretty straightforward. In the meantime reopening this for review so it's ready when the FCP completes.

@rustbot ready

@Nadrieril Nadrieril marked this pull request as ready for review February 13, 2024 17:05
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 13, 2024
@Nadrieril
Copy link
Member Author

r? @compiler-errors

@Nadrieril Nadrieril removed the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Feb 15, 2024
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

r=me when the FCP is finished

@compiler-errors compiler-errors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 20, 2024
@compiler-errors compiler-errors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 20, 2024
@Nadrieril
Copy link
Member Author

@bors r=@compiler-errors

@bors
Copy link
Contributor

bors commented Feb 23, 2024

📌 Commit 8e83d0c has been approved by compiler-errors

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 23, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 23, 2024
…iler-errors

mark `min_exhaustive_patterns` as complete

This is step 1 and 2 of my [proposal](rust-lang#119612 (comment)) to move `min_exhaustive_patterns` forward. The vast majority of in-tree use cases of `exhaustive_patterns` are covered by `min_exhaustive_patterns`. There are a few cases that still require `exhaustive_patterns` in tests and they're all behind references.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#120742 (mark `min_exhaustive_patterns` as complete)
 - rust-lang#121470 (Don't ICE on anonymous struct in enum variant)
 - rust-lang#121492 (coverage: Rename `is_closure` to `is_hole`)
 - rust-lang#121495 (remove repetitive words)
 - rust-lang#121498 (Make QNX/NTO specific "timespec capping" public to crate::sys)
 - rust-lang#121510 (lint-overflowing-ops: unify cases and remove redundancy)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 26cb6c7 into rust-lang:master Feb 23, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
Rollup merge of rust-lang#120742 - Nadrieril:use-min_exh_pats, r=compiler-errors

mark `min_exhaustive_patterns` as complete

This is step 1 and 2 of my [proposal](rust-lang#119612 (comment)) to move `min_exhaustive_patterns` forward. The vast majority of in-tree use cases of `exhaustive_patterns` are covered by `min_exhaustive_patterns`. There are a few cases that still require `exhaustive_patterns` in tests and they're all behind references.

r? ``@ghost``
@Nadrieril Nadrieril deleted the use-min_exh_pats branch February 23, 2024 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-exhaustive_patterns `#![feature(exhaustive_patterns)]` 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.

4 participants