Unable to write blanket impl for subtrait on RPITIT trait #124729
Labels
C-bug
Category: This is a bug.
F-return_position_impl_trait_in_trait
`#![feature(return_position_impl_trait_in_trait)]`
F-return_type_notation
`#[feature(return_type_notation)]`
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
If we have a trait that uses RPITIT, e.g.:
It's currently impossible to define a subtrait and to write a blanket impl for that subtrait, e.g.:
The error we give here is, of course, particularly bad since we suggest that the user change the type to what is already written there syntactically.
We can simplify the example a bit by refining the impl:
If we desugar this, we can see more clearly what's going on:
We need to bound the associated type of the trait when defining the subtrait. If we do that, then it works:
The trouble for RPITIT is that 1) there's no way to bound the associated type in that way, and 2) even if there were (e.g. with RTN with type equality bounds), we probably don't want to require that people do that.
Because of the special relationship between a function with an RPITIT and the implicit associated type, we may be able to make this just work in the case of RPITITs.
cc @compiler-errors
This is related to some existing issues, but is probably a more minimal statement of the underlying issue here, so we're filing it separately.
Related
The text was updated successfully, but these errors were encountered: