Closed U007D closed 4 weeks ago
@U007D I cannot reproduce, could you clarify?
Here is the cargo-script
I'm running:
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! derive_more = { version = "1.0.0", features = ["display", "error", "from"] }
//! tracing-subscriber = "0.3.18"
//! ```
extern crate derive_more;
extern crate tracing_subscriber;
use derive_more::{Display, Error, From};
#[derive(Debug, Display, Error, From)]
enum FooError {
SomeError(std::io::Error),
SomeOtherError(Box<dyn Error + Send + Sync + 'static>),
}
// Perform type-erasure so that `tracing_subscriber` dependency is not leaked to clients
impl From<tracing_subscriber::util::TryInitError> for FooError {
fn from(error: tracing_subscriber::util::TryInitError) -> Self {
Self::SomeOtherError(Box::new(error))
}
}
fn main() {}
Running
cargo script repro.rs
gives no errors.
Okay, afaict this is another case of: https://github.com/JelteF/derive_more/issues/405
If I change @U007D his example to use use derive_more::derive::{Display, Error, From}
instead of use derive_more::{Display, Error, From}
, then it compiles fine for me (after also changing dyn Error
to dyn std::error::Error
.
@U007D if that doesn't fix your issue could you give an example that fails in the way you are describing?
I suspect you are correct. We have already moved back to thiserror
because of these conflicts, but agree this is probably the problem. Thank you!
Seeing if I can replace
thiserror
withderive_more
:gives a compilation error (conflicting
From
impls), whereasthiserror
has no problem with this:compiles fine.