public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Add missing bound to impl-type Self Date: Wed, 8 Jun 2022 11:47:46 +0000 (GMT) [thread overview] Message-ID: <20220608114746.167243985472@sourceware.org> (raw) 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 ();
reply other threads:[~2022-06-08 11:47 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220608114746.167243985472@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).