Skip to content

Implicit copy of pinned kind runs destructor twice #985

Closed

Description

@brson
resource r(i: @mutable int) {
    *i = *i + 1;
}

fn movearg(i: r) {
    // Implicit copy to mutate reference i
    let j <- i;
}

fn main() {
    let i = @mutable 0;
    {
        let j <- r(i);
        movearg(j);
    }
    log_err *i;
    // nooooooo. destructor ran twice
    assert *i == 2;
}

Activity

  1. brson commented on Sep 27, 2011

    @brson
    ContributorAuthor

    marijn: brson: i think mut.rs, when inserting a value into the mut_map, could check whether it is an argument

  2. ghost assigned on Sep 27, 2011
  3. added a commit that references this issue on Sep 28, 2011
  4. added a commit that references this issue on Aug 5, 2023
  5. added 2 commits that reference this issue on Aug 21, 2026
  6. added a commit that references this issue on Sep 25, 2026
  7. added a commit that references this issue on Sep 29, 2026
  8. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions