err.emit();
} else {
- self.report_unknown_field(adt_ty, variant, field, ast_fields, kind_name);
+ self.report_unknown_field(adt_ty, variant, field, ast_fields, kind_name, span);
}
tcx.types.err
field: &hir::Field,
skip_fields: &[hir::Field],
kind_name: &str,
+ ty_span: Span
) {
if variant.recovered {
return;
match variant.ctor_kind {
CtorKind::Fn => {
err.span_label(field.ident.span, "field does not exist");
- err.span_label(field.ident.span, format!(
+ err.span_label(ty_span, format!(
"`{adt}` is a tuple {kind_name}, use the appropriate syntax: `{adt}(/* fields */)`",
adt=ty,
kind_name=kind_name
--> $DIR/issue-4736.rs:4:26
|
LL | let z = NonCopyable{ p: () };
- | ^
- | |
- | field does not exist
- | `NonCopyable` is a tuple struct, use the appropriate syntax: `NonCopyable(/* fields */)`
+ | ----------- ^ field does not exist
+ | |
+ | `NonCopyable` is a tuple struct, use the appropriate syntax: `NonCopyable(/* fields */)`
error: aborting due to previous error
--> $DIR/numeric-fields.rs:4:15
|
LL | let s = S{0b1: 10, 0: 11};
- | ^^^
- | |
- | field does not exist
- | `S` is a tuple struct, use the appropriate syntax: `S(/* fields */)`
+ | - ^^^ field does not exist
+ | |
+ | `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