Switch tests to use the rendered form of diagnostics (#8070)

Historically, we disabled the rendered form in tests outside of
`toolchain/diagnostics`. The idea was to keep tests shorter and avoid
very long chains of autoupdate before stabilizing due to all the line
numbers and other artifacts in the rendered form.

This PR adds `--diagnostic-line-numbers=[all|first]` and defaults to
`first` in tests. This keeps the rendered form so that we can easily
code review that form and the visual cues it does or doesn't provide.
But it removes all but the first location's line numbers to provide
significantly more stability in tests.

By default, tests get the full unicode line-drawing form of diagnostics
so we can ensure all of the artifacts there make sense with the specific
case being diagnosed, but we do retain some focused ASCII-rendering
tests to ensure that fallback remains usable.

There are some issues here that will be fixed in subsequent PRs.
Notably, we try to keep the frame together in the check lines, and so
force some parts to use the first location. This largely works, but
fails in some edge cases, causing the entire frame to be located
incorrectly. There is a TODO about this that we need to fix, and it only
occurs 6 times across the test suite, so it didn't seem worth
front-loading a fix for here.

Assisted-by: Claude Code
This commit is contained in:
Chandler Carruth authored and GitHub committed 2026-11-05 07:19:59 +00:00
1 parent 0b7059a360
commit d0badecd2a
888 files changed
+39731 -12799

No files matched your search

+39 -7
View File
@@ -81,12 +81,36 @@ library "[[@TEST_NAME]]";
class Incomplete;
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+7]]:8-27: error: binding pattern has incomplete type `array(Incomplete, 1)` in name binding declaration [IncompleteTypeInBindingDecl]
// CHECK:STDERR: min_prelude/parts/array.carbon:13:3-24: note: `<builtin array(T, N)>` evaluates to incomplete type `<builtin array(Incomplete, 1)>` [IncompleteTypeInMonomorphization]
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-4]]:1-17: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: ╭─┤ fail_incomplete_element.carbon:[[@LINE+31]]:8
// CHECK:STDERR: │ class Incomplete;
// CHECK:STDERR: · ────────┬────────
// CHECK:STDERR: · ╰──┤ class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ var a: array(Incomplete, 1);
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: binding pattern has incomplete type `array(Incomplete, 1)` in
// CHECK:STDERR: · ┃ name binding declaration
// CHECK:STDERR: · ┃ [IncompleteTypeInBindingDecl]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ min_prelude/parts/array.carbon
// CHECK:STDERR: │ adapt MakeArray(T, N);
// CHECK:STDERR: · ┬─────────────────────
// CHECK:STDERR: · ╰──┤ `<builtin array(T, N)>` evaluates to incomplete type
// CHECK:STDERR: · │ `<builtin array(Incomplete, 1)>`
// CHECK:STDERR: · │ [IncompleteTypeInMonomorphization]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+3]]:8-27: error: binding pattern has incomplete type `array(Incomplete, 1)` in name binding declaration [IncompleteTypeInBindingDecl]
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-7]]:1-17: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: ╭─┤ fail_incomplete_element.carbon:[[@LINE+12]]:8
// CHECK:STDERR: │ class Incomplete;
// CHECK:STDERR: · ────────┬────────
// CHECK:STDERR: · ╰──┤ class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ var a: array(Incomplete, 1);
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: binding pattern has incomplete type `array(Incomplete, 1)` in
// CHECK:STDERR: · ┃ name binding declaration
// CHECK:STDERR: · ┃ [IncompleteTypeInBindingDecl]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var a: array(Incomplete, 1);
@@ -96,8 +120,16 @@ var p: Incomplete* = &a[0];
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_invalid_element.carbon:[[@LINE+3]]:14: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: fail_invalid_element.carbon:[[@LINE+2]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_invalid_element.carbon:[[@LINE+11]]:14
// CHECK:STDERR: -> │ var a: array(1, 1);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert non-type value of type
// CHECK:STDERR: · │ ┃ `Core.IntLiteral` to `type`
// CHECK:STDERR: · │ ┃ [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: · ╰────┤ type `Core.IntLiteral` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(type)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var a: array(1, 1);
+22 -4
View File
@@ -36,7 +36,12 @@ let b: array(i32, 3)* = &a;
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_negative.carbon:[[@LINE+2]]:19-20: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: ╭─┤ fail_negative.carbon:[[@LINE+7]]:19
// CHECK:STDERR: -> │ var a: array(i32, -1);
// CHECK:STDERR: · ━┳
// CHECK:STDERR: · ┗━━┫ error: array bound of -1 is negative
// CHECK:STDERR: · ┃ [ArrayBoundNegative]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var a: array(i32, -1);
@@ -44,7 +49,12 @@ var a: array(i32, -1);
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_overflow.carbon:[[@LINE+2]]:19-38: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge]
// CHECK:STDERR: ╭─┤ fail_overflow.carbon:[[@LINE+7]]:19
// CHECK:STDERR: -> │ var a: array(i32, 39999999999999999993);
// CHECK:STDERR: · ━━┳━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: array bound of 39999999999999999993 is too large
// CHECK:STDERR: · ┃ [ArrayBoundTooLarge]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var a: array(i32, 39999999999999999993);
@@ -52,8 +62,16 @@ var a: array(i32, 39999999999999999993);
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_invalid_type_with_overflow.carbon:[[@LINE+3]]:14: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: fail_invalid_type_with_overflow.carbon:[[@LINE+2]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_invalid_type_with_overflow.carbon:[[@LINE+11]]:14
// CHECK:STDERR: -> │ var b: array(1, 39999999999999999993);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert non-type value of type
// CHECK:STDERR: · │ ┃ `Core.IntLiteral` to `type`
// CHECK:STDERR: · │ ┃ [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: · ╰────┤ type `Core.IntLiteral` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(type)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var b: array(1, 39999999999999999993);
+49 -9
View File
@@ -16,8 +16,16 @@ library "[[@TEST_NAME]]";
class C {}
// CHECK:STDERR: fail_arg_wrong_type.carbon:[[@LINE+3]]:22-35: error: cannot implicitly convert expression of type `()` to `C` [ConversionFailure]
// CHECK:STDERR: fail_arg_wrong_type.carbon:[[@LINE+2]]:22-35: note: type `()` does not implement interface `Core.ImplicitAs(C)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_arg_wrong_type.carbon:[[@LINE+11]]:22
// CHECK:STDERR: -> │ var a: array(C, 3) = ({}, (), true);
// CHECK:STDERR: · ┳━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `()` to `C`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `()` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(C)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var a: array(C, 3) = ({}, (), true);
@@ -29,14 +37,28 @@ class C {}
class D {}
var a: (D, C, D);
// CHECK:STDERR: fail_var_wrong_type.carbon:[[@LINE+3]]:22: error: cannot implicitly convert expression of type `D` to `C` [ConversionFailure]
// CHECK:STDERR: fail_var_wrong_type.carbon:[[@LINE+2]]:22: note: type `D` does not implement interface `Core.ImplicitAs(C)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_var_wrong_type.carbon:[[@LINE+11]]:22
// CHECK:STDERR: -> │ var b: array(C, 3) = a;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `D` to `C`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `D` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(C)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var b: array(C, 3) = a;
var c: (C, D, D);
// CHECK:STDERR: fail_var_wrong_type.carbon:[[@LINE+3]]:22: error: cannot copy value of type `C` [CopyOfUncopyableType]
// CHECK:STDERR: fail_var_wrong_type.carbon:[[@LINE+2]]:22: note: type `C` does not implement interface `Core.Copy` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_var_wrong_type.carbon:[[@LINE+9]]:22
// CHECK:STDERR: -> │ var d: array(C, 3) = c;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: cannot copy value of type `C`
// CHECK:STDERR: · │ ┃ [CopyOfUncopyableType]
// CHECK:STDERR: · ╰────┤ type `C` does not implement interface `Core.Copy`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var d: array(C, 3) = c;
@@ -46,7 +68,13 @@ library "[[@TEST_NAME]]";
class C {}
// CHECK:STDERR: fail_arg_too_short.carbon:[[@LINE+2]]:22-29: error: cannot initialize array of 3 elements from 2 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: ╭─┤ fail_arg_too_short.carbon:[[@LINE+8]]:22
// CHECK:STDERR: -> │ var a: array(C, 3) = ({}, {});
// CHECK:STDERR: · ┳━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot initialize array of 3 elements from 2
// CHECK:STDERR: · ┃ initializers
// CHECK:STDERR: · ┃ [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var a: array(C, 3) = ({}, {});
@@ -57,12 +85,24 @@ library "[[@TEST_NAME]]";
class C {}
var a: (C, C);
// CHECK:STDERR: fail_var_too_short.carbon:[[@LINE+2]]:22: error: cannot initialize array of 3 elements from tuple with 2 elements [ArrayInitFromExprArgCountMismatch]
// CHECK:STDERR: ╭─┤ fail_var_too_short.carbon:[[@LINE+8]]:22
// CHECK:STDERR: -> │ var b: array(C, 3) = a;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: cannot initialize array of 3 elements from
// CHECK:STDERR: · ┃ tuple with 2 elements
// CHECK:STDERR: · ┃ [ArrayInitFromExprArgCountMismatch]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var b: array(C, 3) = a;
// --- fail_arg_too_long.carbon
// CHECK:STDERR: fail_arg_too_long.carbon:[[@LINE+2]]:23-34: error: cannot initialize array of 1 element from 3 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: ╭─┤ fail_arg_too_long.carbon:[[@LINE+8]]:23
// CHECK:STDERR: -> │ var a: array((), 1) = ((), (), ());
// CHECK:STDERR: · ┳━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot initialize array of 1 element from 3
// CHECK:STDERR: · ┃ initializers
// CHECK:STDERR: · ┃ [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var a: array((), 1) = ((), (), ());
+6 -1
View File
@@ -39,7 +39,12 @@ fn F(a: array({}, 3)) -> {} {
library "[[@TEST_NAME]]";
fn F(a: array({}, 3)) -> {} {
// CHECK:STDERR: fail_out_of_bound_non_literal.carbon:[[@LINE+2]]:12-29: error: array index `3` is past the end of type `array({}, 3)` [ArrayIndexOutOfBounds]
// CHECK:STDERR: ╭─┤ fail_out_of_bound_non_literal.carbon:[[@LINE+7]]:12
// CHECK:STDERR: -> │ return a[{.index = 3}.index];
// CHECK:STDERR: · ━━━┳━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: array index `3` is past the end of type `array({}, 3)`
// CHECK:STDERR: · ┃ [ArrayIndexOutOfBounds]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
return a[{.index = 3}.index];
}
+20 -3
View File
@@ -32,7 +32,14 @@ fn H() {
library "[[@TEST_NAME]]";
fn F(generic N: i32) {
// CHECK:STDERR: fail_init_dependent_bound.carbon:[[@LINE+2]]:35-43: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound]
// CHECK:STDERR: ╭─┤ fail_init_dependent_bound.carbon:[[@LINE+9]]:35
// CHECK:STDERR: -> │ var unused arr: array(i32, N) = (1, 2, 3);
// CHECK:STDERR: · ┳━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot initialize array with
// CHECK:STDERR: · ┃ dependent bound from a list of
// CHECK:STDERR: · ┃ initializers
// CHECK:STDERR: · ┃ [ArrayInitDependentBound]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var unused arr: array(i32, N) = (1, 2, 3);
}
@@ -45,8 +52,18 @@ interface Y(T: type, U: T) {}
constraint Z(N: i32) {
// Forming the specific of `Y` uses constant values which are canonical and
// have no location. The error should still point somewhere reasonable.
// CHECK:STDERR: fail_init_dependent_bound_in_constant.carbon:[[@LINE+3]]:24-42: error: cannot initialize array with dependent bound from a list of initializers [ArrayInitDependentBound]
// CHECK:STDERR: fail_init_dependent_bound_in_constant.carbon:[[@LINE-6]]:1-28: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: ╭─┤ fail_init_dependent_bound_in_constant.carbon:[[@LINE+13]]:24
// CHECK:STDERR: │ interface Y(T: type, U: T) {}
// CHECK:STDERR: · ──────────────┬─────────────
// CHECK:STDERR: · ╰──┤ while deducing parameters of generic declared here
// CHECK:STDERR: · │ [DeductionGenericHere]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ extend require impls Y(array((), N), ());
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot initialize array with dependent bound
// CHECK:STDERR: · ┃ from a list of initializers
// CHECK:STDERR: · ┃ [ArrayInitDependentBound]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
extend require impls Y(array((), N), ());
}