2 ms·
> I can’t recall a new Rust release ever breaking existing code. Is this what you’re talking about? I have one case of code from late 2015 that stopped working
by estebank 4y ago
> I can’t recall a new Rust release ever breaking existing code. Is this what you’re talking about?
I have one case of code from late 2015 that stopped working in, IIRC, 2016, due to unsoundness being found in the borrow checker and it being fixed.
error[E0713]: borrow may still be in use when destructor runs
--> src/writer.rs:121:21
|
47 | impl<'a, F: Write + Read + Seek + 'a> Writer<'a, F> {
| -- lifetime `'a` defined here
...
121 | Reader::new(self.file)
| ------------^^^^^^^^^- returning this value requires that `*self.file` is borrowed for `'a`
122 | }
| - here, drop of `self` needs exclusive access to `*self.file`, because the type `Writer<'_, F>` implements the `Drop` trait
I ended up solving it by wrapping `self.file` in an "unnecessary" `Option` and using `Option::take` on `self.file` here. I guess I could have mucked around with `MaybeUninit` and risk UB instead, or removed the convenience `Drop` impl finalizer or made the impl non-generic.
I haven't had a case of code no longer compiling since then.