Make "missing field" error message more natural

This commit is contained in:
r00ster91 2021-02-20 18:32:02 +01:00
parent cb2effd44e
commit 447ce27198
9 changed files with 29 additions and 26 deletions

View file

@ -32,7 +32,7 @@ fn main() {
let w = SingleFoo { };
//~^ ERROR missing field `x` in initializer of `SingleFoo`
let x = PluralFoo {x: 1};
//~^ ERROR missing fields `y`, `z` in initializer of `PluralFoo`
//~^ ERROR missing fields `y` and `z` in initializer of `PluralFoo`
let y = TruncatedFoo{x:1};
//~^ missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo`
let z = TruncatedPluralFoo{x:1};

View file

@ -4,11 +4,11 @@ error[E0063]: missing field `x` in initializer of `SingleFoo`
LL | let w = SingleFoo { };
| ^^^^^^^^^ missing `x`
error[E0063]: missing fields `y`, `z` in initializer of `PluralFoo`
error[E0063]: missing fields `y` and `z` in initializer of `PluralFoo`
--> $DIR/E0063.rs:34:13
|
LL | let x = PluralFoo {x: 1};
| ^^^^^^^^^ missing `y`, `z`
| ^^^^^^^^^ missing `y` and `z`
error[E0063]: missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo`
--> $DIR/E0063.rs:36:13

View file

@ -23,7 +23,7 @@ fn wrong() {
foo::Enum::Variant { x: () };
//~^ ERROR missing field `y` in initializer of `Enum`
foo::Enum::Variant { };
//~^ ERROR missing fields `x`, `y` in initializer of `Enum`
//~^ ERROR missing fields `x` and `y` in initializer of `Enum`
}
fn main() {}

View file

@ -22,11 +22,11 @@ error[E0063]: missing field `y` in initializer of `Enum`
LL | foo::Enum::Variant { x: () };
| ^^^^^^^^^^^^^^^^^^ missing `y`
error[E0063]: missing fields `x`, `y` in initializer of `Enum`
error[E0063]: missing fields `x` and `y` in initializer of `Enum`
--> $DIR/issue-79593.rs:25:5
|
LL | foo::Enum::Variant { };
| ^^^^^^^^^^^^^^^^^^ missing `x`, `y`
| ^^^^^^^^^^^^^^^^^^ missing `x` and `y`
error: aborting due to 5 previous errors

View file

@ -7,6 +7,6 @@ fn main() {
let bar = 1.5f32;
let _ = Foo { bar.into(), bat: -1, . };
//~^ ERROR expected one of
//~| ERROR missing fields `bar`, `baz` in initializer of `Foo`
//~| ERROR missing fields `bar` and `baz` in initializer of `Foo`
//~| ERROR expected identifier, found `.`
}

View file

@ -26,11 +26,11 @@ error[E0063]: missing field `bat` in initializer of `Foo`
LL | let _ = Foo { bar: .5, baz: 42 };
| ^^^ missing `bat`
error[E0063]: missing fields `bar`, `baz` in initializer of `Foo`
error[E0063]: missing fields `bar` and `baz` in initializer of `Foo`
--> $DIR/issue-52496.rs:8:13
|
LL | let _ = Foo { bar.into(), bat: -1, . };
| ^^^ missing `bar`, `baz`
| ^^^ missing `bar` and `baz`
error: aborting due to 5 previous errors

View file

@ -5,5 +5,5 @@ fn main() {
//~^ ERROR expected identifier, found `0`
//~| ERROR expected identifier, found `1`
//~| ERROR expected identifier, found `2`
//~| ERROR missing fields `0`, `1`, `2` in initializer of `Rgb`
//~| ERROR missing fields `0`, `1` and `2` in initializer of `Rgb`
}

View file

@ -22,11 +22,11 @@ LL | let _ = Rgb { 0, 1, 2 };
| |
| while parsing this struct
error[E0063]: missing fields `0`, `1`, `2` in initializer of `Rgb`
error[E0063]: missing fields `0`, `1` and `2` in initializer of `Rgb`
--> $DIR/struct-field-numeric-shorthand.rs:4:13
|
LL | let _ = Rgb { 0, 1, 2 };
| ^^^ missing `0`, `1`, `2`
| ^^^ missing `0`, `1` and `2`
error: aborting due to 4 previous errors