Move diagnostic kind name to the end of the diagnostic. (#4437)

Also surround it in square brackets rather than parentheses. This
matches the format used by Clang and GCC, and means diagnostics will
still match the `file:line:col: error: ` pattern used by some IDE tools.

Before:
```console
fail_builtins.carbon:11:11: error(AliasRequiresNameRef): alias initializer must be a name reference
```

After:
```console
fail_builtins.carbon:11:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
```

Also tighten up test regex to only match on `STDERR` lines that list a
file name.
This commit is contained in:
Richard Smith
2024-10-23 16:56:23 +00:00
committed by GitHub
parent f206072216
commit 2e63da1a40
528 changed files with 1929 additions and 1928 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_comma_only.carbon
// CHECK:STDERR: fail_comma_only.carbon:[[@LINE+3]]:9: error(ExpectedStructLiteralField): expected `.field: field_type` or `.field = value`
// CHECK:STDERR: fail_comma_only.carbon:[[@LINE+3]]:9: error: expected `.field: field_type` or `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {,} = {};
// CHECK:STDERR: ^
var x: {,} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon
// CHECK:STDERR: fail_comma_repeat_in_type.carbon:[[@LINE+3]]:17: error(ExpectedStructLiteralField): expected `.field: field_type`
// CHECK:STDERR: fail_comma_repeat_in_type.carbon:[[@LINE+3]]:17: error: expected `.field: field_type` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {.a: i32,,} = {};
// CHECK:STDERR: ^
var x: {.a: i32,,} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon
// CHECK:STDERR: fail_comma_repeat_in_value.carbon:[[@LINE+3]]:16: error(ExpectedStructLiteralField): expected `.field = value`
// CHECK:STDERR: fail_comma_repeat_in_value.carbon:[[@LINE+3]]:16: error: expected `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {.a = 0,,} = {};
// CHECK:STDERR: ^
var x: {.a = 0,,} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon
// CHECK:STDERR: fail_extra_token_in_type.carbon:[[@LINE+3]]:17: error(UnexpectedTokenAfterListElement): expected `,` or `}`
// CHECK:STDERR: fail_extra_token_in_type.carbon:[[@LINE+3]]:17: error: expected `,` or `}` [UnexpectedTokenAfterListElement]
// CHECK:STDERR: var x: {.a: i32 banana} = {.a = 0};
// CHECK:STDERR: ^~~~~~
var x: {.a: i32 banana} = {.a = 0};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon
// CHECK:STDERR: fail_extra_token_in_value.carbon:[[@LINE+3]]:28: error(UnexpectedTokenAfterListElement): expected `,` or `}`
// CHECK:STDERR: fail_extra_token_in_value.carbon:[[@LINE+3]]:28: error: expected `,` or `}` [UnexpectedTokenAfterListElement]
// CHECK:STDERR: var x: {.a: i32} = {.a = 0 banana};
// CHECK:STDERR: ^~~~~~
var x: {.a: i32} = {.a = 0 banana};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_identifier_colon.carbon
// CHECK:STDERR: fail_identifier_colon.carbon:[[@LINE+3]]:9: error(ExpectedStructLiteralField): expected `.field: field_type` or `.field = value`
// CHECK:STDERR: fail_identifier_colon.carbon:[[@LINE+3]]:9: error: expected `.field: field_type` or `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {a:} = {};
// CHECK:STDERR: ^
var x: {a:} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_identifier_equals.carbon
// CHECK:STDERR: fail_identifier_equals.carbon:[[@LINE+3]]:9: error(ExpectedStructLiteralField): expected `.field: field_type` or `.field = value`
// CHECK:STDERR: fail_identifier_equals.carbon:[[@LINE+3]]:9: error: expected `.field: field_type` or `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {a=} = {};
// CHECK:STDERR: ^
var x: {a=} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_identifier_only.carbon
// CHECK:STDERR: fail_identifier_only.carbon:[[@LINE+3]]:9: error(ExpectedStructLiteralField): expected `.field: field_type` or `.field = value`
// CHECK:STDERR: fail_identifier_only.carbon:[[@LINE+3]]:9: error: expected `.field: field_type` or `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {a} = {};
// CHECK:STDERR: ^
var x: {a} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_invalid_struct_designator.carbon
// CHECK:STDERR: fail_invalid_struct_designator.carbon:[[@LINE+3]]:16: error(ExpectedIdentifierAfterPeriodOrArrow): expected identifier after `.`
// CHECK:STDERR: fail_invalid_struct_designator.carbon:[[@LINE+3]]:16: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
// CHECK:STDERR: var x: i32 = {.7 = 8};
// CHECK:STDERR: ^
var x: i32 = {.7 = 8};
+1 -1
View File
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_missing_type.carbon
// CHECK:STDERR: fail_missing_type.carbon:[[@LINE+3]]:12: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_missing_type.carbon:[[@LINE+3]]:12: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var x: {.a:} = {};
// CHECK:STDERR: ^
var x: {.a:} = {};
+1 -1
View File
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_missing_value.carbon
// CHECK:STDERR: fail_missing_value.carbon:[[@LINE+3]]:12: error(ExpectedExpr): expected expression
// CHECK:STDERR: fail_missing_value.carbon:[[@LINE+3]]:12: error: expected expression [ExpectedExpr]
// CHECK:STDERR: var x: {.a=} = {};
// CHECK:STDERR: ^
var x: {.a=} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon
// CHECK:STDERR: fail_mix_type_and_value.carbon:[[@LINE+3]]:21: error(ExpectedStructLiteralField): expected `.field: field_type`
// CHECK:STDERR: fail_mix_type_and_value.carbon:[[@LINE+3]]:21: error: expected `.field: field_type` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {.a: i32, .b = 0} = {};
// CHECK:STDERR: ^
var x: {.a: i32, .b = 0} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon
// CHECK:STDERR: fail_mix_value_and_type.carbon:[[@LINE+3]]:17: error(ExpectedStructLiteralField): expected `.field = value`
// CHECK:STDERR: fail_mix_value_and_type.carbon:[[@LINE+3]]:17: error: expected `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {.a = 0, b: i32} = {};
// CHECK:STDERR: ^
var x: {.a = 0, b: i32} = {};
@@ -8,21 +8,21 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+8]]:25: error(ExpectedStructLiteralField): expected `.field = value`
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+8]]:25: error: expected `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: i32 = {.a = 1, .b, .c: i32};
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+4]]:29: error(ExpectedStructLiteralField): expected `.field = value`
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+4]]:29: error: expected `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: i32 = {.a = 1, .b, .c: i32};
// CHECK:STDERR: ^
// CHECK:STDERR:
var x: i32 = {.a = 1, .b, .c: i32};
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+7]]:26: error(ExpectedStructLiteralField): expected `.field: field_type`
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+7]]:26: error: expected `.field: field_type` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: i32 = {.a: i32, .b, .c = 1};
// CHECK:STDERR: ^
// CHECK:STDERR:
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+3]]:31: error(ExpectedStructLiteralField): expected `.field: field_type`
// CHECK:STDERR: fail_mix_with_unknown.carbon:[[@LINE+3]]:31: error: expected `.field: field_type` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: i32 = {.a: i32, .b, .c = 1};
// CHECK:STDERR: ^
var x: i32 = {.a: i32, .b, .c = 1};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon
// CHECK:STDERR: fail_no_colon_or_equals.carbon:[[@LINE+3]]:11: error(ExpectedStructLiteralField): expected `.field: field_type` or `.field = value`
// CHECK:STDERR: fail_no_colon_or_equals.carbon:[[@LINE+3]]:11: error: expected `.field: field_type` or `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {.a} = {};
// CHECK:STDERR: ^
var x: {.a} = {};
+1 -1
View File
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_only.carbon
// CHECK:STDERR: fail_period_only.carbon:[[@LINE+3]]:10: error(ExpectedIdentifierAfterPeriodOrArrow): expected identifier after `.`
// CHECK:STDERR: fail_period_only.carbon:[[@LINE+3]]:10: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
// CHECK:STDERR: var x: {.} = {};
// CHECK:STDERR: ^
var x: {.} = {};
+1 -1
View File
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_paren.carbon
// CHECK:STDERR: fail_period_paren.carbon:[[@LINE+3]]:10: error(ExpectedIdentifierAfterPeriodOrArrow): expected identifier after `.`
// CHECK:STDERR: fail_period_paren.carbon:[[@LINE+3]]:10: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
// CHECK:STDERR: var x: {.(a) = 1};
// CHECK:STDERR: ^
var x: {.(a) = 1};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_string_colon.carbon
// CHECK:STDERR: fail_period_string_colon.carbon:[[@LINE+3]]:10: error(ExpectedIdentifierAfterPeriodOrArrow): expected identifier after `.`
// CHECK:STDERR: fail_period_string_colon.carbon:[[@LINE+3]]:10: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
// CHECK:STDERR: var x: {."hello": i32, .y: i32} = {};
// CHECK:STDERR: ^~~~~~~
var x: {."hello": i32, .y: i32} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_period_string_equals.carbon
// CHECK:STDERR: fail_period_string_equals.carbon:[[@LINE+3]]:10: error(ExpectedIdentifierAfterPeriodOrArrow): expected identifier after `.`
// CHECK:STDERR: fail_period_string_equals.carbon:[[@LINE+3]]:10: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
// CHECK:STDERR: var x: {."hello" = 0, .y = 4} = {};
// CHECK:STDERR: ^~~~~~~
var x: {."hello" = 0, .y = 4} = {};
@@ -8,7 +8,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/struct/fail_type_no_designator.carbon
// CHECK:STDERR: fail_type_no_designator.carbon:[[@LINE+3]]:9: error(ExpectedStructLiteralField): expected `.field: field_type` or `.field = value`
// CHECK:STDERR: fail_type_no_designator.carbon:[[@LINE+3]]:9: error: expected `.field: field_type` or `.field = value` [ExpectedStructLiteralField]
// CHECK:STDERR: var x: {i32} = {};
// CHECK:STDERR: ^~~
var x: {i32} = {};