]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Fix bad handling for recursive type query
authorPhilip Herron <herron.philip@googlemail.com>
Tue, 12 Nov 2024 12:16:40 +0000 (12:16 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:32:56 +0000 (12:32 +0100)
commit2992ff08f68e7b9bb36cdeb6747cdc1ee9015d54
tree97a1c133cdcc7f0dcd1cc3fe8cab5e9f9293b7ad
parent1e12ef057250e1d3a4a53697862bc270d9cfa45c
gccrs: Fix bad handling for recursive type query

When resolving a type like this which is generic it causes the argument
substitution to go through bounds checking which is expected. But this
can call a type bounds probe which again calls a type query which will be
on the Impl Type on an impl block which can result in a recursive type
query which does eventually get caught and errors correctly. But this then
triggers some old error diagnositcs which are not valid error codes but old
error messages we used to catch simple errors very early on which do not
apply for this senario.

Fixes Rust-GCC#2905

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::resolve_impl_block_substitutions):
dont check for unconstrained when the self is not resolved
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path):
remove bad debug error diagnostic
* typecheck/rust-tyty-subst.cc: likewise

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-2905-1.rs: New test.
* rust/compile/issue-2905-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-hir-type-check-item.cc
gcc/rust/typecheck/rust-hir-type-check-type.cc
gcc/rust/typecheck/rust-tyty-subst.cc
gcc/testsuite/rust/compile/issue-2905-1.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/issue-2905-2.rs [new file with mode: 0644]
gcc/testsuite/rust/compile/nr2/exclude