]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: typecheck: Separate assemble_builtin_candidate in two
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 16 Jan 2025 15:55:56 +0000 (16:55 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:06:51 +0000 (13:06 +0100)
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 7fdba1c549b1e83ba0cee126d8336cc79ee63f98..82333f18685eddaf91e8ca8b74f5f041983d4406 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 5db96cc7b41606a14cd5f6eddf2d8d4f1880b2aa..73d686b7814207c295f826c788f901ae481dd35c 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 (),