Good day all. I am working on updating the yara-rust wrapper to support the latest Yara version and also transition to Rust 2018 edition. I am seeing the warning below:
warning[E0713]: borrow may still be in use when destructor runs
--> src/compiler.rs:99:39
|
16 | impl<'a> Compiler<'a> {
| -- lifetime `'a` defined here
...
99 | internals::compiler_get_rules(self.inner).map(Rules::from)
| ------------------------------^^^^^^^^^^------------------ returning this value requires that `*self.inner` is borrowed for `'a`
100 | }
| - here, drop of `self` needs exclusive access to `*self.inner`, because the type `compiler::Compiler<'_>` implements the `Drop` trait
|
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
= note: for more information, try `rustc --explain E0729`
So I changed the function signature to:
pub fn compiler_get_rules<'a>(compiler: &'a mut YR_COMPILER) -> Result<&'a mut YR_RULES, YaraError> {
but the warning stays the same. When I changed self
in the containing function to mutable then all the tests break.
I'd appreciate some guidance on where I should be placing/removing lifetime parameters. Thanks!