Trait projection plus return type hinders coercion of function argument #95863
Labels
C-bug
Category: This is a bug.
fixed-by-next-solver
Fixed by the next-generation trait solver, `-Znext-solver`.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: Successful compilation due to the function item coercing to a function pointer.
Instead, this happened: E0271 due to coercion not applying through the trait projection:
Further notes
Edit This doesn't really seem to be about constructors, but functions more generally; see below.
Pre-edit notes
As can be seen in the playground link, the coercion applies for
The last bullet also did not work in Rust 1.19 and prior, but this was fixed by #42807. So technically this could be considered a dupe of #31260 as "coercion sites are not consistent between struct tuples and structs" is still true.
Coercion also applies if the indirection through the trait is not present.
Meta
Discovered on the playground
@rustbot modify labels: T-compiler
The text was updated successfully, but these errors were encountered: