Sorry for the vague description, here's a playground link with a minimized version of the error: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=aefe04553d8c34011e1aae7c4bd56830
There's a couple things that I think are weird:
- The need for
dropon line 48. This behaves likeptakes ownership of&mut s, even though it doesn't. I'm guessing this is a limitation on what rustc can infer about lifetimes. This isn' a big deal,dropis fine as a workaround. - It still fails to compile, and the error message implies that
plives until the end of the function, despite the explicitdropbefore the end of the function.
This smells like a compiler bug, but I could just be missing something about how impl Trait interacts with lifetimes.
A browser interface to the Rust compiler to experiment with the language