rust/tests/ui/parser/struct-lit-placeholder-or-empty-path.rs
Usman Akinyemi 54fc546f20 Recover from struct literals with placeholder or empty path
Based on earlier work by León Orell Valerian Liehr.

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
Signed-off-by: Usman Akinyemi <uniqueusman@archlinux>
2026-01-26 04:09:28 +05:30

14 lines
722 B
Rust

fn main() {
let _ = {foo: (), bar: {} }; //~ ERROR struct literal body without path
//~| NOTE struct name missing for struct literal
//~| HELP add the correct type
let _ = _ {foo: (), bar: {} }; //~ ERROR placeholder `_` is not allowed for the path in struct literals
//~| NOTE not allowed in struct literals
//~| HELP replace it with the correct type
let _ = {foo: ()}; //~ ERROR struct literal body without path
//~| NOTE struct name missing for struct literal
//~| HELP add the correct type
let _ = _ {foo: ()}; //~ ERROR placeholder `_` is not allowed for the path in struct literals
//~| NOTE not allowed in struct literals
//~| HELP replace it with the correct type
}