Skip to content

Constants in patterns can contain equality-less types #34784

Closed
@petrochenkov

Description

@petrochenkov

Code:

const C: *const str = "abcd";

fn main() {
    match C {
        C => {}
        _ => {}
    }
}

Diagnostics:

warning: broken MIR (Terminator { source_info: SourceInfo { span: <anon>:5:9: 5:10, scope: scope0 }, kind: tmp1 = <str as std::cmp::PartialEq>::eq(tmp0, const "abcd") -> bb3 }): bad arg #0 (&str <- *const str): Sorts(ExpectedFound { expected: &str, found: *const str })
 --> <anon>:4:11
  |>
4 |>     match C {
  |>           ^

Reproduces on stable/beta/nightly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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