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

Higher-kinded lifetime bounds could be smarter #26217

Closed
apasel422 opened this issue Jun 11, 2015 · 3 comments · Fixed by #27096
Closed

Higher-kinded lifetime bounds could be smarter #26217

apasel422 opened this issue Jun 11, 2015 · 3 comments · Fixed by #27096
Labels
A-lifetimes Area: Lifetimes / regions A-typesystem Area: The type system

Comments

@apasel422
Copy link
Contributor

The following code fails to compile despite i32: 'static:

fn foo<T>() where for<'a> T: 'a {}

fn main() {
    foo::<i32>();
}

The exact error is:

foo.rs:4:5: 4:15 error: the requirement `for<'a> i32 : 'a` is not satisfied [E0280]
foo.rs:4     foo::<i32>();
             ^~~~~~~~~~

Per @nikomatsakis's comment here, it seems that T: 'static could imply for<'a> T: 'a.

@steveklabnik steveklabnik added A-typesystem Area: The type system A-lifetimes Area: Lifetimes / regions labels Jun 12, 2015
@apasel422
Copy link
Contributor Author

// For now, we just check that there are no higher-ranked
// regions. If there are, we will call this obligation an
// error. Eventually we should be able to support some
// cases here, I imagine (e.g., `for<'a> int : 'a`).
contains the following comment:

// For now, we just check that there are no higher-ranked
// regions. If there are, we will call this obligation an
// error. Eventually we should be able to support some
// cases here, I imagine (e.g., for<'a> int : 'a).

@apasel422
Copy link
Contributor Author

@nikomatsakis I'd be interested in digging into this if you can give me some advice on how to get started.

@nikomatsakis
Copy link
Contributor

@apasel422 hmm, probably best would be to privmsg me on IRC, if that's possible (nmatsakis). It should be fairly easy to write a targeted patch covering cases like for<'a> int : 'a, where the bound region only appears on the RHS; doing a more general fix (e.g., one that handles for<'a> &'a i32 : 'a) would be somewhat harder, though some of the recent refactoring I've been doing would help there.

@oskgo oskgo mentioned this issue Jan 6, 2023
JohnTitor pushed a commit to JohnTitor/rust that referenced this issue Jan 11, 2023
remove E0280

After looking at rust-lang#61137 I tried my hand at E0280. I'm unable to find a reasonable example that emits the error. There are a couple of old examples that compile with the current compiler ([rust-lang#26217](rust-lang#26217), [rust-lang#42114](rust-lang#42114), [rust-lang#27113](rust-lang#27113)) and there is a [bug with chalk](https://github.com/rust-lang/rust/blob/b7cdb635c4b973572307ad288466fba64533369c/src/test/ui/chalkify/bugs/async.rs) that makes it emit the error, with a couple more chalk bugs on zulip.

It seems like the error is supposed to be emitted from unfulfilled where bounds, of which two are related to borrow checking (error in where T: 'a or where 'a: 'b) and thus tend to emit errors like "lifetime may not live long enough" from borrow checking instead. The final case is with type equality constraints (where <T as Iterator>::Item == u32), which is unimplemented ([rust-lang#20041](rust-lang#20041)). That such different problems are supposed to have the same error code also seems strange to me.

Since the error seems to only be emitted when using chalk I propose to remove it and replace it with an ICE instead. A crater run might be warranted.

Pinging `@jackh726` due to removal of chalk test that now ICEs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions A-typesystem Area: The type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants