Closed
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