eyre-rs / eyre

A trait object based error handling type for easy idiomatic error handling and reporting in Rust applications
Apache License 2.0
1.41k stars 68 forks source link

Should the error type implement From<Infallible>? #61

Closed aldanor closed 3 years ago

aldanor commented 3 years ago

Similar e.g. to: https://doc.rust-lang.org/src/core/num/error.rs.html#32-36

IIUC, this will allow using TryInto with eyre error type where blanket impls (like From->TryFrom) may return Infallible as the error type?

yaahc commented 3 years ago

As far as I know this isn't possible to implement for eyre::Report because we impl From<E: Error> for Report.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3e83a8232972ecd27233c85e4105c1a9

Though honestly the error I'm getting isn't the one I expected. I expected it to produce a future incompatibility error indicating that Infallible could introduce an Error imp in the future, but it just seems to indicate that there is overlap. Not sure what that means. I know that there's a debate over whether Infallible/! should be able to satisfy any trait bound, so this may be some compiler hacks that prevent users from depending on Infallible not implementing certain traits or it may be something completely diff that I don't fully understand. Either way though I don't see a way to accomplish this.

If we do decide to make Infallible/! satisfy any trait bound then this should just work automatically, since Infallible would be a valid parameter for the From impl that already exists on Report.

aldanor commented 3 years ago

@yaahc Thanks a million for clarifying, that makes sense! (closing this)