Middle/pretty: Butchered output for opaque types with associated type bounds #127329
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
A-pretty
Area: Pretty printing (including `-Z unpretty`)
C-bug
Category: This is a bug.
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
This is closely related to #106684 and in particular my observation in #106684 (comment). As in there, uncommenting the commented line to replace the return type of
borrow
withimpl '_ + Trait<Associated = impl Sized>
caused the code to compile, as expected. This is a further reduced example, and in this case I'm not even sure that there should be any error at all sincewith
andcapture
both return()
.However, the most salient problem to me as a user here, is not that the code doesn't compile, but that the error doesn't seem to make sense, specifically the inferred type on the
a
parameter to the closure, which is&<impl Trait + '1 + 'static as Trait>::Associated
. TheAssociated: 'static
bound has somehow floated upward to becomeimpl Trait + 'static
, which was never specified.I thought this might be worth reporting as a separate diagnostic bug, but if this is just a consequence of an underlying issue in the type checking, maybe covered under #106684, then feel free to close it.
Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: