Skip to content

ICE in find_value_definition, at rust/checks/lints/rust-lint-marklive.cc match guard with unknown enum variant #4670

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core
pub enum Something {
    Cat(u64),
    Dog(u64),
}

fn main() {
    let my_int: i32 = 1;

    match my_int {
        x if x == Something::Foo as i32 => {}

        _ => {}
    }
}

original:

#[repr(i32)]
pub enum Something {
    Cat(u64),
    Dog(u64),
}

fn main() {
    let my_int: i32 = 1;

    match my_int {
        x if x == Something::Foo as i32 => {}
        //1 => {} // Warning: no value can reach this
        x if x == Something::Foo as i32 => {}
        x if x == Something::Foo as i32 => {} // No warning
        x if x == Something::Foo as i32 => {} // No warning
        x if x == Something::Blarg as i32 => {}
        _ => {}
    }
}

Version information:

206d052

Possibly related line of code:

void
MarkLive::find_value_definition (NodeId ast_node_id, NodeId &ref_node_id)
{
auto resolved = resolver.lookup (ast_node_id, Resolver2_0::Namespace::Values,
Resolver2_0::Namespace::Types);
rust_assert (resolved.has_value ());
ref_node_id = resolved->id;
}
} // namespace Analysis
} // namespace Rust

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 find_value_definition, at rust/checks/lints/rust-lint-marklive.cc:284
0x32c99c7 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xc7f8e1 fancy_abort(char const*, int, char const*)
	../../gcc/diagnostics/context.cc:1813
0x92516c Rust::Analysis::MarkLive::find_value_definition(unsigned int, unsigned int&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:284
0x925208 Rust::Analysis::MarkLive::find_value_definition(unsigned int, unsigned int&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:124
0x925208 Rust::Analysis::MarkLive::visit(Rust::HIR::PathInExpression&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:120
0x117c776 Rust::Analysis::MarkLive::visit(Rust::HIR::MatchExpr&)
	../../gcc/rust/checks/lints/rust-lint-marklive.h:215
0x117a880 Rust::Analysis::MarkLive::go(Rust::HIR::Crate&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:95
0x117ac24 Rust::Analysis::MarkLive::Analysis(Rust::HIR::Crate&)
	../../gcc/rust/checks/lints/rust-lint-marklive.cc:75
0xed0977 Rust::Analysis::ScanDeadcode::Scan(Rust::HIR::Crate&)
	../../gcc/rust/checks/lints/rust-lint-scan-deadcode.h:45
0xec977c Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:857
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.uWTdLfAKpi0h/rustc_testrunner_tmpdir_reporting.Uw5XMoCnQ6pG/mvce.rs -o/tmp/icemaker_global_tempdir.uWTdLfAKpi0h/rustc_testrunner_tmpdir_reporting.Uw5XMoCnQ6pG/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmissing-lintA warning or error is missing and gccrs is not restrictive enoughname resolution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions