diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-05-26 19:30:45 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-05-26 19:18:47 +0000 |
commit | b401e72ba547d2fa595e13f119e3e5e337afc0d9 (patch) | |
tree | 8a5fb3500e2b0f6a6d222fbc194f2644b71e8aae | |
parent | 894e6951cfdd4868a396bde68ac01f0ad28326f0 (diff) | |
download | gcc-b401e72ba547d2fa595e13f119e3e5e337afc0d9.zip gcc-b401e72ba547d2fa595e13f119e3e5e337afc0d9.tar.gz gcc-b401e72ba547d2fa595e13f119e3e5e337afc0d9.tar.bz2 |
gccrs: Fix non canonical type bug with tuples
When working on rpit we needed to change to use a monomorphized clone of
the result of function calls. This ended up causing a verify gimple issue
with tuples because:
fn test<A, B>(a: A, b: B) -> (A, B)
When passing for example:
let a = test::<i32, i32> (123, 456) -> (A=i32, B=i32)
The resulting gimple types became:
const struct (A=i32, B=i32) vs struct (i32, i32)
We removed the VIEW_CONVERT_EXPR support to auto fix this stuff a good
while ago because it hides these kinds of issues because the type hasher
included the A=i32, B=i32 vs the i32, i32 name so updating this to use
get_name instead keeps the naming the same as well as the fields meaning
these types are 100% equivilant and therefore no conversion is required.
This only occurs because tuples are not named types we should really add
more rust specific info on our gimple TYPES.
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): use get_name
* typecheck/rust-tyty.cc (TupleType::get_name): likewise
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
-rw-r--r-- | gcc/rust/backend/rust-compile-type.cc | 2 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc index 5be2b9e..903d0ce 100644 --- a/gcc/rust/backend/rust-compile-type.cc +++ b/gcc/rust/backend/rust-compile-type.cc @@ -454,7 +454,7 @@ TyTyResolveCompile::visit (const TyTy::TupleType &type) } tree struct_type_record = Backend::struct_type (fields); - translated = Backend::named_type (type.as_string (), struct_type_record, + translated = Backend::named_type (type.get_name (), struct_type_record, type.get_ident ().locus); } diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 4da51ff..09a9b97 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -1992,7 +1992,7 @@ TupleType::get_name () const std::string fields_buffer; for (const TyVar &field : get_fields ()) { - fields_buffer += field.get_tyty ()->as_string (); + fields_buffer += field.get_tyty ()->get_name (); bool has_next = (i + 1) < get_fields ().size (); fields_buffer += has_next ? ", " : ""; i++; |