Rust-GCC / gccrs

GCC Front-End for Rust
https://rust-gcc.github.io/
GNU General Public License v2.0
2.4k stars 155 forks source link

ICE on match expression without any match arms #2567

Open MahadMuhammad opened 1 year ago

MahadMuhammad commented 1 year ago

ICE - match statement having no match arms


Code

enum Empty {}

fn foo(x: Empty) {
    match x {
        // empty
    }
}

Meta


Error output

Backtrace

```bash ➜ gccrs-build gcc/crab1 ../mahad-testsuite/E0002.rs crab1: internal compiler error: in check_match_scrutinee, at rust/backend/rust-compile-expr.cc:1286 0x7c6897 check_match_scrutinee ../../gccrs/gcc/rust/backend/rust-compile-expr.cc:1286 0xcc7d7b Rust::Compile::CompileExpr::visit(Rust::HIR::MatchExpr&) ../../gccrs/gcc/rust/backend/rust-compile-expr.cc:1314 0xcbd394 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr*, Rust::Compile::Context*) ../../gccrs/gcc/rust/backend/rust-compile-expr.cc:45 0xce5194 Rust::Compile::HIRCompileBase::compile_function_body(tree_node*, Rust::HIR::BlockExpr&, Rust::TyTy::BaseType*) ../../gccrs/gcc/rust/backend/rust-compile-base.cc:487 0xce71fe Rust::Compile::HIRCompileBase::compile_function(std::__cxx11::basic_string, std::allocator > const&, Rust::HIR::SelfParam&, std::vector >&, Rust::HIR::FunctionQualifiers const&, Rust::HIR::Visibility&, std::vector >&, unsigned int, Rust::HIR::BlockExpr*, Rust::Resolver::CanonicalPath const*, Rust::TyTy::FnType*) ../../gccrs/gcc/rust/backend/rust-compile-base.cc:643 0xcbac68 Rust::Compile::CompileItem::visit(Rust::HIR::Function&) ../../gccrs/gcc/rust/backend/rust-compile-item.cc:181 0xac42f9 Rust::Compile::CompileItem::compile(Rust::HIR::Item*, Rust::Compile::Context*, Rust::TyTy::BaseType*, bool, unsigned int) ../../gccrs/gcc/rust/backend/rust-compile-item.h:38 0xac42f9 Rust::Compile::CompileCrate::go() ../../gccrs/gcc/rust/backend/rust-compile.cc:47 0xac4348 Rust::Compile::CompileCrate::Compile(Rust::HIR::Crate&, Rust::Compile::Context*) ../../gccrs/gcc/rust/backend/rust-compile.cc:40 0xabe37d Rust::Session::compile_crate(char const*) ../../gccrs/gcc/rust/rust-session-manager.cc:671 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See for instructions. ```


powerboat9 commented 1 year ago

It seems like matching on zero-variant enums isn't supported yet, and any attempt to do so fails an assertion.