Skip to content

gccrs: remove horrible hack in solving complex generics on impl blocks #2549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2023

Conversation

philberty
Copy link
Member

We hit an assertion with range based iterators here. This code was used to solve complex generics such as:

struct Foo<X,Y>(X,Y);
impl Foo<T, i32> {
fn test(self, a: Y) { }
}

The impl item will have the signiture of:

fn test<T,Y> (Foo<T, i32> self, a:Y)

So in the case where we have:

let a = Foo(123f32, 456);
a.test(true);

We need to solve the generic argument T from the impl block by infering the arguments there and applying them so that when we apply the generic argument bool we dont end up in the case of missing number of generics.

Addresses #1895

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): remove hack

We hit an assertion with range based iterators here. This code was used
to solve complex generics such as:

  struct Foo<X,Y>(X,Y);
  impl<T> Foo<T, i32> {
    fn test<Y>(self, a: Y) { }
  }

The impl item will have the signiture of:

  fn test<T,Y> (Foo<T, i32> self, a:Y)

So in the case where we have:

  let a = Foo(123f32, 456);
  a.test<bool>(true);

We need to solve the generic argument T from the impl block by infering the
arguments there and applying them so that when we apply the generic
argument bool we dont end up in the case of missing number of generics.

Addresses #1895

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): remove hack

Signed-off-by: Philip Herron <[email protected]>
@philberty philberty added the bug label Aug 12, 2023
@philberty philberty added this to the GCC 14 Stage 3 milestone Aug 12, 2023
@philberty philberty self-assigned this Aug 12, 2023
@philberty philberty mentioned this pull request Aug 12, 2023
41 tasks
@philberty philberty added this pull request to the merge queue Aug 12, 2023
Merged via the queue into master with commit 9ae3c20 Aug 12, 2023
@philberty philberty deleted the phil/generics-hack branch September 17, 2023 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant