-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
struct Foo {
t: Thing
}
#[derive(Clone)]
struct Thing;
fn main() {
let t = &Thing;
let f = Foo {
t
};
}
Current output
error[E0308]: mismatched types
--> src/main.rs:11:9
|
11 | t
| ^ expected `Thing`, found `&Thing`
|
help: consider using clone here
|
11 | t.clone()
| ++++++++
Desired output
error[E0308]: mismatched types
--> src/main.rs:11:9
|
11 | t
| ^ expected `Thing`, found `&Thing`
|
help: consider using clone here
|
11 | t: t.clone()
| ++ ++++++++
Rationale and extra context
The suggestion is not compatible with struct field init shorthand syntax. The suggestion should include the field name when rewriting.
Other cases
No response
Anything else?
rustc 1.69.0-nightly (c5c7d2b37 2023-02-24)
binary: rustc
commit-hash: c5c7d2b37780dac1092e75f12ab97dd56c30861d
commit-date: 2023-02-24
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.