Skip to content

Outlives error for where-clause with HRTB and no trait bounds #95230

Closed
@compiler-errors

Description

@compiler-errors

The following code [playground]:

pub struct Bar
where
    for<'a> &'a mut Self:;

fn main() {}

Should compile, but it does not. Instead it fails with:

error[E0477]: the type `&'a mut Bar` does not fulfill the required lifetime
 --> src/main.rs:3:13
  |
3 |     for<'a> &'a mut Self:;
  |             ^^^^^^^^^^^^
  |
note: type must outlive the empty lifetime as required by this binding
 --> src/main.rs:3:13
  |
3 |     for<'a> &'a mut Self:;
  |             ^^^^^^^^^^^^

I think this is because we instantiate the predicate for<'a> &'a mut Self: ReEmpty(U0) here, which doesn't hold because of the HRTB.

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions