]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Fix non canonical type bug with tuples
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 26 May 2025 18:30:45 +0000 (19:30 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:36:43 +0000 (16:36 +0200)
commitf4a6ab3e7638bb6c50e11419546b855d85b77a10
tree0c2ea57adccd3c53f6ad2e59e71d33f548ab38f6
parent3c72ed2e711c4cb17fea8e13fa055e2f64dcdcd1
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>
gcc/rust/backend/rust-compile-type.cc
gcc/rust/typecheck/rust-tyty.cc