Skip to content

HRTB can't prove some trivially true statements #42114

Closed
@djzin

Description

@djzin
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions