Strange "type annotations needed" error

trait Trait<'a> {}
trait Foo<'a>: Trait<'a> + for<'b> Trait<'b> {}
error[E0283]: type annotations needed
 --> src/lib.rs:2:16
  |
2 | trait Foo<'a>: Trait<'a> + for<'b> Trait<'b> {}
  |                ^^^^^^^^^ cannot infer type for type parameter `Self`
  |
  = note: cannot satisfy `Self: Trait<'a>`

Isn't it trivially satsifiable? If Foo<'a>: Trait<'b> for any lifetime 'b, it's easily provable that Foo<'a>: Trait<'b> for some lifetime 'b ('b == 'a, in this case)!

Is this a bug in the compiler, or am I missing something?

1 Like

Looks like a bug to me, potentially related to

feel free to check e. g. if the behavior on old rust versions follows the same pattern.

2 Likes

Is there a way to bisect it automatically? cargo-bisect-rustc walks nightly-by-nightly :astonished:

IIRC, I was just manually checking stable versions on godbolt.org in that issue.

Edit: Actually, looking back at the issue, I do talk about nightlies there after all.... anyways, checking whether the stable versions behave the same is probably sufficient information to form a good guess whether or not it's "the same" issue.

Edit2: You can also install the nightlies mentioned in the issue manually and just check whether or not behavior changes in the same way at the same points.

Edit3: Regarding cargo-bisect-rustc, I don't know what you mean by "walks nightly-by-nightly", maybe you didn't pass it a start point and end point?

1 Like

Yes, because I didn't know what the start point is :slight_smile: But using godbolt is a good idea.

FYI, IIRC, it does start to speed up eventually, going faster than nightly-by-nightly. But that speedup is slower than one might hope for.

Well, it looks like the same bug: 1.0-1.3 works, 1.4-1.6 ICEs, and 1.7+ gives this error. Thanks!

Since the test-case is somewhat different, feel free to post your code example to that issue thread nonetheless.

1 Like