Skip to content

ICE tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in type_hasher, at rust/backend/rust-compile-context.cc: #4742

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core
//

const A_I8_T: [u32; (&[] as &[_]) as usize] = [0; () + 1];

original:

// Evaluation of constants in array-elem count goes through different
// compiler control-flow paths.
//
// This test is checking the count in an array type.

//@ dont-require-annotations: NOTE

#![allow(unused_imports)]

const A_I8_T
    : [u32; (&[] as &[_]) as usize]
    //~^ ERROR mismatched types
    //~| NOTE expected `i8`, found `u8`
    //~| ERROR cannot add `u8` to `i8`
    = [0; (i8::MAX as usize) + 1];


const A_CHAR_USIZE
    : [u32; 5u8 as char as usize]
    = [0; 5];


const A_BAD_CHAR_USIZE
    : [u32; 5i8 as char as usize]
    //~^ ERROR only `u8` can be cast as `char`, not `i8`
    = [0; 5];

fn main() {}

Version information:

c539964

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

/tmp/icemaker_global_tempdir.flI2N1Vn1tfa/rustc_testrunner_tmpdir_reporting.7Yfx3fzXzwos/mvce.rs:3:21: error: casting ‘& [T?]’ as ‘usize’ is invalid [E0606]
    3 | const A_I8_T: [u32; (&[] as &[_]) as usize] = [0; () + 1];
      |                     ^                ~~~~~
crab1: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in type_hasher, at rust/backend/rust-compile-context.cc:56
0x32edd17 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xacb7e4 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*)
	../../gcc/tree.cc:9266
0x939c50 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*)
	../../gcc/tree.h:3965
0x939c50 Rust::Compile::Context::type_hasher(tree_node*)
	../../gcc/rust/backend/rust-compile-context.cc:56
0x11e502d Rust::Compile::Context::insert_main_variant(tree_node*)
	../../gcc/rust/backend/rust-compile-context.h:92
0x11e502d Rust::Compile::TyTyResolveCompile::create_slice_type_record(Rust::TyTy::SliceType const&)
	../../gcc/rust/backend/rust-compile-type.cc:925
0x11e7a74 Rust::Compile::TyTyResolveCompile::visit(Rust::TyTy::ReferenceType const&)
	../../gcc/rust/backend/rust-compile-type.cc:713
0x11e3435 Rust::Compile::TyTyResolveCompile::compile(Rust::Compile::Context*, Rust::TyTy::BaseType const*, bool)
	../../gcc/rust/backend/rust-compile-type.cc:45
0x11d6fd4 ???
	../../gcc/rust/backend/rust-compile-expr.h:51
0x11cfcba ???
	../../gcc/rust/backend/rust-compile-expr.h:60
0x11d700f ???
	../../gcc/rust/backend/rust-compile-expr.h:51
0x11d3a26 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:166
0x120a9e0 Rust::Compile::HIRCompileBase::compile_constant_item(unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile-base.cc:996
0x120be24 Rust::Compile::HIRCompileBase::compile_constant_expr(Rust::Compile::Context*, unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile-base.cc:642
0x120be24 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
	../../gcc/rust/backend/rust-compile-base.cc:657
0x10c1174 Rust::Resolver::TypeCheckType::visit(Rust::HIR::ArrayType&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:720
0x10c00c7 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:73
0x10c17d7 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:72
0x10a9704 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ConstantItem&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:565
0x10aad5c Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:60
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.flI2N1Vn1tfa/rustc_testrunner_tmpdir_reporting.7Yfx3fzXzwos/mvce.rs -o/tmp/icemaker_global_tempdir.flI2N1Vn1tfa/rustc_testrunner_tmpdir_reporting.7Yfx3fzXzwos/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

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions