Closed bryanlarsen closed 2 years ago
When reporting an issue, it’s useful to produce an MRE.
When next I have time to investigate this issue, I’ll spend it on reproducing the problem. Then the next time i have, I can work on addressing the problem.
Should work if you adjust the trait object to be Send
/ Sync
:
use snafu::{prelude::*, whatever};
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(whatever, display("{message}"))]
Whatever {
message: String,
#[snafu(source(from(Box<dyn std::error::Error + Send + Sync>, Some)))]
source: Option<Box<dyn std::error::Error + Send + Sync>>,
},
}
fn create() -> Result<(), Error> {
whatever!("Broken")
}
fn main() {
fn is_send(_: impl Send) {}
is_send(create());
}
Yes, that works. I don't know if it should be added to the documentation or not.
Thanks.
I stumbled across this today as well.
It should definitly added to the guide at https://github.com/shepmaster/snafu/blob/ba92e751f17e7095453c2178b890f305567fd682/src/lib.rs#L167-L185 because that's where I (and everyone else?) copied the code from to use whatever along with other errors.
Feedback welcome on #331
Published in https://crates.io/crates/snafu/0.7.1
Following the instructions on the front page, I have
This results in the error:
Removing the Whatever block from my error enum fixes the message. I wasn't using whatever! in my async function but it was annoying stripping it from the rest of my code.
I'm a rust newbie, so problem is likely PBKAC, but in case it might affect others I raised an issue. I've now purged whatever usage, so I'm fine with you closing the issue if that's appropriate.