Skip to content

Send not implemented for std::fs::read_dir #22577

Closed
@markuskobler

Description

@markuskobler

Now that the new std::fs changes #21936 have landed. I'm getting the following error with code similar to this snippet http://is.gd/6usayc

fn scan_dir(dir: &Path, pool: &TaskPool, tx: Sender<Vec<io::Result<()>>>) -> io::Result<()> {
    // Read directory outside of task pool
    let entries = try!(fs::read_dir(dir));
    pool.execute(move || {
        let mut stats = Vec::new();
        for entry in entries {
            /* ...process files... */
        }
        tx.send(stats).unwrap();
    });
    Ok(())
}

Error:

<anon>:27:10: 33:7 error: the trait `core::marker::Send` is not implemented for the type `*mut libc::types::common::posix88::DIR` [E0277]
          ...
<anon>:27:10: 33:7 note: `*mut libc::types::common::posix88::DIR` cannot be sent between threads safely

Is it really unsafe to move the read_dir results to a TaskPool?

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