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

Fulfill additional higher-kinded "outlives" predicates #27113

Closed
apasel422 opened this issue Jul 18, 2015 · 9 comments
Closed

Fulfill additional higher-kinded "outlives" predicates #27113

apasel422 opened this issue Jul 18, 2015 · 9 comments
Labels
A-trait-system Area: Trait system A-type-system Area: Type system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@apasel422
Copy link
Contributor

Types fail to fulfill higher-kinded "outlives" predicates when the higher-kinded region is present on the left-hand side of the predicate. For example:

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

fn main() {
    foo::<i32>();
    //~^ ERROR the requirement `for<'a> &'a i32: 'a` is not satisfied [E0280]
}

CC @nikomatsakis.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 20, 2015
@apasel422
Copy link
Contributor Author

This doesn't actually have to do with diagnostics. A more accurate label would be lifetimes.

@apasel422
Copy link
Contributor Author

@nikomatsakis Any advice for progressing on this?

@apasel422
Copy link
Contributor Author

Ping.

@nikomatsakis
Copy link
Contributor

@apasel422 heh, sorry. I think that solving this is actually going to be a bit tricky. What we really want to do, I think, is refactor how the trait resolution code works so that we can more easily introduce predicates into the environment and check under those assumptions. But probably there's an easier, shorter-term fix here, even if it covers less ground.

@apasel422 apasel422 added A-type-system Area: Type system A-trait-system Area: Trait system and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Dec 14, 2015
@beamspease
Copy link

I ran into this issue, and as I understand it's not possible without some work on Higher Kinded Lifetimes.
https://www.reddit.com/r/rust/comments/3lfl5p/trait_method_that_returns_owned_copy/

Dunno if this is the correct bug to comment on, but I just wanted to note that it seems like it makes it impossible to implement ToOwned for a trait...

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@timotree3
Copy link
Contributor

Is there any progress on this issue? Are Polonius or Chalk going to fix this?

I can reproduce it with something as simple as

trait Foo where for<'a> &'a u64: 'a {}

@Spoonbender
Copy link

Triage: resolved

Both examples compile on stable rustc 1.59.0 (9d1b2106e 2022-02-23)

I think we can close this one

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.
@oskgo
Copy link
Contributor

oskgo commented Jan 12, 2023

@rustbot label +E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 12, 2023
@estebank
Copy link
Contributor

We already have a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system A-type-system Area: Type system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

10 participants