https://gcc.gnu.org/g:ecb0e17c41944d340595816e2890f2a7d2053044

commit r15-8724-gecb0e17c41944d340595816e2890f2a7d2053044
Author: Arthur Cohen <arthur.co...@embecosm.com>
Date:   Thu Jan 16 16:55:56 2025 +0100

    gccrs: typecheck: Separate assemble_builtin_candidate in two
    
    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.

Diff:
---
 gcc/rust/typecheck/rust-hir-type-bounds.h |  1 +
 gcc/rust/typecheck/rust-tyty-bounds.cc    | 12 +++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-bounds.h 
b/gcc/rust/typecheck/rust-hir-type-bounds.h
index 7fdba1c549b1..82333f18685e 100644
--- a/gcc/rust/typecheck/rust-hir-type-bounds.h
+++ b/gcc/rust/typecheck/rust-hir-type-bounds.h
@@ -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:
diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc 
b/gcc/rust/typecheck/rust-tyty-bounds.cc
index 5db96cc7b416..73d686b78142 100644
--- a/gcc/rust/typecheck/rust-tyty-bounds.cc
+++ b/gcc/rust/typecheck/rust-tyty-bounds.cc
@@ -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 (),

Reply via email to