Rust-GCC / Rust-GCC/gccrs

ICE `in apply_argument_mappings, at rust/typecheck/rust-tyty-bounds.cc:580`

Open
#3,955 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
trait A: B {
    type Assoc;
}

trait B {}

fn upcast(a: &dyn A<Assoc = i32>) -> &dyn B {
    a
}

original:

//@ check-pass
// issue: 114035
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

trait A: B {
    type Assoc;
}

trait B {}

fn upcast(a: &dyn A<Assoc = i32>) -> &dyn B {
    a
}

// Make sure that we can drop the existential projection `A::Assoc = i32`
// when upcasting `dyn A<Assoc = i32>` to `dyn B`. Before, we used some
// issue: 114035
// different bounds in order to test that an upcast was valid, but this
// didn't allow upcasting to t that have fewer associated types
// than the source type.

fn main() {}

Version information:

5dc8c4d20d62462ebce137c6e5146235ab9e9e2e

Possibly related line of code:
https://github.com/Rust-GCC/gccrs/blob/5dc8c4d20d62462ebce137c6e5146235ab9e9e2e/gcc/rust/typecheck/rust-tyty-bounds.cc#L574-L586

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 apply_argument_mappings, at rust/typecheck/rust-tyty-bounds.cc:580
0x2fecaf8 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0xc0e04d fancy_abort(char const*, int, char const*)
	../../gcc/diagnostic.cc:1803
0x903e03 Rust::TyTy::TypeBoundPredicate::apply_argument_mappings(Rust::TyTy::SubstitutionArgumentMappings&, bool)
	../../gcc/rust/typecheck/rust-tyty-bounds.cc:580
0x105d109 Rust::TyTy::TypeBoundPredicate::apply_argument_mappings(Rust::TyTy::SubstitutionArgumentMappings&, bool)
	../../gcc/rust/typecheck/rust-tyty-bounds.cc:591
0x105d5ae Rust::TyTy::TypeBoundPredicate::apply_generic_arguments(Rust::HIR::GenericArgs*, bool, bool)
	../../gcc/rust/typecheck/rust-tyty-bounds.cc:551
0x105fb94 Rust::Resolver::TypeCheckBase::get_predicate_from_bound(Rust::HIR::TypePath&, tl::optional<std::reference_wrapper<Rust::HIR::Type> >, Rust::BoundPolarity, bool, bool)
	../../gcc/rust/typecheck/rust-tyty-bounds.cc:347
0x108c872 Rust::Resolver::TypeCheckType::visit(Rust::HIR::TraitObjectType&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:674
0x1082477 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:71
0x1082be4 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:67
0x1082be4 Rust::Resolver::TypeCheckType::visit(Rust::HIR::ReferenceType&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:735
0x1082477 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:71
0x10838b7 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type&)
	../../gcc/rust/typecheck/rust-hir-type-check-type.cc:67
0x107409c Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Function&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:598
0x106e185 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gcc/rust/typecheck/rust-hir-type-check-item.cc:59
0x100adcb Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
	../../gcc/rust/typecheck/rust-hir-type-check.cc:74
0xdb97f8 Rust::Session::compile_crate(char const*)
	../../gcc/rust/rust-session-manager.cc:685
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

Start with the reduced Rust reproducer in the issue and run it using the shown crab1 command and compiler flag. Read gcc/rust/typecheck/rust-tyty-bounds.cc around apply_argument_mappings at line 580, then verify the reproducer no longer triggers an internal compiler error and preserves the expected trait-object upcast behavior.

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
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.