mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
f5d3b158b9
This prevents spurious errors when a field is intended to be present
but a preceding syntax error caused it not to be parsed. For example,
StructName { foo: 1 bar: 2 }
will not successfully parse a field `bar`, and we will report the syntax
error but not the missing field.
12 lines
355 B
Rust
12 lines
355 B
Rust
struct Foo { bar: f64, baz: i64, bat: i64 }
|
|
|
|
fn main() {
|
|
let _ = Foo { bar: .5, baz: 42 };
|
|
//~^ ERROR float literals must have an integer part
|
|
//~| ERROR missing field `bat` in initializer of `Foo`
|
|
let bar = 1.5f32;
|
|
let _ = Foo { bar.into(), bat: -1, . };
|
|
//~^ ERROR expected one of
|
|
//~| ERROR expected identifier, found `.`
|
|
}
|