]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: track abi and unsafety on fnptrs for proper type checking
authorPhilip Herron <herron.philip@googlemail.com>
Wed, 3 Sep 2025 19:50:59 +0000 (20:50 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:59:11 +0000 (20:59 +0100)
commit07b7e33869ad04d93eb0f2c68e6a917f6a92d266
tree64122404de8889d6d323187b61ad1997bf5a0104
parenta1a2b612961712e2c1c01d714418c9a57c7aae49
gccrs: track abi and unsafety on fnptrs for proper type checking

We need to distinguish between abi's and unsafety on fnptrs. There is
a commented out check because there is a regression in:

  rust/compile/try-catch-unwind-{new/old}.rs

But i think this is because the test case should be taking an FnOnce
from reading std::panic in rust 1.49. Where as we are passing an fnptr
which is probably because we didnt support fnonce at all then.

Addresses Rust-GCC/gccrs#4090

gcc/rust/ChangeLog:

* hir/tree/rust-hir-item.h: add unsafe helper
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): pass in abi and unsafe
* typecheck/rust-tyty.cc (BaseType::monomorphized_clone): likewise
(FnPtr::as_string): emit more info
(FnPtr::clone): update ctor call
* typecheck/rust-tyty.h: new ctor params
* typecheck/rust-unify.cc (UnifyRules::expect_fnptr): check abi and unsafe

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/hir/tree/rust-hir-item.h
gcc/rust/typecheck/rust-hir-type-check-type.cc
gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-tyty.h
gcc/rust/typecheck/rust-unify.cc