Bug Report
Version
axum v0.4.8
axum v0.5.0
Crates
axum
Description
I'm writing a generic tower::Service that needs to wrap two other services and thus combine their errors. I would like to represent this using a strongly-typed error enum, to be able to distinguish between errors raised by either service. The problem is if both services have Error = Infallible then my service will still have a strongly-typed uninhabited error. It can't ever produce an error but it won't be compatible with axum::Router::layer().
My idea here is to implement From<MyError<Infallible, Infallible>> for Infallible such that my error can be trivially converted to Infallible if it's uninhabited. This still won't make it directly compatible with Router::layer() though, but if Router::layer() required Error: Into<Infallible> rather than Error = Infallible it would all work.
More generally, any time that implements Into<Infallible> is presumably uninhabited, and axum really just cares that the error isn't possible rather than needing it to be the specific type Infallible. And so this should be reflected in the type system.
Bug Report
Version
axum v0.4.8
axum v0.5.0
Crates
axum
Description
I'm writing a generic
tower::Servicethat needs to wrap two other services and thus combine their errors. I would like to represent this using a strongly-typed error enum, to be able to distinguish between errors raised by either service. The problem is if both services haveError = Infalliblethen my service will still have a strongly-typed uninhabited error. It can't ever produce an error but it won't be compatible withaxum::Router::layer().My idea here is to implement
From<MyError<Infallible, Infallible>> for Infalliblesuch that my error can be trivially converted toInfallibleif it's uninhabited. This still won't make it directly compatible withRouter::layer()though, but ifRouter::layer()requiredError: Into<Infallible>rather thanError = Infallibleit would all work.More generally, any time that implements
Into<Infallible>is presumably uninhabited, and axum really just cares that the error isn't possible rather than needing it to be the specific typeInfallible. And so this should be reflected in the type system.