https://gcc.gnu.org/g:72c83626309b40ce327350d1ddf70bcf998a26c7

commit r16-2887-g72c83626309b40ce327350d1ddf70bcf998a26c7
Author: Philip Herron <herron.phi...@googlemail.com>
Date:   Sat Jun 21 15:40:50 2025 +0100

    gccrs: Refactor marker builtin trait assembly
    
    Rename assemble_sized_builtin to assemble_marker_builtins and reorganize
    the type matching to properly handle function pointers and closures with
    their associated traits (Fn, FnMut, FnOnce).
    
    gcc/rust/ChangeLog:
    
            * typecheck/rust-hir-type-bounds.h: Rename method.
            * typecheck/rust-tyty-bounds.cc: Refactor marker trait assembly
            and add proper Fn trait handling for function types.

Diff:
---
 gcc/rust/typecheck/rust-hir-type-bounds.h |  2 +-
 gcc/rust/typecheck/rust-tyty-bounds.cc    | 14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-bounds.h 
b/gcc/rust/typecheck/rust-hir-type-bounds.h
index 82333f18685e..3cf77733e45a 100644
--- a/gcc/rust/typecheck/rust-hir-type-bounds.h
+++ b/gcc/rust/typecheck/rust-hir-type-bounds.h
@@ -37,7 +37,7 @@ public:
 
 private:
   void scan ();
-  void assemble_sized_builtin ();
+  void assemble_marker_builtins ();
   void add_trait_bound (HIR::Trait *trait);
   void assemble_builtin_candidate (LangItem::Kind item);
 
diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc 
b/gcc/rust/typecheck/rust-tyty-bounds.cc
index 5d42f80221ee..a36f7712dac4 100644
--- a/gcc/rust/typecheck/rust-tyty-bounds.cc
+++ b/gcc/rust/typecheck/rust-tyty-bounds.cc
@@ -105,7 +105,7 @@ TypeBoundsProbe::scan ()
     }
 
   // marker traits...
-  assemble_sized_builtin ();
+  assemble_marker_builtins ();
 
   // add auto trait bounds
   for (auto *auto_trait : mappings.get_auto_traits ())
@@ -113,7 +113,7 @@ TypeBoundsProbe::scan ()
 }
 
 void
-TypeBoundsProbe::assemble_sized_builtin ()
+TypeBoundsProbe::assemble_marker_builtins ()
 {
   const TyTy::BaseType *raw = receiver->destructure ();
 
@@ -132,7 +132,6 @@ TypeBoundsProbe::assemble_sized_builtin ()
     case TyTy::POINTER:
     case TyTy::PARAM:
     case TyTy::FNDEF:
-    case TyTy::FNPTR:
     case TyTy::BOOL:
     case TyTy::CHAR:
     case TyTy::INT:
@@ -140,7 +139,6 @@ TypeBoundsProbe::assemble_sized_builtin ()
     case TyTy::FLOAT:
     case TyTy::USIZE:
     case TyTy::ISIZE:
-    case TyTy::CLOSURE:
     case TyTy::INFER:
     case TyTy::NEVER:
     case TyTy::PLACEHOLDER:
@@ -149,6 +147,14 @@ TypeBoundsProbe::assemble_sized_builtin ()
       assemble_builtin_candidate (LangItem::Kind::SIZED);
       break;
 
+    case TyTy::FNPTR:
+    case TyTy::CLOSURE:
+      assemble_builtin_candidate (LangItem::Kind::SIZED);
+      assemble_builtin_candidate (LangItem::Kind::FN_ONCE);
+      assemble_builtin_candidate (LangItem::Kind::FN);
+      assemble_builtin_candidate (LangItem::Kind::FN_MUT);
+      break;
+
       // FIXME str and slice need to be moved and test cases updated
     case TyTy::SLICE:
     case TyTy::STR:

Reply via email to