]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Refactor marker builtin trait assembly
authorPhilip Herron <herron.philip@googlemail.com>
Sat, 21 Jun 2025 14:40:50 +0000 (15:40 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:36:50 +0000 (16:36 +0200)
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.

gcc/rust/typecheck/rust-hir-type-bounds.h
gcc/rust/typecheck/rust-tyty-bounds.cc

index 82333f18685eddaf91e8ca8b74f5f041983d4406..3cf77733e45ad1667b6e83719175892f047658bf 100644 (file)
@@ -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);
 
index 5d42f80221ee65f206a157a3548b7668c809af4d..a36f7712dac45c9fa08a1d90300c0bdd81740534 100644 (file)
@@ -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: