?
can not use assiciated type constraints usable by .into()
#55984
Labels
A-trait-system
Area: Trait system
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
When an error type is guaranteed to come
From<>
a result error type by means of a trait constraint in a generic function with a constant result type, the idiomsome_result.map_err(|e| e.into())
works, but the should-be equivalentOk(some_result?)
does not and produces:That can be alleviated by explicitly demanding that
From<<W as Worker>::Error>
of the generic function's error type, but my expectation would be that this is implied by the type constraint -- especially since the.map_err
version that should be equivalent to the?
one does "get it".Full example:
This fails to build with the above error message, while the commented-out version with
.map_err(|e| e.into())
builds fine. Adding theGenericError: From<...>
"where" clause solves the build error, but is unergonomic (it'd clutter all functions working on that type).In case it is relevant: If
Into<>
is implemented instead of the equivalentFrom<>
(top comment block), then the problem still exists, but adding the additional constraint does not solve it any more but produces a different error message.Meta
Previous research on web and issue tracker search turned out dry, and disucssion on IRC just helped rule out some possible oversights. The behavior is the same with 1.29.0, 1.30.0 and current nightly; full example version:
The text was updated successfully, but these errors were encountered: