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

mysql::Conn has inconsistent implementations of Sync on Windows and macOS #135

Closed
shepmaster opened this issue Mar 15, 2018 · 1 comment
Closed

Comments

@shepmaster
Copy link

This code compiles fine on macOS, but fails on Windows:

#[macro_use]
extern crate lazy_static;
extern crate mysql;

use mysql::*;

fn some_fn() {
    lazy_static! {
        static ref CONNECTION: Conn = Conn::new("mysql://root:password@127.0.0.1:3306/mydb?prefer_socket=false").unwrap();
    }
}

fn main() {}
[dependencies]
lazy_static = "1.0.0"
mysql = "12.2.0"
error[E0277]: the trait bound `*mut std::os::raw::c_void: std::marker::Sync` is not satisfied in `winapi::minwinbase::OVERLAPPED`
  --> src\main.rs:8:5
   |
8  | /     lazy_static! {
9  | |         static ref CONNECTION: Conn = Conn::new("mysql://root:password@127.0.0.1:3306/mydb?prefer_socket=false").unwrap();
10 | |     }
   | |_____^ `*mut std::os::raw::c_void` cannot be shared between threads safely
   |
   = help: within `winapi::minwinbase::OVERLAPPED`, the trait `std::marker::Sync` is not implemented for `*mut std::os::raw::c_void`
   = note: required because it appears within the type `winapi::minwinbase::OVERLAPPED`
   = note: required because of the requirements on the impl of `std::marker::Sync` for `std::ptr::Unique<winapi::minwinbase::OVERLAPPED>`
   = note: required because it appears within the type `std::boxed::Box<winapi::minwinbase::OVERLAPPED>`
   = note: required because it appears within the type `named_pipe::Overlapped`
   = note: required because it appears within the type `named_pipe::PipeClient`
   = note: required because it appears within the type `std::option::Option<named_pipe::PipeClient>`
   = note: required because it appears within the type `std::io::BufWriter<named_pipe::PipeClient>`
   = note: required because it appears within the type `std::option::Option<std::io::BufWriter<named_pipe::PipeClient>>`
   = note: required because it appears within the type `bufstream::InternalBufWriter<named_pipe::PipeClient>`
   = note: required because it appears within the type `std::io::BufReader<bufstream::InternalBufWriter<named_pipe::PipeClient>>`
   = note: required because it appears within the type `bufstream::BufStream<named_pipe::PipeClient>`
   = note: required because it appears within the type `mysql::io::Stream`
   = note: required because it appears within the type `std::option::Option<mysql::io::Stream>`
   = note: required because it appears within the type `mysql::Conn`
   = note: required by `lazy_static::lazy::Lazy`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
@blackbeam
Copy link
Owner

blackbeam commented Mar 16, 2018

Thanks for report.

It's fine for OVERLAPPED to be Sync and Send but traits was not automatically implemented because of a c_void.

Fix published in v12.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants