provide variant definition on tuple struct unknow field error
This commit is contained in:
parent
c917ba325f
commit
70e52f8418
3 changed files with 11 additions and 3 deletions
|
@ -1218,9 +1218,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
ty);
|
ty);
|
||||||
match variant.ctor_kind {
|
match variant.ctor_kind {
|
||||||
CtorKind::Fn => {
|
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(field.ident.span, "field does not exist");
|
||||||
err.span_label(ty_span, format!(
|
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,
|
adt=ty,
|
||||||
kind_name=kind_name
|
kind_name=kind_name
|
||||||
));
|
));
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
error[E0560]: struct `NonCopyable` has no field named `p`
|
error[E0560]: struct `NonCopyable` has no field named `p`
|
||||||
--> $DIR/issue-4736.rs:4:26
|
--> $DIR/issue-4736.rs:4:26
|
||||||
|
|
|
|
||||||
|
LL | struct NonCopyable(());
|
||||||
|
| ----------- `NonCopyable` defined here
|
||||||
|
...
|
||||||
LL | let z = NonCopyable{ p: () };
|
LL | let z = NonCopyable{ p: () };
|
||||||
| ----------- ^ field does not exist
|
| ----------- ^ 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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
error[E0560]: struct `S` has no field named `0b1`
|
error[E0560]: struct `S` has no field named `0b1`
|
||||||
--> $DIR/numeric-fields.rs:4:15
|
--> $DIR/numeric-fields.rs:4:15
|
||||||
|
|
|
|
||||||
|
LL | struct S(u8, u16);
|
||||||
|
| - `S` defined here
|
||||||
|
...
|
||||||
LL | let s = S{0b1: 10, 0: 11};
|
LL | let s = S{0b1: 10, 0: 11};
|
||||||
| - ^^^ field does not exist
|
| - ^^^ 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`
|
error[E0026]: struct `S` does not have a field named `0x1`
|
||||||
--> $DIR/numeric-fields.rs:7:17
|
--> $DIR/numeric-fields.rs:7:17
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue