Skip to content

Tracking issue for release notes of #122792: Stabilize min_exhaustive_patterns #129579

Closed

Description

@rustbot

This issue tracks the release notes text for #122792.

  • Issue is nominated for the responsible team (and T-release nomination is removed).
  • Proposed text is drafted by team responsible for underlying change.
  • Issue is nominated for release team review of clarity for wider audience.
  • Release team includes text in release notes/blog posts.

Release notes text:

The section title will be de-duplicated by the release team with other release notes issues.
Prefer to use the standard titles from previous releases.
More than one section can be included if needed.

# Language
- [Patterns matching empty types can now be omitted in common cases](https://github.com/rust-lang/rust/pull/122792)

Release blog section (if any, leave blank if no section is expected):

Empty patterns can now be omitted in common cases:

```rust
pub fn safe_unwrap<T>(x: Result<T, !>) -> T {
    let Ok(x) = x; // the `Err` case does not need to appear
    x
}

// TODO: other examples, maybe std's PoisonError?
```

This is particularly useful in combination with the never type `!`, but also works with other empty types such a variantless enum (`enum Void {}`).

For reasons related to uninitialized values and unsafe code, this behavior is not allowed if the empty type is accessed through a reference, pointer, or union field:
```rust
pub fn safe_unwrap_ref<T>(x: &Result<T, !>) -> &T {
    match x {
        Ok(x) => x,
        Err(never) => match *never {}, // this branch cannot be omitted because of the reference
    }
}
```

To avoid interfering with crates that wish to support several rust versions, these branches are not yet warned as "unreachable", despite the fact that they can be removed.

Activity

  1. added
    relnotesMarks issues that should be documented in the release notes of the next release.
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 25, 2024
  2. added
    I-lang-nominatedNominated for discussion during a lang team meeting.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 25, 2024
  3. Mark-Simulacrum commented on Aug 25, 2024

    @Mark-Simulacrum
    Member

    This may or may not want to incorporate notes for #129031.

  4. added
    T-releaseRelevant to the release subteam, which will review and decide on the PR/issue.
    on Aug 25, 2024
  5. added this to the 1.82.0 milestone on Aug 27, 2024
  6. traviscross commented on Aug 28, 2024

    @traviscross
    Contributor

    @Nadrieril: What do you think?

    cc @rust-lang/lang

  7. Nadrieril commented on Sep 7, 2024

    @Nadrieril
    Member

    Should I edit the OP? I'm not sure how this works.

  8. added
    T-langRelevant to the language team
    relnotesMarks issues that should be documented in the release notes of the next release.
    relnotes-tracking-issueMarks issues tracking what text to put in release notes.
    and removed
    relnotesMarks issues that should be documented in the release notes of the next release.
    I-lang-nominatedNominated for discussion during a lang team meeting.
    relnotes-tracking-issueMarks issues tracking what text to put in release notes.
    on Sep 24, 2024
  9. Mark-Simulacrum commented on Oct 2, 2024

    @Mark-Simulacrum
    Member

    Yes. I've revised the release note section a bit to not reference the semi-internal name (min_exhaustive_patterns) which we try to stay away from in favor of something more user-facing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-release-nominatedNominated for the release team.T-langRelevant to the language teamT-releaseRelevant to the release subteam, which will review and decide on the PR/issue.relnotesMarks issues that should be documented in the release notes of the next release.relnotes-tracking-issueMarks issues tracking what text to put in release notes.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions