error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> <anon>:14:26
|
14 | self.with(|this| f(this))
| ^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime 'tcx as defined on the block at 13:4...
--> <anon>:13:5
|
13 | {
| ^
note: ...so that the declared lifetime parameter bounds are satisfied
--> <anon>:14:26
|
14 | self.with(|this| f(this))
| ^^^^^^^
note: but, the lifetime must be valid for the lifetime 'b as defined on the block at 14:25...
--> <anon>:14:26
|
14 | self.with(|this| f(this))
| ^^^^^^^
note: ...so that expression is assignable (expected &mut MyType<'_, 'tcx>, found &mut MyType<'b, '_>)
--> <anon>:14:28
|
14 | self.with(|this| f(this))
| ^^^^
error: aborting due to previous error
I believe it should succeed, but somehow the implied bound that 'tcx: 'b is failing to get added in the closure. I haven't investigated much to see why this is the case.
There is a workaround. If you change self.with(|this| f(this)) to self.with(|this| this.with(f)), it works, because the implied bounds work out for you then.
This snippet fails to compile:
with the error:
I believe it should succeed, but somehow the implied bound that
'tcx: 'b
is failing to get added in the closure. I haven't investigated much to see why this is the case.There is a workaround. If you change
self.with(|this| f(this))
toself.with(|this| this.with(f))
, it works, because the implied bounds work out for you then.