Generic bounds are used overzealously #82170
Labels
A-inference
Area: Type inference
A-trait-system
Area: Trait system
C-bug
Category: This is a bug.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d10a2b403aee136b0426cc7f602d51ef
I expected it to compile, but it doesn't. Instead, I get the following compile error:
This is unusual because
Call::build
is implemented for all typesF: FnOnce(A) -> _
(through theCallable
trait), and sinceCall::build
returns a type that implementsFnOnce(A) -> _
, it should be possible to recursively callCall::bulid
if the first one succeeds. However, Rust overzelously assumes thatCall::build
can only be called withF
(the concrete type parameter) instead of any type that implementsFnOnce(A) -> _
. (I'm trying to abstract overFn*
traits for a single argument, so this is road bump is annoying to work around, it requires duplicating all applicable functions).The text was updated successfully, but these errors were encountered: