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:
+8
-8
@@ -33,10 +33,10 @@ fn CallExplicitGenericParamConst(T:! type) {
|
||||
}
|
||||
|
||||
fn CallExplicitGenericParamNonConst(T: type) {
|
||||
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE+7]]:3: error(CompTimeArgumentNotConstant): argument for generic parameter is not a compile-time constant
|
||||
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE+7]]:3: error: argument for generic parameter is not a compile-time constant [CompTimeArgumentNotConstant]
|
||||
// CHECK:STDERR: ExplicitGenericParam(T);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE-10]]:25: note(InitializingGenericParam): initializing generic parameter `T` declared here
|
||||
// CHECK:STDERR: fail_deduce_explicit_non_constant.carbon:[[@LINE-10]]:25: note: initializing generic parameter `T` declared here [InitializingGenericParam]
|
||||
// CHECK:STDERR: fn ExplicitGenericParam(T:! type) -> T* { return ExplicitGenericParam(T); }
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
@@ -84,10 +84,10 @@ library "[[@TEST_NAME]]";
|
||||
fn StructParam[T:! type](x: {.a: T, .b: i32}) {}
|
||||
|
||||
fn CallStructParam() {
|
||||
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE+7]]:3: error(DeductionIncomplete): cannot deduce value for generic parameter `T`
|
||||
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE+7]]:3: error: cannot deduce value for generic parameter `T` [DeductionIncomplete]
|
||||
// CHECK:STDERR: StructParam({.a = 1, .b = 2});
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE-6]]:1: note(DeductionGenericHere): while deducing parameters of generic declared here
|
||||
// CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
|
||||
// CHECK:STDERR: fn StructParam[T:! type](x: {.a: T, .b: i32}) {}
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
@@ -103,10 +103,10 @@ library "[[@TEST_NAME]]";
|
||||
fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U;
|
||||
|
||||
fn CallImplicitNotDeducible() {
|
||||
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE+7]]:3: error(DeductionIncomplete): cannot deduce value for generic parameter `U`
|
||||
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE+7]]:3: error: cannot deduce value for generic parameter `U` [DeductionIncomplete]
|
||||
// CHECK:STDERR: ImplicitNotDeducible(42);
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE-6]]:1: note(DeductionGenericHere): while deducing parameters of generic declared here
|
||||
// CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
|
||||
// CHECK:STDERR: fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
@@ -120,10 +120,10 @@ library "[[@TEST_NAME]]";
|
||||
fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T;
|
||||
|
||||
fn CallImplicitNotDeducible() {
|
||||
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE+6]]:3: error(DeductionInconsistent): inconsistent deductions for value of generic parameter `T`
|
||||
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE+6]]:3: error: inconsistent deductions for value of generic parameter `T` [DeductionInconsistent]
|
||||
// CHECK:STDERR: ImplicitNotDeducible(42, {.x = 12});
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE-6]]:1: note(DeductionGenericHere): while deducing parameters of generic declared here
|
||||
// CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
|
||||
// CHECK:STDERR: fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
ImplicitNotDeducible(42, {.x = 12});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/fail_todo_param_in_type.carbon
|
||||
|
||||
// CHECK:STDERR: fail_todo_param_in_type.carbon:[[@LINE+3]]:24: error(SemanticsTodo): semantics TODO: `symbolic array bound`
|
||||
// CHECK:STDERR: fail_todo_param_in_type.carbon:[[@LINE+3]]:24: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
|
||||
// CHECK:STDERR: fn F(N:! i32, a: [i32; N]*);
|
||||
// CHECK:STDERR: ^
|
||||
fn F(N:! i32, a: [i32; N]*);
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
|
||||
fn F(T:! type, U:! type) {
|
||||
var p: T*;
|
||||
// CHECK:STDERR: fail_type_param_mismatch.carbon:[[@LINE+3]]:3: error(CoreNotFound): package `Core` implicitly referenced here, but not found
|
||||
// CHECK:STDERR: fail_type_param_mismatch.carbon:[[@LINE+3]]:3: error: package `Core` implicitly referenced here, but not found [CoreNotFound]
|
||||
// CHECK:STDERR: let n: U = *p;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~
|
||||
let n: U = *p;
|
||||
|
||||
+12
-12
@@ -24,18 +24,18 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(T:! type, U:! type) -> T*;
|
||||
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:1: error(FunctionRedeclReturnTypeDiffers): function redeclaration differs because return type is `U*`
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:1: error: function redeclaration differs because return type is `U*` [FunctionRedeclReturnTypeDiffers]
|
||||
// CHECK:STDERR: fn F(T:! type, U:! type) -> U* {
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-5]]:1: note(FunctionRedeclReturnTypePrevious): previously declared with return type `T*`
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-5]]:1: note: previously declared with return type `T*` [FunctionRedeclReturnTypePrevious]
|
||||
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn F(T:! type, U:! type) -> U* {
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:10: error(CallArgCountMismatch): 1 argument passed to function expecting 2 arguments
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE+7]]:10: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
|
||||
// CHECK:STDERR: return F(T);
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-13]]:1: note(InCallToEntity): calling function declared here
|
||||
// CHECK:STDERR: fail_different_return_type.carbon:[[@LINE-13]]:1: note: calling function declared here [InCallToEntity]
|
||||
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
@@ -48,18 +48,18 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(T:! type, U:! type) -> T*;
|
||||
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:6: error(RedeclParamDiffers): redeclaration differs at parameter 1
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:6: error: redeclaration differs at parameter 1 [RedeclParamDiffers]
|
||||
// CHECK:STDERR: fn F(U:! type, T:! type) -> T* {
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-5]]:6: note(RedeclParamPrevious): previous declaration's corresponding parameter here
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-5]]:6: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
|
||||
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn F(U:! type, T:! type) -> T* {
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:10: error(CallArgCountMismatch): 1 argument passed to function expecting 2 arguments
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE+7]]:10: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
|
||||
// CHECK:STDERR: return F(T);
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-13]]:1: note(InCallToEntity): calling function declared here
|
||||
// CHECK:STDERR: fail_reorder.carbon:[[@LINE-13]]:1: note: calling function declared here [InCallToEntity]
|
||||
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
@@ -72,18 +72,18 @@ library "[[@TEST_NAME]]";
|
||||
|
||||
fn F(T:! type, U:! type) -> T*;
|
||||
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE+7]]:6: error(RedeclParamDiffers): redeclaration differs at parameter 1
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE+7]]:6: error: redeclaration differs at parameter 1 [RedeclParamDiffers]
|
||||
// CHECK:STDERR: fn F(U:! type, T:! type) -> U* {
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE-5]]:6: note(RedeclParamPrevious): previous declaration's corresponding parameter here
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE-5]]:6: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
|
||||
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
|
||||
// CHECK:STDERR: ^~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
fn F(U:! type, T:! type) -> U* {
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE+6]]:10: error(CallArgCountMismatch): 1 argument passed to function expecting 2 arguments
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE+6]]:10: error: 1 argument passed to function expecting 2 arguments [CallArgCountMismatch]
|
||||
// CHECK:STDERR: return F(T);
|
||||
// CHECK:STDERR: ^~
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE-13]]:1: note(InCallToEntity): calling function declared here
|
||||
// CHECK:STDERR: fail_rename.carbon:[[@LINE-13]]:1: note: calling function declared here [InCallToEntity]
|
||||
// CHECK:STDERR: fn F(T:! type, U:! type) -> T*;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
return F(T);
|
||||
|
||||
@@ -17,7 +17,7 @@ fn ErrorIfNIsZero(N:! i32) {
|
||||
// ensuring we produce an error when doing so. Notionally this error is
|
||||
// produced as a result of instantiating the `Core.Int` template, although
|
||||
// that's not how we currently model `Core.Int`.
|
||||
// CHECK:STDERR: fail_call_monomorphization_error.carbon:[[@LINE+3]]:10: error(IntWidthNotPositive): integer type width of 0 is not positive
|
||||
// CHECK:STDERR: fail_call_monomorphization_error.carbon:[[@LINE+3]]:10: error: integer type width of 0 is not positive [IntWidthNotPositive]
|
||||
// CHECK:STDERR: var v: Core.Int(N);
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
var v: Core.Int(N);
|
||||
|
||||
@@ -41,10 +41,10 @@ library "[[@TEST_NAME]]";
|
||||
fn Undefined[T:! type](x: T) -> T;
|
||||
|
||||
fn CallUndefined() -> i32 {
|
||||
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE+6]]:10: error(MissingGenericFunctionDefinition): use of undefined generic function
|
||||
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE+6]]:10: error: use of undefined generic function [MissingGenericFunctionDefinition]
|
||||
// CHECK:STDERR: return Undefined(0);
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE-6]]:1: note(MissingGenericFunctionDefinitionHere): generic function declared here
|
||||
// CHECK:STDERR: fail_call_undefined.carbon:[[@LINE-6]]:1: note: generic function declared here [MissingGenericFunctionDefinitionHere]
|
||||
// CHECK:STDERR: fn Undefined[T:! type](x: T) -> T;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
return Undefined(0);
|
||||
|
||||
Reference in New Issue
Block a user