aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-01-16 16:55:56 +0100
committerPhilip Herron <philip.herron@embecosm.com>2025-01-21 13:45:16 +0000
commit9e876359e38d6849c64b7352dc560e0264a7300c (patch)
tree2563d426ac4560d6abbd728977156f317565ca38 /gcc
parent9c6e09e2f73c056ad30382a5d000d938e1dfd473 (diff)
downloadgcc-9e876359e38d6849c64b7352dc560e0264a7300c.zip
gcc-9e876359e38d6849c64b7352dc560e0264a7300c.tar.gz
gcc-9e876359e38d6849c64b7352dc560e0264a7300c.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-bounds.h1
-rw-r--r--gcc/rust/typecheck/rust-tyty-bounds.cc12
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 4e781af..114394d 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 23df46c..5d65b94 100644
--- a/gcc/rust/typecheck/rust-tyty-bounds.cc
+++ b/gcc/rust/typecheck/rust-tyty-bounds.cc
@@ -151,6 +151,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)
{
auto lang_item_defined = mappings.lookup_lang_item (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 (),