Invalid "convert the array to a slice" suggestion #110063
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
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
Both of these suggestions result in invalid code, and don't really make much sense. This suggestion should only be emitted when it's about an expression of type
[T; N]
, and not a trait bound that arises some other way (like the type being explicitly written in the code).Other cases
No response
Anything else?
This invalid suggestion also occurs in serde autoderived implementations of Deserialize, if a field of the struct/enum is an array with more than 32 elements. (This is the context where I initially discovered this, the MVE above is a reverse-engineering of that case).
This seems to only happen in nightly. I think this is just because this suggestion was added after 1.68.0 was released, or something like that.
The commit that introduced this suggestion (and also the bug) is 8ac7d0e.
Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=ec4aeb169fe3a41cfecf995c8cd66150
The text was updated successfully, but these errors were encountered: