Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aldanor opened this issue Oct 19, 2021 · 2 comments
Closed

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

aldanor opened this issue Oct 19, 2021 · 2 comments

Comments

@aldanor
Copy link
Contributor

aldanor commented Oct 19, 2021

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?

@aldanor aldanor changed the title Should error type implement From<Infallible>? Should the error type implement From<Infallible>? Oct 19, 2021
@yaahc
Copy link
Collaborator

yaahc commented Oct 19, 2021

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
Copy link
Contributor Author

aldanor commented Oct 19, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants