1
Fork 0

provide variant definition on tuple struct unknow field error

This commit is contained in:
Cedric 2019-06-19 11:09:17 +02:00
parent c917ba325f
commit 70e52f8418
3 changed files with 11 additions and 3 deletions

View file

@ -1218,9 +1218,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty);
match variant.ctor_kind {
CtorKind::Fn => {
err.span_label(variant.ident.span, format!("`{adt}` defined here", adt=ty));
err.span_label(field.ident.span, "field does not exist");
err.span_label(ty_span, format!(
"`{adt}` is a tuple {kind_name}, use the appropriate syntax: `{adt}(/* fields */)`",
"`{adt}` is a tuple {kind_name},\
use the appropriate syntax: `{adt}(/* fields */)`",
adt=ty,
kind_name=kind_name
));

View file

@ -1,10 +1,13 @@
error[E0560]: struct `NonCopyable` has no field named `p`
--> $DIR/issue-4736.rs:4:26
|
LL | struct NonCopyable(());
| ----------- `NonCopyable` defined here
...
LL | let z = NonCopyable{ p: () };
| ----------- ^ field does not exist
| |
| `NonCopyable` is a tuple struct, use the appropriate syntax: `NonCopyable(/* fields */)`
| `NonCopyable` is a tuple struct,use the appropriate syntax: `NonCopyable(/* fields */)`
error: aborting due to previous error

View file

@ -1,10 +1,13 @@
error[E0560]: struct `S` has no field named `0b1`
--> $DIR/numeric-fields.rs:4:15
|
LL | struct S(u8, u16);
| - `S` defined here
...
LL | let s = S{0b1: 10, 0: 11};
| - ^^^ field does not exist
| |
| `S` is a tuple struct, use the appropriate syntax: `S(/* fields */)`
| `S` is a tuple struct,use the appropriate syntax: `S(/* fields */)`
error[E0026]: struct `S` does not have a field named `0x1`
--> $DIR/numeric-fields.rs:7:17