Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer may_dangle on type parameters of Punctuated iterator Drop impls #1247

Merged
merged 2 commits into from Dec 1, 2022

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Dec 1, 2022

Fixes #1246.

    error[E0505]: cannot move out of `p` because it is borrowed
      --> tests/test_iterators.rs:56:18
       |
    54 |     for element in &p {
       |                    --
       |                    |
       |                    borrow of `p` occurs here
       |                    a temporary with access to the borrow is created here ...
    55 |         if *element == 2 {
    56 |             drop(p);
       |                  ^ move out of `p` occurs here
    ...
    59 |     }
       |     - ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `syn::punctuated::Iter<'_, i32>`

    error[E0505]: cannot move out of `p` because it is borrowed
      --> tests/test_iterators.rs:64:18
       |
    62 |     for element in &mut p {
       |                    ------
       |                    |
       |                    borrow of `p` occurs here
       |                    a temporary with access to the borrow is created here ...
    63 |         if *element == 2 {
    64 |             drop(p);
       |                  ^ move out of `p` occurs here
    ...
    67 |     }
       |     - ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `syn::punctuated::IterMut<'_, i32>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Punctuated iterators are overly restrictive of lifetimes in Drop
1 participant