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 new as_name interface for Dynamic types Date: Wed, 8 Jun 2022 12:41:36 +0000 (GMT) [thread overview] Message-ID: <20220608124136.6C64B386CE45@sourceware.org> (raw) https://gcc.gnu.org/g:d6fb62465635d67a420285c361d74b41c556e9dc commit d6fb62465635d67a420285c361d74b41c556e9dc Author: Philip Herron <philip.herron@embecosm.com> Date: Sat Apr 30 13:44:16 2022 +0100 Add new as_name interface for Dynamic types The Gimple names of our dyn trait objects were looking like: const struct dyn [HIR Trait: FnLike->[C: 0 Nid: 31 Hid: 38 Lid: 13] [(FN call ), ]<Self, &isize, &isize>] & const f This is a horrible name but useful for debugging this patch fixes this so we have a seperate naming for generating the type. So now it looks like: const struct dyn [FnLike<Self, &isize, &isize>] & const f Diff: --- gcc/rust/typecheck/rust-tyty-bounds.cc | 20 ++++++++++++++++++++ gcc/rust/typecheck/rust-tyty.cc | 3 +-- gcc/rust/typecheck/rust-tyty.h | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc b/gcc/rust/typecheck/rust-tyty-bounds.cc index bda7a7f47a6..7a1562ab544 100644 --- a/gcc/rust/typecheck/rust-tyty-bounds.cc +++ b/gcc/rust/typecheck/rust-tyty-bounds.cc @@ -215,6 +215,12 @@ TypeBoundPredicate::as_string () const return get ()->as_string () + subst_as_string (); } +std::string +TypeBoundPredicate::as_name () const +{ + return get ()->get_name () + subst_as_string (); +} + const Resolver::TraitReference * TypeBoundPredicate::get () const { @@ -432,6 +438,20 @@ TypeBoundsMappings::bounds_as_string () const return "bounds:[" + raw_bounds_as_string () + "]"; } +std::string +TypeBoundsMappings::raw_bounds_as_name () const +{ + std::string buf; + for (size_t i = 0; i < specified_bounds.size (); i++) + { + const TypeBoundPredicate &b = specified_bounds.at (i); + bool has_next = (i + 1) < specified_bounds.size (); + buf += b.as_name () + (has_next ? " + " : ""); + } + + return buf; +} + void TypeBoundsMappings::add_bound (TypeBoundPredicate predicate) { diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 6fc395c572b..fcbf9986d7d 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -2867,8 +2867,7 @@ DynamicObjectType::clone () const std::string DynamicObjectType::get_name () const { - std::string bounds = "[" + raw_bounds_as_string () + "]"; - return "dyn " + bounds; + return "dyn [" + raw_bounds_as_name () + "]"; } bool diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index e2f1aa49c8b..b00237c1c27 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -124,6 +124,8 @@ public: std::string bounds_as_string () const; + std::string raw_bounds_as_name () const; + protected: void add_bound (TypeBoundPredicate predicate); @@ -1019,6 +1021,8 @@ public: std::string as_string () const; + std::string as_name () const; + const Resolver::TraitReference *get () const; Location get_locus () const { return locus; }
reply other threads:[~2022-06-08 12:41 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=20220608124136.6C64B386CE45@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).