mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -9,7 +9,7 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_access_into_invalid.carbon
|
||||
|
||||
|
||||
// CHECK:STDERR: fail_access_into_invalid.carbon:[[@LINE+3]]:10: error(NameNotFound): name `a` not found
|
||||
// CHECK:STDERR: fail_access_into_invalid.carbon:[[@LINE+3]]:10: error: name `a` not found [NameNotFound]
|
||||
// CHECK:STDERR: fn F() { a.b; }
|
||||
// CHECK:STDERR: ^
|
||||
fn F() { a.b; }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_assign_empty.carbon
|
||||
|
||||
// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+3]]:20: error(StructInitElementCountMismatch): cannot initialize struct with 1 field from struct with 0 fields
|
||||
// CHECK:STDERR: fail_assign_empty.carbon:[[@LINE+3]]:20: error: cannot initialize struct with 1 field from struct with 0 fields [StructInitElementCountMismatch]
|
||||
// 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/check/testdata/struct/fail_assign_to_empty.carbon
|
||||
|
||||
// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+3]]:13: error(StructInitElementCountMismatch): cannot initialize struct with 0 fields from struct with 1 field
|
||||
// CHECK:STDERR: fail_assign_to_empty.carbon:[[@LINE+3]]:13: error: cannot initialize struct with 0 fields from struct with 1 field [StructInitElementCountMismatch]
|
||||
// CHECK:STDERR: var x: {} = {.a = 1};
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
var x: {} = {.a = 1};
|
||||
|
||||
+10
-10
@@ -8,46 +8,46 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_duplicate_name.carbon
|
||||
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:42: error(StructNameDuplicate): duplicated field name `abc` in struct type literal
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:42: error: duplicated field name `abc` in struct type literal [StructNameDuplicate]
|
||||
// CHECK:STDERR: fn F() -> {.d: i32, .abc: i32, .e: i32, .abc: i32, .f: i32};
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:22: note(StructNamePrevious): field with the same name here
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:22: note: field with the same name here [StructNamePrevious]
|
||||
// CHECK:STDERR: fn F() -> {.d: i32, .abc: i32, .e: i32, .abc: i32, .f: i32};
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
fn F() -> {.d: i32, .abc: i32, .e: i32, .abc: i32, .f: i32};
|
||||
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:19: error(StructNameDuplicate): duplicated field name `a` in struct type literal
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:19: error: duplicated field name `a` in struct type literal [StructNameDuplicate]
|
||||
// CHECK:STDERR: let v: {.a: i32, .a: i32} = {.a = 1};
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:10: note(StructNamePrevious): field with the same name here
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:10: note: field with the same name here [StructNamePrevious]
|
||||
// CHECK:STDERR: let v: {.a: i32, .a: i32} = {.a = 1};
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
let v: {.a: i32, .a: i32} = {.a = 1};
|
||||
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:26: error(StructNameDuplicate): duplicated field name `def` in struct literal
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:26: error: duplicated field name `def` in struct literal [StructNameDuplicate]
|
||||
// CHECK:STDERR: let w: i32 = {.def = 1, .def = 2}.def;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:16: note(StructNamePrevious): field with the same name here
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:16: note: field with the same name here [StructNamePrevious]
|
||||
// CHECK:STDERR: let w: i32 = {.def = 1, .def = 2}.def;
|
||||
// CHECK:STDERR: ^~~
|
||||
// CHECK:STDERR:
|
||||
let w: i32 = {.def = 1, .def = 2}.def;
|
||||
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:30: error(StructNameDuplicate): duplicated field name `a` in struct literal
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+7]]:30: error: duplicated field name `a` in struct literal [StructNameDuplicate]
|
||||
// CHECK:STDERR: var x: {.a: i32} = {.a = 1, .a = 2};
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:22: note(StructNamePrevious): field with the same name here
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+4]]:22: note: field with the same name here [StructNamePrevious]
|
||||
// CHECK:STDERR: var x: {.a: i32} = {.a = 1, .a = 2};
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
var x: {.a: i32} = {.a = 1, .a = 2};
|
||||
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+6]]:39: error(StructNameDuplicate): duplicated field name `b` in struct literal
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+6]]:39: error: duplicated field name `b` in struct literal [StructNameDuplicate]
|
||||
// CHECK:STDERR: var y: {.b: i32, .c: i32} = {.b = 3, .b = 4};
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+3]]:31: note(StructNamePrevious): field with the same name here
|
||||
// CHECK:STDERR: fail_duplicate_name.carbon:[[@LINE+3]]:31: note: field with the same name here [StructNamePrevious]
|
||||
// CHECK:STDERR: var y: {.b: i32, .c: i32} = {.b = 3, .b = 4};
|
||||
// CHECK:STDERR: ^
|
||||
var y: {.b: i32, .c: i32} = {.b = 3, .b = 4};
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_field_name_mismatch.carbon
|
||||
|
||||
// CHECK:STDERR: fail_field_name_mismatch.carbon:[[@LINE+4]]:20: error(StructInitMissingFieldInLiteral): missing value for field `a` in struct initialization
|
||||
// CHECK:STDERR: fail_field_name_mismatch.carbon:[[@LINE+4]]:20: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
|
||||
// CHECK:STDERR: var x: {.a: i32} = {.b = 1};
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
var x: {.a: i32} = {.b = 1};
|
||||
|
||||
// CHECK:STDERR: fail_field_name_mismatch.carbon:[[@LINE+3]]:20: error(StructInitMissingFieldInConversion): cannot convert from struct type `{.a: i32}` to `{.b: i32}`: missing field `b` in source type
|
||||
// CHECK:STDERR: fail_field_name_mismatch.carbon:[[@LINE+3]]:20: error: cannot convert from struct type `{.a: i32}` to `{.b: i32}`: missing field `b` in source type [StructInitMissingFieldInConversion]
|
||||
// CHECK:STDERR: var y: {.b: i32} = x;
|
||||
// CHECK:STDERR: ^
|
||||
var y: {.b: i32} = x;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_field_type_mismatch.carbon
|
||||
|
||||
// CHECK:STDERR: fail_field_type_mismatch.carbon:[[@LINE+3]]:20: error(StructInitMissingFieldInLiteral): missing value for field `a` in struct initialization
|
||||
// CHECK:STDERR: fail_field_type_mismatch.carbon:[[@LINE+3]]:20: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
|
||||
// CHECK:STDERR: var x: {.a: i32} = {.b = 1.0};
|
||||
// CHECK:STDERR: ^~~~~~~~~~
|
||||
var x: {.a: i32} = {.b = 1.0};
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_keyword_name.carbon
|
||||
|
||||
// CHECK:STDERR: fail_keyword_name.carbon:[[@LINE+8]]:13: error(ExpectedIdentifierAfterPeriodOrArrow): expected identifier after `.`
|
||||
// CHECK:STDERR: fail_keyword_name.carbon:[[@LINE+8]]:13: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
|
||||
// CHECK:STDERR: fn F() -> {.class: i32};
|
||||
// CHECK:STDERR: ^~~~~
|
||||
// CHECK:STDERR:
|
||||
// CHECK:STDERR: fail_keyword_name.carbon:[[@LINE+4]]:13: error(SemanticsTodo): semantics TODO: `Error recovery from keyword name.`
|
||||
// CHECK:STDERR: fail_keyword_name.carbon:[[@LINE+4]]:13: error: semantics TODO: `Error recovery from keyword name.` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn F() -> {.class: i32};
|
||||
// CHECK:STDERR: ^~~~~
|
||||
// CHECK:STDERR:
|
||||
fn F() -> {.class: i32};
|
||||
|
||||
// CHECK:STDERR: fail_keyword_name.carbon:[[@LINE+3]]:19: error(ExpectedIdentifierAfterPeriodOrArrow): expected identifier after `.`
|
||||
// CHECK:STDERR: fail_keyword_name.carbon:[[@LINE+3]]:19: error: expected identifier after `.` [ExpectedIdentifierAfterPeriodOrArrow]
|
||||
// CHECK:STDERR: fn G() { return {.return = 5}; };
|
||||
// CHECK:STDERR: ^~~~~~
|
||||
fn G() { return {.return = 5}; };
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_member_access_type.carbon
|
||||
|
||||
var x: {.a: f64} = {.a = 4.0};
|
||||
// CHECK:STDERR: fail_member_access_type.carbon:[[@LINE+3]]:14: error(QualifiedExprNameNotFound): type `{.a: f64}` does not have a member `b`
|
||||
// CHECK:STDERR: fail_member_access_type.carbon:[[@LINE+3]]:14: error: type `{.a: f64}` does not have a member `b` [QualifiedExprNameNotFound]
|
||||
// CHECK:STDERR: var y: i32 = x.b;
|
||||
// CHECK:STDERR: ^~~
|
||||
var y: i32 = x.b;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_member_of_function.carbon
|
||||
|
||||
fn A() {
|
||||
// CHECK:STDERR: fail_member_of_function.carbon:[[@LINE+3]]:3: error(UseOfNonExprAsValue): expression cannot be used as a value
|
||||
// CHECK:STDERR: fail_member_of_function.carbon:[[@LINE+3]]:3: error: expression cannot be used as a value [UseOfNonExprAsValue]
|
||||
// CHECK:STDERR: A.y;
|
||||
// CHECK:STDERR: ^
|
||||
A.y;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_non_member_access.carbon
|
||||
|
||||
var x: {.a: i32} = {.a = 4};
|
||||
// CHECK:STDERR: fail_non_member_access.carbon:[[@LINE+3]]:14: error(QualifiedExprNameNotFound): type `{.a: i32}` does not have a member `b`
|
||||
// CHECK:STDERR: fail_non_member_access.carbon:[[@LINE+3]]:14: error: type `{.a: i32}` does not have a member `b` [QualifiedExprNameNotFound]
|
||||
// CHECK:STDERR: var y: i32 = x.b;
|
||||
// CHECK:STDERR: ^~~
|
||||
var y: i32 = x.b;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_too_few_values.carbon
|
||||
|
||||
// CHECK:STDERR: fail_too_few_values.carbon:[[@LINE+3]]:29: error(StructInitElementCountMismatch): cannot initialize struct with 2 fields from struct with 1 field
|
||||
// CHECK:STDERR: fail_too_few_values.carbon:[[@LINE+3]]:29: error: cannot initialize struct with 2 fields from struct with 1 field [StructInitElementCountMismatch]
|
||||
// CHECK:STDERR: var x: {.a: i32, .b: i32} = {.a = 1};
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
var x: {.a: i32, .b: i32} = {.a = 1};
|
||||
|
||||
+2
-2
@@ -8,10 +8,10 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_type_assign.carbon
|
||||
|
||||
// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+6]]:1: error(ImplicitAsConversionFailure): cannot implicitly convert from `type` to `{.a: i32}`
|
||||
// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+6]]:1: error: cannot implicitly convert from `type` to `{.a: i32}` [ImplicitAsConversionFailure]
|
||||
// CHECK:STDERR: var x: {.a: i32} = {.a: i32};
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+3]]:1: note(MissingImplInMemberAccessNote): type `type` does not implement interface `ImplicitAs`
|
||||
// CHECK:STDERR: fail_type_assign.carbon:[[@LINE+3]]:1: note: type `type` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
|
||||
// CHECK:STDERR: var x: {.a: i32} = {.a: i32};
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var x: {.a: i32} = {.a: i32};
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/fail_value_as_type.carbon
|
||||
|
||||
// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+6]]:8: error(ImplicitAsConversionFailure): cannot implicitly convert from `{.a: i32}` to `type`
|
||||
// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+6]]:8: error: cannot implicitly convert from `{.a: i32}` to `type` [ImplicitAsConversionFailure]
|
||||
// CHECK:STDERR: var x: {.a = 1};
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+3]]:8: note(MissingImplInMemberAccessNote): type `{.a: i32}` does not implement interface `ImplicitAs`
|
||||
// CHECK:STDERR: fail_value_as_type.carbon:[[@LINE+3]]:8: note: type `{.a: i32}` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
|
||||
// CHECK:STDERR: var x: {.a = 1};
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
var x: {.a = 1};
|
||||
|
||||
+5
-5
@@ -30,11 +30,11 @@ var c: C({.a = 1, .b = 2}) = F();
|
||||
// --- fail_bad_type.impl.carbon
|
||||
|
||||
impl package Implicit;
|
||||
// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+8]]:14: error(StructInitMissingFieldInLiteral): missing value for field `a` in struct initialization
|
||||
// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+8]]:14: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
|
||||
// CHECK:STDERR: var c_bad: C({.c = 1, .d = 2}) = F();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE-4]]:6(InImport): in import
|
||||
// CHECK:STDERR: implicit.carbon:8:1: note(DeductionGenericHere): while deducing parameters of generic declared here
|
||||
// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE-4]]:6: in import [InImport]
|
||||
// CHECK:STDERR: implicit.carbon:8:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
|
||||
// CHECK:STDERR: class C(S:! {.a: i32, .b: i32}) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
@@ -43,10 +43,10 @@ var c_bad: C({.c = 1, .d = 2}) = F();
|
||||
// --- fail_bad_value.impl.carbon
|
||||
|
||||
impl package Implicit;
|
||||
// CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+6]]:1: error(ImplicitAsConversionFailure): cannot implicitly convert from `C` to `C`
|
||||
// CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+6]]:1: error: cannot implicitly convert from `C` to `C` [ImplicitAsConversionFailure]
|
||||
// CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+3]]:1: note(MissingImplInMemberAccessNote): type `C` does not implement interface `ImplicitAs`
|
||||
// CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+3]]:1: note: type `C` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
|
||||
// CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F();
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var c_bad: C({.a = 3, .b = 4}) = F();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/no_prelude/fail_assign_nested.carbon
|
||||
|
||||
// CHECK:STDERR: fail_assign_nested.carbon:[[@LINE+3]]:19: error(StructInitMissingFieldInLiteral): missing value for field `a` in struct initialization
|
||||
// CHECK:STDERR: fail_assign_nested.carbon:[[@LINE+3]]:19: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
|
||||
// CHECK:STDERR: var x: {.a: {}} = {.b = {}};
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
var x: {.a: {}} = {.b = {}};
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
class Incomplete;
|
||||
|
||||
// CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE+6]]:8: error(IncompleteTypeInVarDecl): variable has incomplete type `{.a: Incomplete}`
|
||||
// CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE+6]]:8: error: variable has incomplete type `{.a: Incomplete}` [IncompleteTypeInVarDecl]
|
||||
// CHECK:STDERR: var s: {.a: Incomplete};
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE-5]]:1: note(ClassForwardDeclaredHere): class was forward declared here
|
||||
// CHECK:STDERR: fail_nested_incomplete.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
|
||||
// CHECK:STDERR: class Incomplete;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
|
||||
var s: {.a: Incomplete};
|
||||
|
||||
Reference in New Issue
Block a user