Skip to content

ICE: in visit, at rust/hir/rust-ast-lower-pattern.cc:258 exlusive range pattern #3659

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
#![feature(exclusive_range_pattern)]

fn main() {
    let x = 3;

    match x {
        0..-1 => 2,
        _ => 3,
    };
}

original:

// Make sure redundant testing paths in `match` expressions are sorted out.

#![feature(exclusive_range_pattern)]

// EMIT_MIR match_test.main.SimplifyCfg-initial.after.mir
fn main() {
    let x = 3;
    let b = true;

    // When `(0..=10).contains(x) && !b`, we should jump to the last arm
    // without testing two other candidates.
    match x {
        0..10 if b..=20 => 1,
        -1 => 2,
        _ => 3,
    };
}

Version information:

7651217

Possibly related line of code:

}
void
ASTLoweringPattern::visit (AST::RangePattern &pattern)
{
if (pattern.get_range_kind () == AST::RangeKind::EXCLUDED)
rust_unreachable (); // Not supported yet
auto upper_bound = lower_range_pattern_bound (pattern.get_upper_bound ());
auto lower_bound = lower_range_pattern_bound (pattern.get_lower_bound ());
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings.get_next_hir_id (crate_num),

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

crab1: internal compiler error: in visit, at rust/hir/rust-ast-lower-pattern.cc:258
0x88ca23 Rust::HIR::ASTLoweringPattern::visit(Rust::AST::RangePattern&)
	../../gcc/rust/hir/rust-ast-lower-pattern.cc:258
0xe6bd46 Rust::HIR::ASTLoweringPattern::translate(Rust::AST::Pattern&, bool)
	../../gcc/rust/hir/rust-ast-lower-pattern.cc:33
0xe5d52e Rust::HIR::ASTLoweringExprWithBlock::visit(Rust::AST::MatchExpr&)
	../../gcc/rust/hir/rust-ast-lower.cc:446
0xe7e908 Rust::HIR::ASTLoweringExprWithBlock::translate(Rust::AST::ExprWithBlock&, bool*)
	../../gcc/rust/hir/rust-ast-lower-block.h:153
0xe7e908 Rust::HIR::ASTLoweringExpr::visit(Rust::AST::MatchExpr&)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:689
0xe87322 Rust::HIR::ASTLoweringExpr::translate(Rust::AST::Expr&, bool*)
	../../gcc/rust/hir/rust-ast-lower-expr.cc:43
0xe92bb7 Rust::HIR::ASTLoweringStmt::visit(Rust::AST::ExprStmt&)
	../../gcc/rust/hir/rust-ast-lower-stmt.cc:50
0xe93247 Rust::HIR::ASTLoweringStmt::translate(Rust::AST::Stmt*, bool*)
	../../gcc/rust/hir/rust-ast-lower-stmt.cc:33
0xe5c00e Rust::HIR::ASTLoweringBlock::visit(Rust::AST::BlockExpr&)
	../../gcc/rust/hir/rust-ast-lower.cc:122
0xe6e3ea Rust::HIR::ASTLoweringBlock::translate(Rust::AST::BlockExpr&, bool*)
	../../gcc/rust/hir/rust-ast-lower-block.h:37
0xe6e3ea Rust::HIR::ASTLoweringItem::visit(Rust::AST::Function&)
	../../gcc/rust/hir/rust-ast-lower-item.cc:444
0xe6f11e Rust::HIR::ASTLoweringItem::translate(Rust::AST::Item&)
	../../gcc/rust/hir/rust-ast-lower-item.cc:38
0xe5cba7 Rust::HIR::ASTLowering::go()
	../../gcc/rust/hir/rust-ast-lower.cc:81
0xe5d0a1 Rust::HIR::ASTLowering::Resolve(Rust::AST::Crate&)
	../../gcc/rust/hir/rust-ast-lower.cc:71
0xce8eb8 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:663
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions