Skip to content
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

GAT: Constructing associated types parameterised by lifetime #67089

Closed
dhardy opened this issue Dec 6, 2019 · 3 comments · Fixed by #67160
Closed

GAT: Constructing associated types parameterised by lifetime #67089

dhardy opened this issue Dec 6, 2019 · 3 comments · Fixed by #67160
Labels
A-associated-items Area: Associated items such as associated types and consts. C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dhardy
Copy link
Contributor

dhardy commented Dec 6, 2019

Uses generic associated types - #44265

As I understand it, the following should be legal:

trait A {
    type B<'a>;
    
    fn make_b<'a>(&'a self) -> Self::B<'a>;
}

I simply get an error:

error[E0109]: lifetime arguments are not allowed for this type
 --> src/lib.rs:6:40
  |
6 |     fn make_b<'a>(&'a self) -> Self::B<'a>;
  |                                        ^^ lifetime argument not allowed

Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a4a05477f9f0f529277707801ffd0297

@jonas-schievink jonas-schievink added A-associated-items Area: Associated items such as associated types and consts. C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 6, 2019
@csmoe

This comment has been minimized.

@dhardy
Copy link
Contributor Author

dhardy commented Dec 6, 2019

Then perhaps you'd like to fix this silly example?

@csmoe
Copy link
Member

csmoe commented Dec 6, 2019

@dhardy sorry, my fault. Self::B works here because of lifetime elision, NOT unneeded actually

@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Dec 6, 2019
Centril added a commit to Centril/rust that referenced this issue Dec 21, 2019
…atsakis

Make GATs less ICE-prone.

After this PR simple lifetime-generic associated types can now be used in a compiling program. There are two big limitations:

* rust-lang#30472 has not been addressed in any way (see src/test/ui/generic-associated-types/iterable.rs)
* Using type- and const-generic associated types errors because bound types and constants aren't handled by trait solving.
    * The errors are technically non-fatal, but they happen in a [part of the compiler](https://github.com/rust-lang/rust/blob/4abb0ad2731e9ac6fd5d64d4cf15b7c82e4b5a81/src/librustc_typeck/lib.rs#L298) that fairly aggressively stops compiling on errors.

closes rust-lang#47206
closes rust-lang#49362
closes rust-lang#62521
closes rust-lang#63300
closes rust-lang#64755
closes rust-lang#67089
@bors bors closed this as completed in b50c3b7 Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts. C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants