aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-05-02 20:10:39 +0000
committerGitHub <noreply@github.com>2022-05-02 20:10:39 +0000
commit5aec7cbfa560440801dfd0b26e408ab6fb692ed6 (patch)
tree69fff1e277fe7e58f16722ad201861ff97de4a8f
parent694114ea9567d1d7bc96b3d5ce287daede11b941 (diff)
parentd6fb62465635d67a420285c361d74b41c556e9dc (diff)
downloadgcc-5aec7cbfa560440801dfd0b26e408ab6fb692ed6.zip
gcc-5aec7cbfa560440801dfd0b26e408ab6fb692ed6.tar.gz
gcc-5aec7cbfa560440801dfd0b26e408ab6fb692ed6.tar.bz2
Merge #1199
1199: Add new as_name interface for Dynamic types r=philberty a=philberty 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 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
-rw-r--r--gcc/rust/typecheck/rust-tyty-bounds.cc20
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc3
-rw-r--r--gcc/rust/typecheck/rust-tyty.h4
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 bda7a7f..7a1562a 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 6fc395c..fcbf998 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 e2f1aa4..b00237c 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; }