Thread joining can't be used with failure
marmistrz opened this issue · 0 comments
marmistrz commented
Example code:
fn run() -> Fallible<()> {
let handle = thread::spawn(|| loop {});
handle.join()?;
Ok(())
}
results in an error:
error[E0277]: the size for values of type `dyn std::any::Any + std::marker::Send` cannot be known at compilation time
--> src/main.rs:11:5
|
11 | handle.join()?;
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `dyn std::any::Any + std::marker::Send`
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-sized>
= note: required because of the requirements on the impl of `std::error::Error` for `std::boxed::Box<dyn std::any::Any + std::marker::Send>`
= note: required because of the requirements on the impl of `failure::Fail` for `std::boxed::Box<dyn std::any::Any + std::marker::Send>`
= note: required because of the requirements on the impl of `std::convert::From<std::boxed::Box<dyn std::any::Any + std::marker::Send>>` for `failure::Error`
= note: required by `std::convert::From::from`
error[E0277]: the trait bound `dyn std::any::Any + std::marker::Send: std::error::Error` is not satisfied
--> src/main.rs:11:5
|
11 | handle.join()?;
| ^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `dyn std::any::Any + std::marker::Send`
|
= note: required because of the requirements on the impl of `std::error::Error` for `std::boxed::Box<dyn std::any::Any + std::marker::Send>`
= note: required because of the requirements on the impl of `failure::Fail` for `std::boxed::Box<dyn std::any::Any + std::marker::Send>`
= note: required because of the requirements on the impl of `std::convert::From<std::boxed::Box<dyn std::any::Any + std::marker::Send>>` for `failure::Error`
= note: required by `std::convert::From::from`
error[E0277]: `dyn std::any::Any + std::marker::Send` cannot be shared between threads safely
--> src/main.rs:11:5
|
11 | handle.join()?;
| ^^^^^^^^^^^^^^ `dyn std::any::Any + std::marker::Send` cannot be shared between threads safely
|
= help: the trait `std::marker::Sync` is not implemented for `dyn std::any::Any + std::marker::Send`
= note: required because of the requirements on the impl of `std::marker::Sync` for `std::ptr::Unique<dyn std::any::Any + std::marker::Send>`
= note: required because it appears within the type `std::boxed::Box<dyn std::any::Any + std::marker::Send>`
= note: required because of the requirements on the impl of `failure::Fail` for `std::boxed::Box<dyn std::any::Any + std::marker::Send>`
= note: required because of the requirements on the impl of `std::convert::From<std::boxed::Box<dyn std::any::Any + std::marker::Send>>` for `failure::Error`
= note: required by `std::convert::From::from`