Skip to content

possible bug with borrowing and moving things into tasks #3684

Description

@erickt

I was trying to help out @ben0x539 with some code of his: https://gist.github.com/3846368. He's messing around with moving a channel into a task, which is then passed to a closure. This fails with

foo.rs:5:56: 5:58 error: copying a noncopyable value
foo.rs:5         let fail_: fn~(~str) -> ! = fn~(x: ~str) -> ! { wr.send(x); fail; };
                                                                 ^~
foo.rs:5:56: 5:58 note: non-copyable value cannot be copied into a ~fn closure
foo.rs:5         let fail_: fn~(~str) -> ! = fn~(x: ~str) -> ! { wr.send(x); fail; };

However, if we get rid of the task, it works fine. I would have thought that moving the channel into the task would be roughly equivalent to the non-task version, but I'm probably missing some subtly in the borrower.

In the meantime, you can use pipes::SharedChan to write this kind of function.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions