Open tuxmark5 opened 2 years ago
Replacing the box_static_block
call with box_static_block::<<<T as Table>::Blocks<'a> as Iterator>::Item>(block)
makes this pass...looking into this now
Looking more into this, it looks somewhat related to the autoderef on table.blocks()
: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=186ffccf48c7b69388263f638a6a4a7b
Still looking
Ok, so I'll talk to Niko about this sometime soonish, but for now, here's a basic analysis of what's going on. I'll use the Foo
trait from the playground above rather than Iterator
, just for simplicity.
When we call table.blocks()
, rustc essentially makes the return of this <T as Table>::Blocks<'_#1r>
, where '_#1r
is some lifetime. Then, we call blocks.item()
to get a block
of type <<T as Table>::Blocks<'_#1r> as Foo>::Item
. To pass this to box_static_block
, we need that to outlive static. Well, we know that <<T as Table>::Blocks<'a> as Foo>::Item: 'static
, not the lifetime 'a
, but that doesn't tell us anything about the lifetime '_#1r
. Ultimately, we do know a bit about how 'a
and '_#1r
are related, because of the method calls, but because the Item
type is through a projection, we can't know that <<T as Table>::Blocks<'_#1r> as Foo>::Item: 'static
holds if <<T as Table>::Blocks<'a> as Foo>::Item: 'static
holds. Well, maybe we should be able to - that's not clear yet.
Interestingly, I expected changing the bound to for<'x> <<T as Table>::Blocks<'x> as Foo>::Item: 'static
to fix this, but that runs into a different error that I haven't looked into.
I tried this code:
I expected this code to compile, but it doesn't. rustc suggests this:
But such bound already exists and does seemingly nothing.
Meta
rustc --version --verbose
: