Skip to content

Incorrect codegen with shadowed constants in a match arm #27077

Closed
@Aatch

Description

@Aatch

From @eefriedman's comment in #27033:

fn main() {
    const C: u8 = 3;
    match 1 {
        C @ 2 => { println!("{}", C); }
        _ => {}
    };
}
<anon>:4:9: 4:14 warning: unused variable: `C`, #[warn(unused_variables)] on by default
<anon>:4         C @ 2 => { println!("{}", C); }
                 ^~~~~
Switch constants must all be same type as switch value!
  switch i32 %3, label %match_else [
    i8 3, label %match_case
  ]
LLVM ERROR: Broken function found, compilation aborted!
playpen: application terminated with error code 1

Not sure how this is happening and the code should be rejected as in #27033, but it does indicate that something in the compiler is probably broken.

cc @rust-lang/compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationT-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