Skip to content

consts in patterns in const contexts with feature effects causes warning (soon: error) about not implementing PartialEq #119398

Closed
@bend-n

Description

@bend-n

Code

#![feature(effects)]
#[derive(Eq, PartialEq)]
pub struct Y(u8);
pub const GREEN: Y = Y(4);
pub const fn is_green(x: Y) -> bool {
    match x { GREEN => true, _ => false }
}

Current output

warning: to use a constant of type `Y` in a pattern, the type must implement `PartialEq`
 --> src/main.rs:7:15
  |
7 |     match x { GREEN => true, _ => false }
  |               ^^^^^
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122>
  = note: `#[warn(const_patterns_without_partial_eq)]` on by default

Desired output

Rationale and extra context

the T is Derive(PartialEq); why does it warn?

Other cases

No response

Anything else?

as requested by @fmease

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_trait_impl`#![feature(const_trait_impl)]`F-effects`#![feature(effects)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions