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

HRTB can't prove some trivially true statements #42114

Closed
djzin opened this issue May 20, 2017 · 4 comments · Fixed by #106879
Closed

HRTB can't prove some trivially true statements #42114

djzin opened this issue May 20, 2017 · 4 comments · Fixed by #106879
Labels
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@djzin
Copy link
Contributor

djzin commented May 20, 2017

fn lifetime<'a>()
    where &'a (): 'a
{
    /* do nothing */
}

fn doesnt_work()
    where for<'a> &'a (): 'a
{
    /* do nothing */
}

fn main() {
    lifetime();
    doesnt_work();
}

Was trying to demonstrate lifetimes of references fulfilling the 'a lifetime bound - but then came across this. The bound can be proven easily for a specific 'a - but for some reason not for the higher-ranked version. The error for doesnt_work looks like this:

rustc 1.19.0-nightly (5dfcd85fd 2017-05-19)
error[E0280]: the requirement `for<'a> &'a () : 'a` is not satisfied
  --> <anon>:15:5
   |
15 |     doesnt_work();
   |     ^^^^^^^^^^^
   |
   = note: required by `doesnt_work`

error: aborting due to previous error
@djzin
Copy link
Contributor Author

djzin commented May 21, 2017

Note this also works:

trait Prove<'a> : 'a {}

impl<'a> Prove<'a> for &'a () {}

fn does_work()
    where for<'a> &'a (): Prove<'a>
{}

but attaching a where bound to the trait impl makes it fail!

trait Prove<'a> : 'a {}

impl<'a> Prove<'a> for &'a () where Self: 'a {}

fn doesnt_work()
    where for<'a> &'a (): Prove<'a>
{}

@Mark-Simulacrum Mark-Simulacrum added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@steveklabnik
Copy link
Member

Triage: original example still does not compile

@oskgo
Copy link
Contributor

oskgo commented Jan 4, 2023

Triage: Both examples compile on rust stable 1.66.0

Seems related to #27113, which should also be closed.

@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.
@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
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jan 14, 2023
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 15, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#106072 (fix: misleading "add dyn keyword before derive macro" suggestion)
 - rust-lang#106859 (Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal)
 - rust-lang#106863 (Remove various double spaces in compiler source comments.)
 - rust-lang#106865 (Add explanation comment for GUI test)
 - rust-lang#106867 (Fix the stability attributes for `std::os::fd`.)
 - rust-lang#106878 (Add regression test for rust-lang#92157)
 - rust-lang#106879 (Add regression test for rust-lang#42114)
 - rust-lang#106880 (doc: fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 30b963c Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. 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.

5 participants