Compiler erroneously suggests inserting a syntax error in struct definition #71136
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
C-bug
Category: This is a bug.
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.
When defining a struct that derives Clone, that owns an instance of another struct, which is not Clone, an invalid suggestion is given to resolve the problem.
I tried this code:
I expected any suggestions to at least be valid Rust. Instead, the compiler suggested "borrowing" but put the
&
in the wrong place, which is invalid syntax.I checked this in Stable 1.42.0 and "Nightly version: 1.44.0-nightly (2020-04-12 3712e11)" on Rust Playground
A link to the code in Playground:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0fcf1446729fefbbd984472106334097
This issue has been assigned to @kper via this comment.
The text was updated successfully, but these errors were encountered: