Skip to content

R raymond/fix/issue 107165 #125716

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

Closed

Conversation

r-raymond
Copy link
Contributor

@r-raymond r-raymond commented May 29, 2024

Fixes #107165

by introducing a suggestion to use the struct pattern:

pub enum Elibrary {
    #[non_exhaustive]
    Unit,

    #[non_exhaustive]
    Tuple(i64),
}

and

    match lib {
        Elibrary::Unit => (),
        _ => (),
    };

    match lib {
        Elibrary::Tuple(_) => (),
        _ => (),
    };

lead to


error[E0603]: unit variant `Unit` is private
  --> $DIR/non-exhaustive-variant-hint-issue-107165.rs:39:19
   |
LL |         Elibrary::Unit => (),
   |                   ^^^^ private unit variant
   |
note: the unit variant `Unit` is defined here
  --> $DIR/auxiliary/non_exhaustive_structs_and_variants_lib.rs:3:5
   |
LL |     #[non_exhaustive]
   |     ----------------- cannot be constructed because it is `#[non_exhaustive]`
LL |     Unit,
   |     ^^^^
help: consider using a struct pattern instead: `Unit { .. }`
  --> $DIR/non-exhaustive-variant-hint-issue-107165.rs:39:19
   |
LL |         Elibrary::Unit => (),
   |                   ^^^^

error[E0603]: tuple variant `Tuple` is private
  --> $DIR/non-exhaustive-variant-hint-issue-107165.rs:45:19
   |
LL |         Elibrary::Tuple(_) => (),
   |                   ^^^^^ private tuple variant
   |
note: the tuple variant `Tuple` is defined here
  --> $DIR/auxiliary/non_exhaustive_structs_and_variants_lib.rs:6:5
   |
LL |     #[non_exhaustive]
   |     ----------------- cannot be constructed because it is `#[non_exhaustive]`
LL |     Tuple(i64),
   |     ^^^^^
help: consider using a struct pattern instead: `Tuple { .. }`
  --> $DIR/non-exhaustive-variant-hint-issue-107165.rs:45:19
   |
LL |         Elibrary::Tuple(_) => (),
   |                   ^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0603`.

@rustbot
Copy link
Collaborator

rustbot commented May 29, 2024

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. labels May 29, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jun 18, 2024

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

@lcnr
Copy link
Contributor

lcnr commented Aug 14, 2024

Please update the PR title and move the PR to "Ready for review" once it's ready

@rustbot author

@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 Aug 14, 2024
@Dylan-DPC
Copy link
Member

@r-raymond any updates on this?

@Dylan-DPC
Copy link
Member

Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks

@Dylan-DPC Dylan-DPC closed this Feb 7, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Pattern-matching on #[non_exhaustive] unit/tuple structs and variants causes confusing diagnostic
6 participants