Due to limitations in the borrow checker, this implies a 'static lifetime

submited by
Style Pass
2023-01-23 12:00:06

For the past six months or so I have been work­ing on finite-wasm, a pro­ject aimed at en­for­cing de­term­in­istic re­source lim­its (in time and space) in a runtime ag­nostic and Easy to Reason About way. This pro­ject pro­duces a spe­cific­a­tion (or rather ad­di­tions to the WebAssembly spe­cific­a­tion) de­tail­ing how these lim­its should be en­forced and ana­lyses im­ple­ment­ing the spe­cific­a­tion. Last week I fi­nally pub­lished the very first ver­sion of this code on crates.io, but did­n’t feel com­fort­able mak­ing the re­pos­it­ory pub­lic quite yet – I have a fair bit of im­prove­ments I want to make first. I’ll try to make a point of writ­ing more about this pro­ject at a later date, when the pro­ject is fully pub­lic.

That said, as I was work­ing on the im­prove­ments I en­countered a per­plex­ing lim­it­a­tion in rustc that mani­fests it­self as a note: due to cur­rent lim­it­a­tions in the bor­row check­er, this im­plies a 'static life­time dia­gnost­ic. It seemed great op­por­tun­ity for a stand-alone blog post, if not to doc­u­ment a pos­sible work­around, then to serve as a proof that even ex­per­i­enced Rust de­velopers aren’t im­mune to “fight­ing the bor­row checker” woes. But also be­cause this dia­gnostic mes­sage is quite opaque and is hardly doc­u­mented (I could only find this in­tern­als thread) and writ­ing my ex­per­i­ence down seemed pos­sibly use­ful to the next un­for­tu­nate soul to en­counter a sim­ilar prob­lem. Per­haps this might even in­form a change in rustc?

Leave a Comment