public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add missing bound to impl-type Self
@ 2022-06-08 11:47 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:41d0e2fa96183425eb23d8c5669e3a216d0cea66

commit 41d0e2fa96183425eb23d8c5669e3a216d0cea66
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Thu Nov 4 13:34:45 2021 +0000

    Add missing bound to impl-type Self

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-item.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.h b/gcc/rust/typecheck/rust-hir-type-check-item.h
index fe70035df06..706f649340f 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.h
@@ -70,12 +70,34 @@ public:
 	  }
       }
 
+    std::vector<TyTy::TypeBoundPredicate> specified_bounds;
     TraitReference *trait_reference = &TraitReference::error_node ();
     if (impl_block.has_trait_ref ())
       {
 	std::unique_ptr<HIR::TypePath> &ref = impl_block.get_trait_ref ();
 	trait_reference = TraitResolver::Resolve (*ref.get ());
 	rust_assert (!trait_reference->is_error ());
+
+	// setup the bound
+	TyTy::TypeBoundPredicate predicate (
+	  trait_reference->get_mappings ().get_defid (), ref->get_locus ());
+	auto &final_seg = ref->get_final_segment ();
+	if (final_seg->is_generic_segment ())
+	  {
+	    auto final_generic_seg
+	      = static_cast<HIR::TypePathSegmentGeneric *> (final_seg.get ());
+	    if (final_generic_seg->has_generic_args ())
+	      {
+		HIR::GenericArgs &generic_args
+		  = final_generic_seg->get_generic_args ();
+
+		// this is applying generic arguments to a trait
+		// reference
+		predicate.apply_generic_arguments (&generic_args);
+	      }
+	  }
+
+	specified_bounds.push_back (std::move (predicate));
       }
 
     TyTy::BaseType *self = nullptr;
@@ -86,6 +108,8 @@ public:
 		       "failed to resolve Self for ImplBlock");
 	return;
       }
+    // inherit the bounds
+    self->inherit_bounds (specified_bounds);
 
     bool is_trait_impl_block = !trait_reference->is_error ();


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 11:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 11:47 [gcc/devel/rust/master] Add missing bound to impl-type Self Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).