Skip to content

Required lifetime bounds for GATs in where clauses get removed #4954

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

Closed
jam1garner opened this issue Aug 13, 2021 · 10 comments
Closed

Required lifetime bounds for GATs in where clauses get removed #4954

jam1garner opened this issue Aug 13, 2021 · 10 comments

Comments

@jam1garner
Copy link

Minimal reproduction (playground link, hit 'format' then try building to see it in action):

Before

trait Foo {
    type Arg<'a>;
}

struct Bar<T>(T) where for<'a> T: Foo<Arg<'a> = ()>;

After

trait Foo {
    type Arg<'a>;
}

struct Bar<T>(T)
where
    for<'a> T: Foo<Arg = ()>;
//                             ^^^ note the lack of <'a> bound, which is needed

This will result in the following compiler error:

error[E0107]: missing generics for associated type `Foo::Arg`
 --> src/main.rs:9:20
  |
9 |     for<'a> T: Foo<Arg = ()>;
  |                    ^^^ expected 1 lifetime argument
  |
note: associated type defined here, with 1 lifetime parameter: `'a`
 --> src/main.rs:4:10
  |
4 |     type Arg<'a>;
  |          ^^^ --
help: add missing lifetime argument
  |
9 |     for<'a> T: Foo<Arg<'a> = ()>;
  |                    ~~~~~~~
@raftario
Copy link

Also running into this, will try and look into fixing it and open a PR if I can figure it out

@calebcartwright
Copy link
Member

Thanks @raftario but this has already been fixed in source, just hasn't been released yet.

@calebcartwright
Copy link
Member

we would benefit from getting more test cases added for the various issues that have been reported, can ping you if you're interested in working on that

@raftario
Copy link

Oh that's great to hear, thanks for letting me know. Wouldn't mind getting a couple of tests in if that can be of any help

@calebcartwright
Copy link
Member

Excellent thanks. Will create a new issue with the details tomorrow and tag you

@calebcartwright
Copy link
Member

Closing as the issue was already resolved in source and test case has been added. No ETA yet on exactly when the fix will hit nightly, but it will be in the next release regardless

@chrisbouchard
Copy link

Any word when this fix will be available in nightly in light of the push for GAT stabilization?

@calebcartwright
Copy link
Member

Any word when this fix will be available in nightly in light of the push for GAT stabilization?

This has already been on nightly for quite some time

@chrisbouchard
Copy link

chrisbouchard commented Jan 10, 2022

@calebcartwright Yep, you're right. My editor wasn't using nightly rustfmt. Sorry for the noise!

@calebcartwright
Copy link
Member

@calebcartwright Yep, you're right. My editor wasn't using nightly rustfmt. Sorry for the noise!

No worries. FWIW I believe it'll land on stable with the 1.58 release too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants