]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Add check for placeholder (infer) type in return position
authorPhilip Herron <herron.philip@googlemail.com>
Wed, 16 Apr 2025 19:38:17 +0000 (20:38 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Thu, 17 Apr 2025 09:28:24 +0000 (09:28 +0000)
commitbb01719f0e1665a777b2b475e5feaafd01aa3ac8
tree7ae758403f8689e8f0935541d1f9fb4ced8bc8ae
parent50a90f12af84ba2d203a0510bbeb41a383981303
gccrs: Add check for placeholder (infer) type in return position

It is not allowed to have a declared inference variable in the return
position of a function as this may never get infered you need good points
of truth.

Ideally if we get a student for GSoC 25 we will get the Default Hir Visitor
so that we can grab the HIR::InferredType locus instead of using the ref
location lookups.

Fixes Rust-GCC#402

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): add diagnostic
* typecheck/rust-tyty.cc (BaseType::contains_infer): new helper to grab first infer var
* typecheck/rust-tyty.h: prototype

gcc/testsuite/ChangeLog:

* rust/compile/issue-402.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-tyty.cc
gcc/rust/typecheck/rust-tyty.h
gcc/testsuite/rust/compile/issue-402.rs [new file with mode: 0644]