]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Fix ICE when typechecking non-trait item when we expect one
authorPhilip Herron <herron.philip@googlemail.com>
Wed, 2 Oct 2024 14:47:33 +0000 (15:47 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 19 Mar 2025 14:32:16 +0000 (15:32 +0100)
commit308fd792af6c220b505515e6d40e7ba0f9820cf5
tree3eebb2a7582f269c94bdac1353a093639518199e
parentac5821890051d71cf55169c4f7e91801ca5f8ba2
gccrs: Fix ICE when typechecking non-trait item when we expect one

We just had an assertion here for this case where we expect a trait.
This changes the assertion into error handling producing the correct
error code with fixit suggestion like rustc.

Fixes #2499

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
use error handling instead of assertion
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): reuse trait reference
* typecheck/rust-hir-type-check-item.h: update prototype

gcc/testsuite/ChangeLog:

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

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