Skip to content

Associated Type Binding - Internal Compile Error #2369

@MahadMuhammad

Description

@MahadMuhammad

Associated Type Binding - Internal Compile Error


Tested this code on E0229

// https://doc.rust-lang.org/error_codes/E0229.html
#![allow(unused)]
fn main() {
pub trait Foo {
    type A;
    fn boo(&self) -> <Self as Foo>::A;
}

struct Bar;

impl Foo for isize {
    type A = usize;
    fn boo(&self) -> usize { 42 }
}

fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
// error: associated type bindings are not allowed here
}

Expected Output:

  • Should give error E0229 like rustc.
  • rustc output:
mahad@linux:~/Desktop/mahad/gccrs-build$ rustc ../mahad-testsuite/E0229.rs 
error[E0229]: associated type bindings are not allowed here
  --> ../mahad-testsuite/E0229.rs:16:25
   |
16 | fn baz<I>(x: &<I as Foo<A=Bar>>::A) {}
   |                         ^^^^^ associated type not allowed here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0229`.

But this happened:

  • Internal compiler error.
mahad@linux:~/Desktop/mahad/gccrs-build$ gcc/crab1 ../mahad-testsuite/E0229.rs -frust-incomplete-and-experimental-compiler-do-not-use
crab1: internal compiler error: in append_reference_for_def, at rust/resolve/rust-name-resolver.cc:257
0x7b9b15 Rust::Resolver::Scope::append_reference_for_def(unsigned int, unsigned int)
	../../gccrs/gcc/rust/resolve/rust-name-resolver.cc:257
0x7b9b15 Rust::Resolver::Scope::append_reference_for_def(unsigned int, unsigned int)
	../../gccrs/gcc/rust/resolve/rust-name-resolver.cc:246
0xbaf86a Rust::Resolver::Resolver::insert_resolved_type(unsigned int, unsigned int)
	../../gccrs/gcc/rust/resolve/rust-name-resolver.cc:492
0xc22bc0 Rust::Resolver::TypeCheckType::visit(Rust::HIR::QualifiedPathInType&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-type.cc:304
0xc21175 Rust::Resolver::TypeCheckType::Resolve(Rust::HIR::Type*)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-type.cc:64
0xbde154 Rust::Resolver::TraitItemReference::get_type_from_fn(Rust::HIR::TraitItemFunc&) const
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check.cc:190
0xc0aad6 Rust::TyTy::TypeBoundPredicateItem::get_tyty_for_receiver(Rust::TyTy::BaseType const*)
	../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:539
0xc39b9b Rust::Resolver::TypeCheckImplItemWithTrait::visit(Rust::HIR::Function&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-implitem.cc:523
0xc38d6d Rust::Resolver::TypeCheckImplItemWithTrait::Resolve(Rust::HIR::ImplBlock*, Rust::HIR::ImplItem*, Rust::TyTy::BaseType*, Rust::TyTy::TypeBoundPredicate&, std::vector<Rust::TyTy::SubstitutionParamMapping, std::allocator<Rust::TyTy::SubstitutionParamMapping> >)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-implitem.cc:372
0xc1d73a Rust::Resolver::TypeC[E0229](https://doc.rust-lang.org/error_codes/E0229.html)heckItem::validate_trait_impl_block(Rust::HIR::ImplBlock&, Rust::TyTy::BaseType*, std::vector<Rust::TyTy::SubstitutionParamMapping, std::allocator<Rust::TyTy::SubstitutionParamMapping> >&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:614
0xc1e2f3 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::ImplBlock&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:409
0xc17cd0 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:49
0xc17cd0 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:35
0xc34cbf ???
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-stmt.h:36
0xc34d9c Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt*)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
0xc2cb14 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:540
0xc2b7b3 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr*)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-expr.cc:41
0xc1d213 Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Function&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:496
0xc17cd0 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:49
0xc17cd0 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
	../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:35
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.

Which version of gccrs, I was using 8628813


Metadata

Metadata

Assignees

Labels

bugdiagnosticdiagnostic static analysis

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions