Open liamnaddell opened 3 months ago
extern "C" { fn printf(s: *const i8, ...); } #[lang = "sized"] pub trait Sized {} struct Foo { my_int: u32, } trait Parent<T> { fn parent(&self) -> T; } trait Child: Parent<u32> { fn child(&self); } impl Parent<u32> for Foo { fn parent(&self) -> u32 { unsafe { let parent = "parent%i\n\0"; let msg = parent as *const str; printf(msg as *const i8,self.my_int); return self.my_int; } } } impl Child for Foo { fn child(&self) { let _ = self; unsafe { let child = "child\n\0"; let msg = child as *const str; printf(msg as *const i8); } } } pub fn main() { let a = Foo{ my_int: 0xf00dfeed}; let b: &dyn Child = &a; b.parent(); b.child(); }
liam@gentoo ~/super2 $ gccrs trait16.rs trait16.rs:18:1: error: cycle detected when computing the super predicates of ‘Child’ [E0391] 18 | trait Child: Parent<u32> { | ^~~~~ crab1: internal compiler error: in resolve_impl_block_substitutions, at rust/typecheck/rust-hir-type-check-item.cc:673
``` crab1: internal compiler error: in resolve_impl_block_substitutions, at rust/typecheck/rust-hir-type-check-item.cc:673 0x1327d4f Rust::Resolver::TypeCheckItem::resolve_impl_block_substitutions(Rust::HIR::ImplBlock&, bool&) ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:673 0x1324eaf Rust::Resolver::TypeCheckItem::ResolveImplBlockSelf(Rust::HIR::ImplBlock&) ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:73 0x138de63 Rust::Resolver::query_type(unsigned int, Rust::TyTy::BaseType**) ../../gccrs/gcc/rust/typecheck/rust-type-util.cc:91 0x130f7c7 operator() ../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:75 0x1312f6f __invoke_impl&, unsigned int, Rust::HIR::ImplBlock*> /usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/invoke.h:61 0x1312df7 __invoke_r&, unsigned int, Rust::HIR::ImplBlock*> /usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/invoke.h:114 0x1312cbf _M_invoke /usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/std_function.h:290 0x11ce63b Rust::Analysis::Mappings::iterate_impl_blocks(std::function) ../../gccrs/gcc/rust/util/rust-hir-map.cc:826 0x130f957 Rust::Resolver::TypeBoundsProbe::scan() ../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:67 0x130f54b Rust::Resolver::TypeBoundsProbe::Probe(Rust::TyTy::BaseType const*) ../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:35 0x12c0c07 Rust::TyTy::BaseType::satisfies_bound(Rust::TyTy::TypeBoundPredicate const&, bool) const ../../gccrs/gcc/rust/typecheck/rust-tyty.cc:296 0x12c121b Rust::TyTy::BaseType::bounds_compatible(Rust::TyTy::BaseType const&, unsigned int, bool) const ../../gccrs/gcc/rust/typecheck/rust-tyty.cc:388 0x12e31d7 Rust::TyTy::SubstitutionParamMapping::fill_param_ty(Rust::TyTy::SubstitutionArgumentMappings&, unsigned int) ../../gccrs/gcc/rust/typecheck/rust-tyty-subst.cc:139 0x1311747 Rust::TyTy::TypeBoundPredicate::apply_generic_arguments(Rust::HIR::GenericArgs*, bool) ../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:502 0x131044b Rust::Resolver::TypeCheckBase::get_predicate_from_bound(Rust::HIR::TypePath&, Rust::HIR::Type*, Rust::BoundPolarity) ../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:295 0x1327d8b Rust::Resolver::TypeCheckItem::resolve_impl_block_substitutions(Rust::HIR::ImplBlock&, bool&) ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:678 0x1324eaf Rust::Resolver::TypeCheckItem::ResolveImplBlockSelf(Rust::HIR::ImplBlock&) ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:73 0x138de63 Rust::Resolver::query_type(unsigned int, Rust::TyTy::BaseType**) ../../gccrs/gcc/rust/typecheck/rust-type-util.cc:91 0x130f7c7 operator() ../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:75 0x1312f6f __invoke_impl&, unsigned int, Rust::HIR::ImplBlock*> /usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/invoke.h:61 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See for instructions. ```
I expected this code to compile, since rustc happily compiles this code.
This was found during testing for #914 Likely does not block the issue, however, it means we have less tests for supertraits.
Code
Meta
Error output
Backtrace
``` crab1: internal compiler error: in resolve_impl_block_substitutions, at rust/typecheck/rust-hir-type-check-item.cc:673 0x1327d4f Rust::Resolver::TypeCheckItem::resolve_impl_block_substitutions(Rust::HIR::ImplBlock&, bool&) ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:673 0x1324eaf Rust::Resolver::TypeCheckItem::ResolveImplBlockSelf(Rust::HIR::ImplBlock&) ../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:73 0x138de63 Rust::Resolver::query_type(unsigned int, Rust::TyTy::BaseType**) ../../gccrs/gcc/rust/typecheck/rust-type-util.cc:91 0x130f7c7 operator() ../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:75 0x1312f6f __invoke_impl&, unsigned int, Rust::HIR::ImplBlock*>
/usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/invoke.h:61
0x1312df7 __invoke_r&, unsigned int, Rust::HIR::ImplBlock*>
/usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/invoke.h:114
0x1312cbf _M_invoke
/usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/std_function.h:290
0x11ce63b Rust::Analysis::Mappings::iterate_impl_blocks(std::function)
../../gccrs/gcc/rust/util/rust-hir-map.cc:826
0x130f957 Rust::Resolver::TypeBoundsProbe::scan()
../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:67
0x130f54b Rust::Resolver::TypeBoundsProbe::Probe(Rust::TyTy::BaseType const*)
../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:35
0x12c0c07 Rust::TyTy::BaseType::satisfies_bound(Rust::TyTy::TypeBoundPredicate const&, bool) const
../../gccrs/gcc/rust/typecheck/rust-tyty.cc:296
0x12c121b Rust::TyTy::BaseType::bounds_compatible(Rust::TyTy::BaseType const&, unsigned int, bool) const
../../gccrs/gcc/rust/typecheck/rust-tyty.cc:388
0x12e31d7 Rust::TyTy::SubstitutionParamMapping::fill_param_ty(Rust::TyTy::SubstitutionArgumentMappings&, unsigned int)
../../gccrs/gcc/rust/typecheck/rust-tyty-subst.cc:139
0x1311747 Rust::TyTy::TypeBoundPredicate::apply_generic_arguments(Rust::HIR::GenericArgs*, bool)
../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:502
0x131044b Rust::Resolver::TypeCheckBase::get_predicate_from_bound(Rust::HIR::TypePath&, Rust::HIR::Type*, Rust::BoundPolarity)
../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:295
0x1327d8b Rust::Resolver::TypeCheckItem::resolve_impl_block_substitutions(Rust::HIR::ImplBlock&, bool&)
../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:678
0x1324eaf Rust::Resolver::TypeCheckItem::ResolveImplBlockSelf(Rust::HIR::ImplBlock&)
../../gccrs/gcc/rust/typecheck/rust-hir-type-check-item.cc:73
0x138de63 Rust::Resolver::query_type(unsigned int, Rust::TyTy::BaseType**)
../../gccrs/gcc/rust/typecheck/rust-type-util.cc:91
0x130f7c7 operator()
../../gccrs/gcc/rust/typecheck/rust-tyty-bounds.cc:75
0x1312f6f __invoke_impl&, unsigned int, Rust::HIR::ImplBlock*>
/usr/lib/gcc/aarch64-unknown-linux-gnu/13/include/g++-v13/bits/invoke.h:61
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See for instructions.
```
Expected output
I expected this code to compile, since rustc happily compiles this code.