Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer on windows is not Send + unhelpful compilation error #20943

Closed
pfalabella opened this issue Jan 11, 2015 · 1 comment · Fixed by #21389
Closed

Timer on windows is not Send + unhelpful compilation error #20943

pfalabella opened this issue Jan 11, 2015 · 1 comment · Fixed by #21389
Labels
O-windows Operating system: Windows

Comments

@pfalabella
Copy link
Contributor

This code:

use std::io::timer::Timer;
use std::thread::Thread;
use std::time::duration::Duration;

fn main() {
    let mut timer = Timer::new().unwrap();
    Thread::spawn(move || {
        timer.sleep(Duration::seconds(1));
    });
}

compiles on Linux. On windows it fails to compile with:

$ rustc wintimer.rs
wintimer.rs:7:5: 7:18 error: the trait `core::marker::Send` is not implemented for the type `*mut libc::types::common::c95::c_void`
wintimer.rs:7     Thread::spawn(move || {
                  ^~~~~~~~~~~~~

I'm not sure if different behavior of timer on different OSs is an issue or somewhat "by design". For me the real issue was the unhelpful error message, that exposes an implementation detail but does not point to the part of the code that is actually wrong (where is c_void in my code? It's deep in the gut of the windows implementation for timer).

rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)
binary: rustc
commit-hash: 44a287e6eb22ec3c2a687fc156813577464017f7
commit-date: 2015-01-08 17:03:40 -0800
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly
@kmcallister kmcallister added O-windows Operating system: Windows A-libs labels Jan 11, 2015
@alexcrichton
Copy link
Member

Aha! Looks like opt-in-builtin-traits needs to be propagated to the windows definition of Timer.

retep998 added a commit to retep998/rust that referenced this issue Jan 19, 2015
Fixes rust-lang#20943

Signed-off-by: Peter Atashian <retep998@gmail.com>
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants