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

9144da4
Opened by Oli Scherer at 2022-06-22 02:50:45

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> {}
  1. 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,

    • E0279 is not found in the error index (#32777)
    • I think this piece of code should compile, since u32 does implement R<'a, 'static> for every 'a.

    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
    

    kennytm at 2017-04-11 04:57:06

  2. 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`
    

    Esteban Kuber at 2019-09-02 04:09:46

  3. 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

    onlineSoftwareDevOK at 2022-06-18 21:39:40

  4. 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?

    onlineSoftwareDevOK at 2022-06-21 01:57:21

  5. 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?

    onlineSoftwareDevOK at 2022-06-22 02:21:17

  6. 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.

    Esteban Kuber at 2022-06-22 02:50:45