Skip to content

unsatisfyable HKL error message prints broken bound (for<'b> 'b : ) #35180

Open

Description

@oli-obk

the full error is

error[E0279]: the requirement `for<'b> 'b : ` is not satisfied (`expected bound lifetime parameter 'b, found concrete lifetime`)
 --> <anon>:2:5
  |
2 |     test::<FooS>(&mut 42);
  |     ^^^^^^^^^^^^
  |
  = note: required because of the requirements on the impl of `for<'b> Foo<'b>` for `FooS<'_>`
  = note: required by `test`

reproducible example on stable, beta and nightly:

fn main() {
    test::<FooS>(&mut 42);
}

trait Foo<'a> {}

struct FooS<'a> {
    data: &'a mut u32,
}

impl<'a, 'b: 'a> Foo<'b> for FooS<'a> {}

fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {}

Activity

  1. kennytm commented on Apr 11, 2017

    @kennytm
    Member

    Another program which produces similar message:

    trait R<'a, 's: 'a> {}
    
    impl<'a, 's: 'a> R<'a, 's> for u32 {}
    
    struct S<X: for<'a> R<'a, 'static>>(X);
    
    fn f(x: S<u32>) {}

    Error:

    error: main function not found
    
    error[E0279]: the requirement `for<'a>  : 'a` is not satisfied (`expected bound lifetime parameter 'a, found concrete lifetime`)
     --> 1.rs:7:1
      |
    7 | fn f(x: S<u32>) {}
      | ^^^^^^^^^^^^^^^^^^
      |
      = note: required because of the requirements on the impl of `for<'a> R<'a, 'static>` for `u32`
      = note: required by `S`
    
    error: aborting due to previous error

    BTW,


    Version:

    rustc 1.18.0-nightly (3b5754e5c 2017-04-10)
    binary: rustc
    commit-hash: 3b5754e5ce73d24c6684b3ed0c68a557dfdd2f52
    commit-date: 2017-04-10
    host: x86_64-apple-darwin
    release: 1.18.0-nightly
    LLVM version: 3.9
    
  2. estebank commented on Sep 2, 2019

    @estebank
    Contributor

    Current output:

    error: implementation of `Foo` is not general enough
     --> src/main.rs:2:5
      |
    2 |     test::<FooS>(&mut 42);
      |     ^^^^^^^^^^^^
      |
      = note: Due to a where-clause on `test`,
      = note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`
      = note: but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1`
    

    The case in the comment now compiles.


    Working on a PR to make the output:

    error: implementation of `Foo` is not general enough
      --> file.rs:2:5
       |
    2  |     test::<FooS>(&mut 42);
       |     ^^^^^^^^^^^^
    ...
    13 | fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {}
       | ------------------------------------------------------------- due to a where-clause on `test`...
       |
       = note: ...`FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`...
       = note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1`
    
  3. added a commit that references this issue on Sep 10, 2019
    11b0ae6
  4. added a commit that references this issue on Sep 10, 2019
    8433952
  5. added a commit that references this issue on Sep 17, 2019
    3edc644
  6. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 27, 2019
  7. onlineSoftwareDevOK commented on Jun 18, 2022

    @onlineSoftwareDevOK
    Contributor

    Is it possible to reproduce E0279 using Rust stable nowadays? I am writing documentation for that error. Every code snippet which used to throw that error now returns implementation of X is not general enough

  8. onlineSoftwareDevOK commented on Jun 21, 2022

    @onlineSoftwareDevOK
    Contributor

    Is it possible to reproduce E0279 using Rust stable nowadays? I am writing documentation for that error. Every code snippet which used to throw that error now returns implementation of X is not general enough

    @estebank Do you know this?

  9. onlineSoftwareDevOK commented on Jun 22, 2022

    @onlineSoftwareDevOK
    Contributor

    Is it possible to reproduce E0279 using Rust stable nowadays? I am writing documentation for that error. Every code snippet which used to throw that error now returns implementation of X is not general enough

    @spastorino @nikomatsakis Do you know this?

  10. estebank commented on Jun 22, 2022

    @estebank
    Contributor

    Theoretically, yes (the code is still there to produce the error), but we have no test for it in the test suite and it's possible that it has been shadowed by other, newer errors.

  11. estebank commented on Jul 30, 2026

    @estebank
    Contributor

    Current output:

    error: implementation of `Foo` is not general enough
     --> src/main.rs:2:5
      |
    2 |     test::<FooS>(&mut 42);
      |     ^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
      |
      = note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`...
      = note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1`
    

    The actual bug (for<'b> 'b :) has been gone for a while. The error isn't great and I would like to revamp it at some point.

  12. estebank commented on Sep 9, 2026

    @estebank
    Contributor

    Current output on nightly:

    error[E0277]: the trait bound `for<'b> FooS<'_>: Foo<'b>` is not satisfied
      --> src/main.rs:2:12
       |
     2 |     test::<FooS>(&mut 42);
       |            ^^^^ unsatisfied trait bound
       |
    help: the trait `Foo<'b>` is not implemented for `FooS<'_>`
          but trait `Foo<'_>` is implemented for it
      --> src/main.rs:11:1
       |
    11 | impl<'a, 'b: 'a> Foo<'b> for FooS<'a> {}
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    note: required by a bound in `test`
      --> src/main.rs:13:44
       |
    13 | fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {}
       |                                            ^^^^^^^^^^^^^^^ required by this bound in `test`
    

    I feel confident we can close this ticket once we enable the new trait solver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions