Rust-GCC / Rust-GCC/gccrs

ICE `in resolve_impl_block_substitutions, at rust/typecheck/rust-hir-type-check-item.cc`

Open
#3,932 0 comments 0 reactions 1 assignee View on GitHub

@philberty is already working on this.

Since Sep 15, 2026.

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
enum NonNullary {
    Nullary,
    from(isize),
}

impl NonNullary<NonNullary> for isize {
    fn from() -> isize {}
}

fn from(val: NonNullary) -> isize {
    match val {
        NonNullary::Other(i) => i,
    }
}

original:

// run-rustfix
#![allow(dead_code, unused_variables)]
enum NonNullary {
    Nullary,
    from(isize),
}

impl NonNullary<NonNullary> for isize {
    fn from(val: NonNullary) -> isize {
    let v = NonNullary::Nullary;
    let val = v as isize; //~ ERROR non-primitive cast: `NonNullary` as `isize` [E0605]
}
}

fn from(val: NonNullary) -> isize {
        match val {
            NonNullary::Nullary => 0,
            NonNullary::Other(i) => i,
        }
    }

Version information:

5c3e2adc695b04a199d37cacd8c23b14fdab914f

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5c3e2adc695b04a199d37cacd8c23b14fdab914f/gcc/rust/typecheck/rust-hir-type-check-item.cc#L773-L785

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

Program output

/tmp/icemaker_global_tempdir.0PvUk84um7LW/rustc_testrunner_tmpdir_reporting.cpFUqle5CLfA/mvce.rs:6:6: error: Expected a trait found ‘’ [E0404]
    6 | impl NonNullary<NonNullary> for isize {
      |      ^~~~~~~~~~
      |      not a trait
/tmp/icemaker_global_tempdir.0PvUk84um7LW/rustc_testrunner_tmpdir_reporting.cpFUqle5CLfA/mvce.rs:6:6: error: Expected a trait found ‘’ [E0404]
    6 | impl NonNullary<NonNullary> for isize {
      |      ^~~~~~~~~~
      |      not a trait
crab1: internal compiler error: in resolve_impl_block_substitutions, at rust/typecheck/rust-hir-type-check-item.cc:779
0x2fec938 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
	../../gcc/diagnostic.cc:1803
0x9041e9 Rust::Resolver::TypeCheckItem::resolve_impl_block_substitutions(Rust::HIR::ImplBlock&, bool&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:779
0x10713e6 Rust::Resolver::TypeCheckItem::ResolveImplBlockSelf(Rust::HIR::ImplBlock&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:77
0x1119f6a Rust::Resolver::query_type(unsigned int, Rust::TyTy::BaseType**)
	../../gcc/rust/typecheck/rust-type-util.cc:131
0x10ed72e Rust::Resolver::PathProbeType::process_impl_item_candidate(unsigned int, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*)
	../../gcc/rust/typecheck/rust-hir-path-probe.cc:302
0x10ed72e operator()
	../../gcc/rust/typecheck/rust-hir-path-probe.cc:290
0x10ed72e __invoke_impl<bool, Rust::Resolver::PathProbeType::process_impl_items_for_candidates()::<lambda(Rust::HirId, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*)>&, unsigned int, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*>
	/usr/include/c++/15.1.1/bits/invoke.h:63
0x10ed72e __invoke_r<bool, Rust::Resolver::PathProbeType::process_impl_items_for_candidates()::<lambda(Rust::HirId, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*)>&, unsigned int, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*>
	/usr/include/c++/15.1.1/bits/invoke.h:116
0x10ed72e _M_invoke
	/usr/include/c++/15.1.1/bits/std_function.h:292
0xf3158e std::function<bool (unsigned int, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*)>::operator()(unsigned int, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*) const
	/usr/include/c++/15.1.1/bits/std_function.h:593
0xf3158e Rust::Analysis::Mappings::iterate_impl_items(std::function<bool (unsigned int, Rust::HIR::ImplItem*, Rust::HIR::ImplBlock*)>)
	../../gcc/rust/util/rust-hir-map.cc:818
0x10f02f7 Rust::Resolver::PathProbeType::process_impl_items_for_candidates()
	../../gcc/rust/typecheck/rust-hir-path-probe.cc:288
0x10f02f7 Rust::Resolver::PathProbeType::Probe(Rust::TyTy::BaseType const*, Rust::HIR::PathIdentSegment const&, bool, bool, bool, Rust::DefId)
	../../gcc/rust/typecheck/rust-hir-path-probe.cc:165
0x1130c33 Rust::Resolver::TypeCheckExpr::resolve_segments(unsigned int, std::vector<Rust::HIR::PathExprSegment, std::allocator<Rust::HIR::PathExprSegment> >&, unsigned long, Rust::TyTy::BaseType*, Rust::Analysis::NodeMapping const&, unsigned long)
	../../gcc/rust/typecheck/rust-hir-type-check-path.cc:429
0x1132a8f Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::PathInExpression&)
	../../gcc/rust/typecheck/rust-hir-type-check-path.cc:248
0x109a314 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x1095500 Rust::Resolver::TypeCheckPattern::visit(Rust::HIR::TupleStructPattern&)
	../../gcc/rust/typecheck/rust-hir-type-check-pattern.cc:164
0x1094fcf Rust::Resolver::TypeCheckPattern::Resolve(Rust::HIR::Pattern&, Rust::TyTy::BaseType*)
	../../gcc/rust/typecheck/rust-hir-type-check-pattern.cc:39
0x109b794 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::MatchExpr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1691
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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.