]> git.lizzy.rs Git - rust.git/commitdiff
adt hint pointing to adt span
authorCedric <cedric.brancourt@gmail.com>
Wed, 19 Jun 2019 08:07:07 +0000 (10:07 +0200)
committerCedric <cedric.brancourt@gmail.com>
Wed, 19 Jun 2019 08:07:07 +0000 (10:07 +0200)
src/librustc_typeck/check/expr.rs
src/test/ui/issues/issue-4736.stderr
src/test/ui/numeric/numeric-fields.stderr

index 8edda805592a302b49b56631794e698944865733..3c31e01240317ed999b2def260ec44f64975e905 100644 (file)
@@ -1125,7 +1125,7 @@ fn check_expr_struct_fields(
 
                     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
@@ -1196,6 +1196,7 @@ fn report_unknown_field(
         field: &hir::Field,
         skip_fields: &[hir::Field],
         kind_name: &str,
+        ty_span: Span
     ) {
         if variant.recovered {
             return;
@@ -1218,7 +1219,7 @@ fn report_unknown_field(
         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
index 557ee5593f373e3069359705c2a749a1ba3461d4..6786b592d985717cbbcb7b356fb06e231d457a29 100644 (file)
@@ -2,10 +2,9 @@ error[E0560]: struct `NonCopyable` has no field named `p`
   --> $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
 
index fef7486b8536d88562c969ac416afc3045c7d5d0..e71af0f33ee4291271056bd3e4b127c4b0041b40 100644 (file)
@@ -2,10 +2,9 @@ error[E0560]: struct `S` has no field named `0b1`
   --> $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