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

@@ -45,8 +45,19 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_too_few_arguments.carbon:[[@LINE+3]]:26: error: too few template arguments for class template 'TwoTypes' [CppInteropParseError]
// CHECK:STDERR: ./templates.h:5:41: note: template is declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_too_few_arguments.carbon:[[@LINE+14]]:26
// CHECK:STDERR: -> │ var x: Cpp.TwoTypes(Cpp.A);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: too few template arguments for class
// CHECK:STDERR: · ┃ template 'TwoTypes'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./templates.h
// CHECK:STDERR: │ template<typename T, typename U> struct TwoTypes {};
// CHECK:STDERR: · ──────────────────────────────── ┬
// CHECK:STDERR: · ╰──┤ template is declared here
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoTypes(Cpp.A);
@@ -56,8 +67,19 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_too_many_arguments.carbon:[[@LINE+3]]:38-40: error: too many template arguments for class template 'TwoTypes' [CppInteropParseError]
// CHECK:STDERR: ./templates.h:5:41: note: template is declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_too_many_arguments.carbon:[[@LINE+14]]:38
// CHECK:STDERR: -> │ var x: Cpp.TwoTypes(Cpp.A, Cpp.A, Cpp.A);
// CHECK:STDERR: · ┳━━
// CHECK:STDERR: · ┗━━┫ error: too many template arguments for
// CHECK:STDERR: · ┃ class template 'TwoTypes'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./templates.h
// CHECK:STDERR: │ template<typename T, typename U> struct TwoTypes {};
// CHECK:STDERR: · ──────────────────────────────── ┬
// CHECK:STDERR: · ╰──┤ template is declared here
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoTypes(Cpp.A, Cpp.A, Cpp.A);
@@ -88,13 +110,39 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_fixed_size_pack_wrong_size.carbon:[[@LINE+3]]:57: error: too few template arguments for class template 'Inner' [CppInteropParseError]
// CHECK:STDERR: ./templates.h:15:33: note: template is declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_fixed_size_pack_wrong_size.carbon:[[@LINE+18]]:57
// CHECK:STDERR: -> │ var too_few: Cpp.FixedSizePack(Cpp.A, Cpp.A).Inner(Cpp.B);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: too few
// CHECK:STDERR: · ┃ template
// CHECK:STDERR: · ┃ arguments
// CHECK:STDERR: · ┃ for class
// CHECK:STDERR: · ┃ template
// CHECK:STDERR: · ┃ 'Inner'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./templates.h
// CHECK:STDERR: │ template<True<T> ...U> struct Inner {};
// CHECK:STDERR: · ────────────────────── ┬
// CHECK:STDERR: · ╰──┤ template is declared here
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var too_few: Cpp.FixedSizePack(Cpp.A, Cpp.A).Inner(Cpp.B);
// CHECK:STDERR: fail_fixed_size_pack_wrong_size.carbon:[[@LINE+3]]:70-72: error: too many template arguments for class template 'Inner' [CppInteropParseError]
// CHECK:STDERR: ./templates.h:15:33: note: template is declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_fixed_size_pack_wrong_size.carbon:[[@LINE+14]]:70
// CHECK:STDERR: -> │ var too_many: Cpp.FixedSizePack(Cpp.A, Cpp.A).Inner(Cpp.B, Cpp.B, Cpp.B);
// CHECK:STDERR: · ━┳━
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: too many template arguments for class template 'Inner'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./templates.h
// CHECK:STDERR: │ template<True<T> ...U> struct Inner {};
// CHECK:STDERR: · ────────────────────── ┬
// CHECK:STDERR: · ╰──┤ template is declared here
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var too_many: Cpp.FixedSizePack(Cpp.A, Cpp.A).Inner(Cpp.B, Cpp.B, Cpp.B);
@@ -23,7 +23,13 @@ fn CarbonSide[template T: type](p: T) -> T;
inline Cpp '''c++
template<typename T>
// CHECK:STDERR: fail_todo_bidirectional_intorp_too_deep.carbon:[[@LINE+2]]:6: error: semantics TODO: `maximum depth for bidirectional Carbon/C++ interop is 10` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_todo_bidirectional_intorp_too_deep.carbon:[[@LINE+8]]:6
// CHECK:STDERR: -> │ auto AddTypeWrapper(T x) -> T {
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: semantics TODO:
// CHECK:STDERR: · ┃ `maximum depth for bidirectional Carbon/C++ interop is 10`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
auto AddTypeWrapper(T x) -> T {
// Calls into to Carbon, adding a layer of Wrap(...) to the type T that
@@ -41,8 +41,16 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_int_param_mismatch.carbon:[[@LINE+3]]:1-22: error: cannot implicitly convert expression of type `Cpp.Simple` to `Cpp.Simple` [ConversionFailure]
// CHECK:STDERR: fail_int_param_mismatch.carbon:[[@LINE+2]]:1-22: note: type `Cpp.Simple` does not implement interface `Core.ImplicitAs(Cpp.Simple)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_int_param_mismatch.carbon:[[@LINE+11]]:1
// CHECK:STDERR: -> │ var s: Cpp.Simple(456) = Cpp.MakeSimple123();
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `Cpp.Simple` to
// CHECK:STDERR: · │ ┃ `Cpp.Simple`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `Cpp.Simple` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.Simple)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var s: Cpp.Simple(456) = Cpp.MakeSimple123();
@@ -135,8 +143,16 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_type_argument.carbon:[[@LINE+3]]:26-30: error: cannot implicitly convert expression of type `type` to `i32` [ConversionFailure]
// CHECK:STDERR: fail_type_argument.carbon:[[@LINE+2]]:26-30: note: type `type` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_type_argument.carbon:[[@LINE+11]]:26
// CHECK:STDERR: -> │ var x: Cpp.TwoNonType(1, Cpp.A) = {};
// CHECK:STDERR: · ┳━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of
// CHECK:STDERR: · │ ┃ type `type` to `i32`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `type` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(i32)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoNonType(1, Cpp.A) = {};
@@ -148,8 +164,16 @@ import Cpp library "templates.h";
var n: i32;
// CHECK:STDERR: fail_no_conversion.carbon:[[@LINE+3]]:26-27: error: cannot implicitly convert expression of type `i32*` to `i32` [ConversionFailure]
// CHECK:STDERR: fail_no_conversion.carbon:[[@LINE+2]]:26-27: note: type `i32*` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_no_conversion.carbon:[[@LINE+11]]:26
// CHECK:STDERR: -> │ var x: Cpp.TwoNonType(1, &n) = {};
// CHECK:STDERR: · ┳━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of
// CHECK:STDERR: · │ ┃ type `i32*` to `i32`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `i32*` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(i32)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoNonType(1, &n) = {};
@@ -36,10 +36,33 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
//@dump-sem-ir-begin
// CHECK:STDERR: fail_template_mismatch.carbon:[[@LINE+5]]:35: error: too few template arguments for class template 'C' [CppInteropParseError]
// CHECK:STDERR: fail_template_mismatch.carbon:[[@LINE+4]]:35: note: template template argument has different template parameters than its corresponding template template parameter [CppInteropParseNote]
// CHECK:STDERR: ./templates.h:6:66: note: previous template template parameter is here [CppInteropParseNote]
// CHECK:STDERR: ./templates.h:4:37: note: template is declared here [CppInteropParseNote]
// CHECK:STDERR: ╭─┤ fail_template_mismatch.carbon:[[@LINE+28]]:35
// CHECK:STDERR: -> │ var x: Cpp.TwoTemplates(Cpp.A, Cpp.C);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: too few template arguments for
// CHECK:STDERR: · │ ┃ class template 'C'
// CHECK:STDERR: · │ ┃ [CppInteropParseError]
// CHECK:STDERR: · ╰────┤ template template argument has
// CHECK:STDERR: · │ different template parameters than its
// CHECK:STDERR: · │ corresponding template template
// CHECK:STDERR: · │ parameter
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./templates.h
// CHECK:STDERR: │ template<typename, typename> struct C {};
// CHECK:STDERR: · ──────────────────────────── ┬
// CHECK:STDERR: · ╰──┤ template is declared here
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: │
// CHECK:STDERR: │ template<template<typename> typename, template<typename> typename>
// CHECK:STDERR: · ────────────────── ┬
// CHECK:STDERR: · ╰──┤ previous
// CHECK:STDERR: · │ template
// CHECK:STDERR: · │ template
// CHECK:STDERR: · │ parameter
// CHECK:STDERR: · │ is here
// CHECK:STDERR: · │ [CppInteropParseNote]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoTemplates(Cpp.A, Cpp.C);
//@dump-sem-ir-end
@@ -52,7 +75,14 @@ import Cpp library "templates.h";
class X {}
// CHECK:STDERR: fail_type_argument.carbon:[[@LINE+2]]:32: error: template argument for template template parameter must be a class template or type alias template [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_type_argument.carbon:[[@LINE+9]]:32
// CHECK:STDERR: -> │ var x: Cpp.TwoTemplates(Cpp.A, X);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: template argument for template
// CHECK:STDERR: · ┃ template parameter must be a class
// CHECK:STDERR: · ┃ template or type alias template
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoTemplates(Cpp.A, X);
@@ -62,7 +92,14 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_non_type_argument.carbon:[[@LINE+2]]:32: error: template argument for template template parameter must be a class template or type alias template [CppInteropParseError]
// CHECK:STDERR: ╭─┤ fail_non_type_argument.carbon:[[@LINE+9]]:32
// CHECK:STDERR: -> │ var x: Cpp.TwoTemplates(Cpp.A, true);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: template argument for template
// CHECK:STDERR: · ┃ template parameter must be a class
// CHECK:STDERR: · ┃ template or type alias template
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoTemplates(Cpp.A, true);
@@ -43,8 +43,16 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_non_type_argument.carbon:[[@LINE+3]]:28-31: error: cannot implicitly convert non-type value of type `bool` to `type` [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: fail_non_type_argument.carbon:[[@LINE+2]]:28-31: note: type `bool` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╭─┤ fail_non_type_argument.carbon:[[@LINE+11]]:28
// CHECK:STDERR: -> │ var x: Cpp.TwoTypes(Cpp.A, true);
// CHECK:STDERR: · ┳━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert non-type value
// CHECK:STDERR: · │ ┃ of type `bool` to `type`
// CHECK:STDERR: · │ ┃ [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: · ╰────┤ type `bool` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(type)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoTypes(Cpp.A, true);
@@ -54,7 +62,13 @@ library "[[@TEST_NAME]]";
import Cpp library "templates.h";
// CHECK:STDERR: fail_unsupported_type.carbon:[[@LINE+2]]:28-29: error: semantics TODO: `unsupported type used as template argument` [SemanticsTodo]
// CHECK:STDERR: ╭─┤ fail_unsupported_type.carbon:[[@LINE+8]]:28
// CHECK:STDERR: -> │ var x: Cpp.TwoTypes(Cpp.A, {});
// CHECK:STDERR: · ━┳
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: semantics TODO: `unsupported type used as template argument`
// CHECK:STDERR: · ┃ [SemanticsTodo]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
var x: Cpp.TwoTypes(Cpp.A, {});