Skip to content

Can duplicate unique pointers using auto-move-by-type #4114

Closed
@rntz

Description

@rntz

Currently, the incoming branch rustc accepts the following program:

fn dup(x: ~int) -> (~int,~int) { *~(x,x) }
fn main() { dup(~2); }

Since dup duplicates a unique pointer, it shouldn't accept it. Indeed, it correctly rejects the following program, complaining that it uses a moved variable:

fn dup(x: ~int) -> (~int,~int) { *~(move x,move x) }
fn main() { dup(~2); }

This makes me think that the problem is somewhere in the code @pcwalton added in #4109, @33c1e47.

Note that the following is also accepted incorrectly:

fn dup(x: ~int) -> ~(~int,~int) { ~(x,x) }

However, the following is correctly rejected:

fn dup(x: ~int) -> (~int,~int) { (x,x) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions