]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
typecheck: Separate assemble_builtin_candidate in two
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 16 Jan 2025 15:55:56 +0000 (16:55 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Tue, 21 Jan 2025 13:45:16 +0000 (13:45 +0000)
This paves the way for adding trait bounds that aren't necessarily Sized.

gcc/rust/ChangeLog:

* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::add_trait_bound): New function.
* typecheck/rust-hir-type-bounds.h: Declare it.
(TypeBoundsProbe::assemble_builtin_candidate): Call into add_trait_bound.

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

index 4e781afd2a7ee7232fba07d767483ded1dc3d6bd..114394d13bd83fcc70dde902467415817c6bd20a 100644 (file)
@@ -38,6 +38,7 @@ public:
 private:
   void scan ();
   void assemble_sized_builtin ();
+  void add_trait_bound (HIR::Trait *trait);
   void assemble_builtin_candidate (LangItem::Kind item);
 
 private:
index 23df46c323e817391ed694a5fbeec0c672eebd1e..5d65b94150ca11bd35c868e9273a81fdea16ba56 100644 (file)
@@ -150,6 +150,14 @@ TypeBoundsProbe::assemble_sized_builtin ()
     }
 }
 
+void
+TypeBoundsProbe::add_trait_bound (HIR::Trait *trait)
+{
+  auto trait_ref = TraitResolver::Resolve (*trait);
+
+  trait_references.push_back ({trait_ref, mappings.lookup_builtin_marker ()});
+}
+
 void
 TypeBoundsProbe::assemble_builtin_candidate (LangItem::Kind lang_item)
 {
@@ -167,9 +175,7 @@ TypeBoundsProbe::assemble_builtin_candidate (LangItem::Kind lang_item)
   HIR::Trait *trait = static_cast<HIR::Trait *> (item);
   const TyTy::BaseType *raw = receiver->destructure ();
 
-  // assemble the reference
-  TraitReference *trait_ref = TraitResolver::Resolve (*trait);
-  trait_references.push_back ({trait_ref, mappings.lookup_builtin_marker ()});
+  add_trait_bound (trait);
 
   rust_debug ("Added builtin lang_item: %s for %s",
              LangItem::ToString (lang_item).c_str (),