Skip to content

Shared-kind typarams shouldn't be copyable #984

Description

@brson

Because ~resource is shared kind it is not safe to copy shared kinds for which we don't know the type. This means that the ty param @T must not be copied. On first blush this seems quite restrictive since shared boxes may not be used as ty params when they need to be copied.

Activity

  1. brson commented on Sep 27, 2011

    @brson
    ContributorAuthor

    This also seems to imply that fn <@T> can't do vector addition or append on [T]:

    // compile-fail/unique-vec-res.rs
    resource r(i: @mutable int) {
        *i = *i + 1;
    }
    
    fn f<@T>(i: [T], j: [T]) {
        // Shouldn't be able to do this copy of j
        let k = i + j;
    }
    
    fn main() {
        let i1 = @mutable 0;
        let i2 = @mutable 1;
        let r1 <- [~r(i1)];
        let r2 <- [~r(i2)];
        f(r1, r2);
        log_err *i1;
        log_err *i2;                                                                                                                                                              
    }
    
  2. brson commented on Sep 27, 2011

    @brson
    ContributorAuthor

    This isn't actually required until #977 is implemented

  3. marijnh commented on Nov 15, 2011

    @marijnh
    Contributor

    This is handled/superseded by the new kind system (#1177).

  4. added a commit that references this issue on Aug 21, 2026
  5. added a commit that references this issue on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions