Skip to content

rustc crashes when attempting to match a &str #3222

Closed
@Dretch

Description

@Dretch

Given this test case:

fn f(s: &str) {
    match s {
        "a" => (),
         _  => (),
    }
}

fn main() {}

rustc fails with:

rustc: /home/gareth/projects/rust/src/llvm/lib/VMCore/Instructions.cpp:2279: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
Aborted (core dumped)

I have no idea if this code should work or not. If it shouldn't work, I think rustc should emit a nicer error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions