Open
Description
Code
struct Person {
name: String,
}
fn main() {
Person("Wilfred".to_owned());
}
Current output
error[E0423]: expected function, tuple struct or tuple variant, found struct `Person`
--> src/main.rs:6:5
|
1 | / struct Person {
2 | | name: String,
3 | | }
| |_- `Person` defined here
...
6 | Person("Wilfred".to_owned());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `Person { name: val }`
Desired output
Ideally rustc would offer a fix here of Person { name: "Wilfred".to_owned() }
.
Rationale and extra context
When there's only one field in a struct, this is probably what the user meant to write.
Rust Version
$ rustc --version --verbose
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7
Anything else?
No response