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

Self: 'static causes GAT outlives lint to needlessly fire #90888

Closed
BoxyUwU opened this issue Nov 14, 2021 · 0 comments · Fixed by #91849
Closed

Self: 'static causes GAT outlives lint to needlessly fire #90888

BoxyUwU opened this issue Nov 14, 2021 · 0 comments · Fixed by #91849
Labels
A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Nov 14, 2021

The following code (playground):

#![feature(generic_associated_types)]

trait Trait: 'static {
    type Assoc<'a>;
    fn make_assoc(_: &u32) -> Self::Assoc<'_>;
}

Gives an error:

error: Missing required bounds on Assoc
 --> src/lib.rs:4:5
  |
4 |     type Assoc<'a>;
  |     ^^^^^^^^^^^^^^-
  |                   |
  |                   help: add the required where clauses: `where Self: 'a`

I would have expected the where Self: 'a not to be required as we already know that Self outlives 'a as it outlives 'static

Meta

rustc version: 1.58.0-nightly (e90c5fb 2021-11-12)

@BoxyUwU BoxyUwU added C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs labels Nov 14, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 13, 2021
…r=nikomatsakis

GATs outlives lint: Try to prove bounds

Fixes rust-lang#91036
Fixes rust-lang#90888
Fixes rust-lang#91348 (better error + documentation to be added to linked issue)

Instead of checking for bounds directly, try to prove them in the associated type environment.

Also, add a bit of extra information to the error, including a link to the relevant discussion issue (rust-lang#87479). That should be edited to include a brief summary of the current state of the outlives lint, including a brief background. It also might or might not be worth it to bump this to a full error code at some point.

r? `@nikomatsakis`
@bors bors closed this as completed in 8487833 Dec 13, 2021
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants