Rust-GCC / Rust-GCC/gccrs

ICE in is_refutable, at rust/hir/tree/rust-hir-pattern-abstract.cc:287

Open
#4,739 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core
enum Foo<'a> {
    Bar { field: &u64 },
}

fn in_let() {
    let y = 22;
    let foo = Foo::Bar { field: &y };

    let Foo::Bar::<'static> { field: _z } = foo;
}

original:

enum Foo<'a> {
    Bar { field: &u64 }
}

fn in_let() {
    let y = 22;
    let foo = Foo::Bar { field: &y };
    //~^ ERROR `y` does not live long enough
    let Foo::Bar::<'static> { field: _z } = foo;
}

fn in_match() {
    let y = 22;
    let foo = Foo::Bar { field: &y };
    //~^ ERROR `y` does not live long enough
    match foo {
        Foo::Bar::<'static> { field: _z } => {
        }
    }
}

fn main() { }

Version information:

c539964b8cc842e871d77b45150df6a5882335fb

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/c539964b8cc842e871d77b45150df6a5882335fb/gcc/rust/hir/tree/rust-hir-pattern-abstract.cc#L281-L293

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)

Program output

crab1: internal compiler error: in is_refutable, at rust/hir/tree/rust-hir-pattern-abstract.cc:287
0x32edd17 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xc847b9 fancy_abort(char const*, int, char const*)
	../../gcc/diagnostics/context.cc:1813
0x927fe6 Rust::HIR::StructPattern::is_refutable(Rust::TyTy::BaseType const&) const
	../../gcc/rust/hir/tree/rust-hir-pattern-abstract.cc:287
0x1199a59 Rust::Analysis::PatternChecker::visit(Rust::HIR::LetStmt&)
	../../gcc/rust/checks/errors/rust-hir-pattern-analysis.cc:702
0x1199593 Rust::Analysis::PatternChecker::visit(Rust::HIR::BlockExpr&)
	../../gcc/rust/checks/errors/rust-hir-pattern-analysis.cc:281
0x119a4e3 Rust::Analysis::PatternChecker::go(Rust::HIR::Crate&)
	../../gcc/rust/checks/errors/rust-hir-pattern-analysis.cc:46
0xecc43b Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:815
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.Kh0eHSMMkvzv/rustc_testrunner_tmpdir_reporting.iJly6HyW3yNc/mvce.rs -o/tmp/icemaker_global_tempdir.Kh0eHSMMkvzv/rustc_testrunner_tmpdir_reporting.iJly6HyW3yNc/binaryname -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reduced Rust case with the provided crab1 command, then inspect StructPattern::is_refutable in gcc/rust/hir/tree/rust-hir-pattern-abstract.cc around line 287 and its caller in rust-hir-pattern-analysis.cc. Done means the case no longer triggers an internal compiler error and instead handles the shown pattern and lifetime diagnostic normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.