Skip to content

Instantly share code, notes, and snippets.

@xkr47
Last active June 19, 2020 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xkr47/b6ac7d746e01010a01e394bb00d45209 to your computer and use it in GitHub Desktop.
Save xkr47/b6ac7d746e01010a01e394bb00d45209 to your computer and use it in GitHub Desktop.
Seriously funny rust error message
$ cargo build
Updating crates.io index
Blocking waiting for file lock on package cache
Downloaded dbus v0.8.4
Compiling pkg-config v0.3.17
Compiling libc v0.2.71
Compiling libdbus-sys v0.2.1
Compiling dbus v0.8.4
Compiling x v0.1.0 (/tmp/x)
error[E0277]: `*mut std::ffi::c_void` cannot be sent between threads safely
--> src/main.rs:10:9
|
10 | thread::spawn(move || self.run());
| ^^^^^^^^^^^^^ `*mut std::ffi::c_void` cannot be sent between threads safely
|
= help: the trait `std::marker::Send` is not implemented for `*mut std::ffi::c_void`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::cell::Cell<*mut std::ffi::c_void>`
= note: required because it appears within the type `dbus::ffidisp::connection::IConnection`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<dbus::ffidisp::connection::IConnection>`
= note: required because it appears within the type `std::boxed::Box<dbus::ffidisp::connection::IConnection>`
= note: required because it appears within the type `dbus::ffidisp::connection::Connection`
= note: required because it appears within the type `Foo`
= note: required because it appears within the type `[closure@src/main.rs:10:23: 10:41 self:Foo]`
error[E0277]: `(dyn for<'r> std::ops::FnMut(&'r dbus::ffidisp::connection::Connection, dbus::message::Message) -> bool + 'static)` cannot be sent between threads safely
--> src/main.rs:10:9
|
10 | thread::spawn(move || self.run());
| ^^^^^^^^^^^^^ `(dyn for<'r> std::ops::FnMut(&'r dbus::ffidisp::connection::Connection, dbus::message::Message) -> bool + 'static)` cannot be sent between threads safely
|
= help: the trait `std::marker::Send` is not implemented for `(dyn for<'r> std::ops::FnMut(&'r dbus::ffidisp::connection::Connection, dbus::message::Message) -> bool + 'static)`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn for<'r> std::ops::FnMut(&'r dbus::ffidisp::connection::Connection, dbus::message::Message) -> bool + 'static)>`
= note: required because it appears within the type `std::boxed::Box<(dyn for<'r> std::ops::FnMut(&'r dbus::ffidisp::connection::Connection, dbus::message::Message) -> bool + 'static)>`
= note: required because it appears within the type `std::option::Option<std::boxed::Box<(dyn for<'r> std::ops::FnMut(&'r dbus::ffidisp::connection::Connection, dbus::message::Message) -> bool + 'static)>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::cell::RefCell<std::option::Option<std::boxed::Box<(dyn for<'r> std::ops::FnMut(&'r dbus::ffidisp::connection::Connection, dbus::message::Message) -> bool + 'static)>>>`
= note: required because it appears within the type `dbus::ffidisp::connection::IConnection`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<dbus::ffidisp::connection::IConnection>`
= note: required because it appears within the type `std::boxed::Box<dbus::ffidisp::connection::IConnection>`
= note: required because it appears within the type `dbus::ffidisp::connection::Connection`
= note: required because it appears within the type `Foo`
= note: required because it appears within the type `[closure@src/main.rs:10:23: 10:41 self:Foo]`
error[E0277]: `(dyn dbus::ffidisp::MsgHandler + 'static)` cannot be sent between threads safely
--> src/main.rs:10:9
|
10 | thread::spawn(move || self.run());
| ^^^^^^^^^^^^^ `(dyn dbus::ffidisp::MsgHandler + 'static)` cannot be sent between threads safely
|
= help: the trait `std::marker::Send` is not implemented for `(dyn dbus::ffidisp::MsgHandler + 'static)`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn dbus::ffidisp::MsgHandler + 'static)>`
= note: required because it appears within the type `std::boxed::Box<(dyn dbus::ffidisp::MsgHandler + 'static)>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<std::boxed::Box<(dyn dbus::ffidisp::MsgHandler + 'static)>>`
= note: required because it appears within the type `alloc::raw_vec::RawVec<std::boxed::Box<(dyn dbus::ffidisp::MsgHandler + 'static)>>`
= note: required because it appears within the type `std::vec::Vec<std::boxed::Box<(dyn dbus::ffidisp::MsgHandler + 'static)>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::cell::RefCell<std::vec::Vec<std::boxed::Box<(dyn dbus::ffidisp::MsgHandler + 'static)>>>`
= note: required because it appears within the type `dbus::ffidisp::connection::IConnection`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<dbus::ffidisp::connection::IConnection>`
= note: required because it appears within the type `std::boxed::Box<dbus::ffidisp::connection::IConnection>`
= note: required because it appears within the type `dbus::ffidisp::connection::Connection`
= note: required because it appears within the type `Foo`
= note: required because it appears within the type `[closure@src/main.rs:10:23: 10:41 self:Foo]`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.
error: could not compile `x`.
To learn more, run the command again with --verbose.
cargo build 22.51s user 0.89s system 149% cpu 15.654 total
[package]
name = "x"
version = "0.1.0"
edition = "2018"
[dependencies]
dbus = "0.8.1"
use dbus::ffidisp::Connection;
use std::thread;
struct Foo {
conn: Connection
}
impl Foo {
fn start(mut self) {
thread::spawn(move || self.run());
}
fn run(mut self) {
// ...
}
}
fn main() {
let conn = Connection::new_session().unwrap();
Foo { conn }.start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment