strake/containers.rs

dropck is too strict for Vec destructor

im-nefilim opened this issue · 2 comments

This:

fn main() {
    let (mut b, a) = (containers::collections::Vec::new(), "abc".to_string());

    b.push(&a);
    /// `a` goes out of scope
    /// dropck thinks Drop implementation of
    /// might access `a` and complains.
}

fails with:

error[E0597]: `a` does not live long enough
 --> _\src\main.rs:_:_
  |
8 |     b.push(&a);
  |            ^^ borrowed value does not live long enough
9 | }
  | -
  | |
  | `a` dropped here while still borrowed
  | borrow might be used here, when `b` is dropped and runs the `Drop` code for type `containers::collections::Vec`
  |
  = note: values in a scope are dropped in the opposite order they are defined

dropck does not complain with std::vec::Vec.

I just published version 0.9.9, including b027d44; can you confirm it resolves your issue?

Yes, it seems to be working as expected.