diff --git a/toolchain/check/testdata/builtins/char_literal/convert_char.carbon b/toolchain/check/testdata/builtins/char_literal/convert_char.carbon index 09ef3df465e7..260baa8425bc 100644 --- a/toolchain/check/testdata/builtins/char_literal/convert_char.carbon +++ b/toolchain/check/testdata/builtins/char_literal/convert_char.carbon @@ -44,8 +44,7 @@ library "[[@TEST_NAME]]"; import library "builtin"; let c: CharLiteral = 'a'; -// CHECK:STDERR: fail_runtime_call.carbon:[[@LINE+4]]:18-26: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] -// CHECK:STDERR: imported from: fail_runtime_call.carbon:[[@LINE-4]]:1 [InImport] +// CHECK:STDERR: fail_runtime_call.carbon:[[@LINE+3]]:18-26: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] // CHECK:STDERR: builtin.carbon:10:1-38: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: let d: UInt(8) = ToChar(c); diff --git a/toolchain/check/testdata/builtins/float/convert_checked.carbon b/toolchain/check/testdata/builtins/float/convert_checked.carbon index 9543097117a8..e06a990cf78f 100644 --- a/toolchain/check/testdata/builtins/float/convert_checked.carbon +++ b/toolchain/check/testdata/builtins/float/convert_checked.carbon @@ -138,8 +138,7 @@ import library "f64"; //@dump-sem-ir-begin let not_constant_64: f64 = 0.0; -// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+4]]:33-65: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] -// CHECK:STDERR: imported from: fail_not_constant.carbon:[[@LINE-5]]:1 [InImport] +// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:33-65: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] // CHECK:STDERR: f64.carbon:5:1-36: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); @@ -790,10 +789,10 @@ let convert_not_constant: f64 = Float64ToFloat64(not_constant_64); // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %not_constant_64.patt: %pattern_type.667 = value_binding_pattern not_constant_64 [concrete = constants.%not_constant_64.patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc11_65.1: %f64.761 = value_of_initializer @__global_init.%Float64ToFloat64.call -// CHECK:STDOUT: %.loc11_65.2: %f64.761 = converted @__global_init.%Float64ToFloat64.call, %.loc11_65.1 -// CHECK:STDOUT: %f64.loc11: type = type_literal constants.%f64.761 [concrete = constants.%f64.761] -// CHECK:STDOUT: %convert_not_constant: %f64.761 = wrapper_binding convert_not_constant, %.loc11_65.2 +// CHECK:STDOUT: %.loc10_65.1: %f64.761 = value_of_initializer @__global_init.%Float64ToFloat64.call +// CHECK:STDOUT: %.loc10_65.2: %f64.761 = converted @__global_init.%Float64ToFloat64.call, %.loc10_65.1 +// CHECK:STDOUT: %f64.loc10: type = type_literal constants.%f64.761 [concrete = constants.%f64.761] +// CHECK:STDOUT: %convert_not_constant: %f64.761 = wrapper_binding convert_not_constant, %.loc10_65.2 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %convert_not_constant.patt: %pattern_type.667 = value_binding_pattern convert_not_constant [concrete = constants.%convert_not_constant.patt] // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/builtins/int/convert.carbon b/toolchain/check/testdata/builtins/int/convert.carbon index 5dee1402ee2f..960131d2f452 100644 --- a/toolchain/check/testdata/builtins/int/convert.carbon +++ b/toolchain/check/testdata/builtins/int/convert.carbon @@ -241,8 +241,7 @@ import library "int_ops"; let not_constant: Core.IntLiteral = 0; -// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+4]]:33-63: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] -// CHECK:STDERR: imported from: fail_not_constant.carbon:[[@LINE-5]]:1 [InImport] +// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:33-63: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] // CHECK:STDERR: int_ops.carbon:16:1-49: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: let convert_not_constant: i16 = IntLiteralToInt16(not_constant); diff --git a/toolchain/check/testdata/builtins/int/convert_checked.carbon b/toolchain/check/testdata/builtins/int/convert_checked.carbon index 60c26695fcd2..752e69c3853e 100644 --- a/toolchain/check/testdata/builtins/int/convert_checked.carbon +++ b/toolchain/check/testdata/builtins/int/convert_checked.carbon @@ -215,20 +215,17 @@ import library "int_ops"; let not_constant: i32 = 0; -// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+4]]:40-65: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] -// CHECK:STDERR: imported from: fail_not_constant.carbon:[[@LINE-5]]:1 [InImport] +// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:40-65: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] // CHECK:STDERR: int_ops.carbon:19:1-32: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: let convert_not_constant_narrow: i16 = Int32ToInt16(not_constant); -// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+4]]:38-63: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] -// CHECK:STDERR: imported from: fail_not_constant.carbon:[[@LINE-11]]:1 [InImport] +// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:38-63: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] // CHECK:STDERR: int_ops.carbon:11:1-32: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: let convert_not_constant_same: i32 = Int32ToInt32(not_constant); -// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+4]]:39-64: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] -// CHECK:STDERR: imported from: fail_not_constant.carbon:[[@LINE-17]]:1 [InImport] +// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:39-64: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] // CHECK:STDERR: int_ops.carbon:27:1-32: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: let convert_not_constant_widen: i64 = Int32ToInt64(not_constant); diff --git a/toolchain/check/testdata/class/cross_package_import.carbon b/toolchain/check/testdata/class/cross_package_import.carbon index 250181388c22..8d49be292591 100644 --- a/toolchain/check/testdata/class/cross_package_import.carbon +++ b/toolchain/check/testdata/class/cross_package_import.carbon @@ -62,9 +62,8 @@ var c: Other.C = {}; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_todo_merge_define_extern.carbon:[[@LINE+4]]:1 [InImport] +// CHECK:STDERR: imported from: fail_todo_merge_define_extern.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: other_extern.carbon:4:1-15: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_todo_merge_define_extern.carbon:[[@LINE+2]]:1 [InImport] // CHECK:STDERR: other_define.carbon:4:1-9: note: name is previously declared here [NameDeclPrevious] import Other library "other_define"; import Other library "other_extern"; @@ -77,9 +76,8 @@ var c: Other.C = {}; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+4]]:1 [InImport] +// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: other_conflict.carbon:4:1-8: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+2]]:1 [InImport] // CHECK:STDERR: other_define.carbon:4:1-9: note: name is previously declared here [NameDeclPrevious] import Other library "other_define"; import Other library "other_conflict"; @@ -327,7 +325,7 @@ var c: Other.C = {}; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other // CHECK:STDOUT: %c.var: ref %C = var_storage %c.var_patt [concrete] -// CHECK:STDOUT: %.loc13: type = splice_block %C.ref [concrete = constants.%C] { +// CHECK:STDOUT: %.loc12: type = splice_block %C.ref [concrete = constants.%C] { // CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [concrete = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C] // CHECK:STDOUT: } @@ -347,10 +345,10 @@ var c: Other.C = {}; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc13_19.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] -// CHECK:STDOUT: %.loc13_19.2: init %C to file.%c.var = class_init () [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc13_1: init %C = converted %.loc13_19.1, %.loc13_19.2 [concrete = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc13_1 +// CHECK:STDOUT: %.loc12_19.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] +// CHECK:STDOUT: %.loc12_19.2: init %C to file.%c.var = class_init () [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc12_1: init %C = converted %.loc12_19.1, %.loc12_19.2 [concrete = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -392,7 +390,7 @@ var c: Other.C = {}; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Other.import = import Other // CHECK:STDOUT: %c.var: ref %C = var_storage %c.var_patt [concrete] -// CHECK:STDOUT: %.loc13: type = splice_block %C.ref [concrete = constants.%C] { +// CHECK:STDOUT: %.loc12: type = splice_block %C.ref [concrete = constants.%C] { // CHECK:STDOUT: %Other.ref: = name_ref Other, imports.%Other [concrete = imports.%Other] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C] // CHECK:STDOUT: } @@ -412,10 +410,10 @@ var c: Other.C = {}; // CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc13_19.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] -// CHECK:STDOUT: %.loc13_19.2: init %C to file.%c.var = class_init () [concrete = constants.%C.val] -// CHECK:STDOUT: %.loc13_1: init %C = converted %.loc13_19.1, %.loc13_19.2 [concrete = constants.%C.val] -// CHECK:STDOUT: assign file.%c.var, %.loc13_1 +// CHECK:STDOUT: %.loc12_19.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] +// CHECK:STDOUT: %.loc12_19.2: init %C to file.%c.var = class_init () [concrete = constants.%C.val] +// CHECK:STDOUT: %.loc12_1: init %C = converted %.loc12_19.1, %.loc12_19.2 [concrete = constants.%C.val] +// CHECK:STDOUT: assign file.%c.var, %.loc12_1 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/extern.carbon b/toolchain/check/testdata/class/extern.carbon index a0847b23fd93..39e7ca8d6f16 100644 --- a/toolchain/check/testdata/class/extern.carbon +++ b/toolchain/check/testdata/class/extern.carbon @@ -114,9 +114,8 @@ extern class C; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_import_extern_decl_then_decl.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_import_extern_decl_then_decl.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: decl.carbon:4:1-8: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_import_extern_decl_then_decl.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: extern_decl.carbon:4:1-15: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "extern_decl"; @@ -126,9 +125,8 @@ import library "decl"; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_import_decl_then_extern_decl.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_import_decl_then_extern_decl.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: extern_decl.carbon:4:1-15: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_import_decl_then_extern_decl.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: decl.carbon:4:1-8: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "decl"; @@ -138,9 +136,8 @@ import library "extern_decl"; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_import_extern_decl_then_def.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_import_extern_decl_then_def.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: def.carbon:4:1-9: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_import_extern_decl_then_def.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: extern_decl.carbon:4:1-15: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "extern_decl"; @@ -150,14 +147,12 @@ import library "def"; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_import_ownership_conflict.carbon:[[@LINE+10]]:1 [InImport] -// CHECK:STDERR: decl.carbon:4:1-8: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: imported from: fail_import_ownership_conflict.carbon:[[@LINE+8]]:1 [InImport] +// CHECK:STDERR: decl.carbon:4:1-8: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: extern_decl.carbon:4:1-15: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_import_ownership_conflict.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_import_ownership_conflict.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: def.carbon:4:1-9: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_import_ownership_conflict.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: extern_decl.carbon:4:1-15: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "extern_decl"; @@ -168,9 +163,8 @@ import library "def"; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_todo_import_extern_decl_copy.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_todo_import_extern_decl_copy.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: extern_decl_copy.carbon:4:1-15: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_todo_import_extern_decl_copy.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: extern_decl.carbon:4:1-15: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "extern_decl"; @@ -182,8 +176,7 @@ library "[[@TEST_NAME]]"; import library "extern_decl"; -// CHECK:STDERR: fail_extern_decl_after_import_extern_decl.carbon:[[@LINE+4]]:1-15: error: redeclaration of `class C` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_extern_decl_after_import_extern_decl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_decl_after_import_extern_decl.carbon:[[@LINE+3]]:1-15: error: redeclaration of `class C` is redundant [RedeclRedundant] // CHECK:STDERR: extern_decl.carbon:4:1-15: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern class C; @@ -194,8 +187,7 @@ library "[[@TEST_NAME]]"; import library "decl"; -// CHECK:STDERR: fail_decl_after_import_extern_decl.carbon:[[@LINE+4]]:1-15: error: redeclarations of `class C` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_decl_after_import_extern_decl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_decl_after_import_extern_decl.carbon:[[@LINE+3]]:1-15: error: redeclarations of `class C` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: decl.carbon:4:1-8: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern class C; @@ -206,8 +198,7 @@ library "[[@TEST_NAME]]"; import library "def"; -// CHECK:STDERR: fail_def_after_import_extern_decl.carbon:[[@LINE+4]]:1-15: error: redeclarations of `class C` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_def_after_import_extern_decl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_def_after_import_extern_decl.carbon:[[@LINE+3]]:1-15: error: redeclarations of `class C` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: def.carbon:4:1-9: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern class C; @@ -218,8 +209,7 @@ library "[[@TEST_NAME]]"; import library "def"; -// CHECK:STDERR: fail_extern_decl_after_import_def.carbon:[[@LINE+4]]:1-15: error: redeclarations of `class C` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_extern_decl_after_import_def.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_decl_after_import_def.carbon:[[@LINE+3]]:1-15: error: redeclarations of `class C` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: def.carbon:4:1-9: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern class C; diff --git a/toolchain/check/testdata/class/fail_import_misuses.carbon b/toolchain/check/testdata/class/fail_import_misuses.carbon index 16366a4147de..d8bcfe8db7e5 100644 --- a/toolchain/check/testdata/class/fail_import_misuses.carbon +++ b/toolchain/check/testdata/class/fail_import_misuses.carbon @@ -25,15 +25,14 @@ library "[[@TEST_NAME]]"; import library "a"; -// CHECK:STDERR: fail_b.carbon:[[@LINE+4]]:1-13: error: redeclaration of `class Empty` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_b.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_b.carbon:[[@LINE+3]]:1-13: error: redeclaration of `class Empty` is redundant [RedeclRedundant] // CHECK:STDERR: a.carbon:4:1-13: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: class Empty { } // CHECK:STDERR: fail_b.carbon:[[@LINE+4]]:8-17: error: binding pattern has incomplete type `Incomplete` in name binding declaration [IncompleteTypeInBindingDecl] -// CHECK:STDERR: imported from: fail_b.carbon:[[@LINE-10]]:1 [InImport] +// CHECK:STDERR: imported from: fail_b.carbon:[[@LINE-9]]:1 [InImport] // CHECK:STDERR: a.carbon:7:1-17: note: class was forward declared here [ClassForwardDeclaredHere] // CHECK:STDERR: var a: Incomplete; diff --git a/toolchain/check/testdata/class/generic/import.carbon b/toolchain/check/testdata/class/generic/import.carbon index a4643f7547ef..27d55fa1e639 100644 --- a/toolchain/check/testdata/class/generic/import.carbon +++ b/toolchain/check/testdata/class/generic/import.carbon @@ -68,8 +68,7 @@ fn Use() { impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_foo.impl.carbon:[[@LINE+4]]:13-19: error: redeclaration differs at parameter 1 [RedeclParamDiffers] -// CHECK:STDERR: imported from: fail_foo.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_foo.impl.carbon:[[@LINE+3]]:13-19: error: redeclaration differs at parameter 1 [RedeclParamDiffers] // CHECK:STDERR: foo.carbon:4:13-19: note: previous declaration's corresponding parameter here [RedeclParamPrevious] // CHECK:STDERR: class Class(U: type) { @@ -982,9 +981,9 @@ class Class(U: type) { // CHECK:STDOUT: %Class.generic.d9d1e3.1: %Class.type.e90e5c.1 = struct_value () [concrete] // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic] // CHECK:STDOUT: %T.patt: %pattern_type.9a5 = symbolic_binding_pattern T, 0 [symbolic] -// CHECK:STDOUT: %Class.type.e90e5c.2: type = parameterized_class_name_type @Class.loc8 [concrete] +// CHECK:STDOUT: %Class.type.e90e5c.2: type = parameterized_class_name_type @Class.loc7 [concrete] // CHECK:STDOUT: %Class.generic.d9d1e3.2: %Class.type.e90e5c.2 = struct_value () [concrete] -// CHECK:STDOUT: %Class.d9697b.2: type = class_type @Class.loc8, @Class.loc8(%U) [symbolic] +// CHECK:STDOUT: %Class.d9697b.2: type = class_type @Class.loc7, @Class.loc7(%U) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -1009,14 +1008,14 @@ class Class(U: type) { // CHECK:STDOUT: %default.import.loc2_19.1 = import // CHECK:STDOUT: %default.import.loc2_19.2 = import // CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Class.decl: %Class.type.e90e5c.2 = class_decl @Class.loc8 [concrete = constants.%Class.generic.d9d1e3.2] { -// CHECK:STDOUT: %U.patt.loc8_14.1: %pattern_type.9a5 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_14.2 (constants.%U.patt)] +// CHECK:STDOUT: %Class.decl: %Class.type.e90e5c.2 = class_decl @Class.loc7 [concrete = constants.%Class.generic.d9d1e3.2] { +// CHECK:STDOUT: %U.patt.loc7_14.1: %pattern_type.9a5 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc7_14.2 (constants.%U.patt)] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc8_16.1: type = splice_block %.loc8_16.2 [concrete = type] { +// CHECK:STDOUT: %.loc7_16.1: type = splice_block %.loc7_16.2 [concrete = type] { // CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen] -// CHECK:STDOUT: %.loc8_16.2: type = type_literal type [concrete = type] +// CHECK:STDOUT: %.loc7_16.2: type = type_literal type [concrete = type] // CHECK:STDOUT: } -// CHECK:STDOUT: %U.loc8_14.2: type = symbolic_binding U, 0 [symbolic = %U.loc8_14.1 (constants.%U)] +// CHECK:STDOUT: %U.loc7_14.2: type = symbolic_binding U, 0 [symbolic = %U.loc7_14.1 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1027,9 +1026,9 @@ class Class(U: type) { // CHECK:STDOUT: class; // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic class @Class.loc8(%U.loc8_14.2: type) { -// CHECK:STDOUT: %U.patt.loc8_14.2: %pattern_type.9a5 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_14.2 (constants.%U.patt)] -// CHECK:STDOUT: %U.loc8_14.1: type = symbolic_binding U, 0 [symbolic = %U.loc8_14.1 (constants.%U)] +// CHECK:STDOUT: generic class @Class.loc7(%U.loc7_14.2: type) { +// CHECK:STDOUT: %U.patt.loc7_14.2: %pattern_type.9a5 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc7_14.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.loc7_14.1: type = symbolic_binding U, 0 [symbolic = %U.loc7_14.1 (constants.%U)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: @@ -1052,8 +1051,8 @@ class Class(U: type) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Class.loc8(constants.%U) { -// CHECK:STDOUT: %U.patt.loc8_14.2 => constants.%U.patt -// CHECK:STDOUT: %U.loc8_14.1 => constants.%U +// CHECK:STDOUT: specific @Class.loc7(constants.%U) { +// CHECK:STDOUT: %U.patt.loc7_14.2 => constants.%U.patt +// CHECK:STDOUT: %U.loc7_14.1 => constants.%U // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/implicit_import.carbon b/toolchain/check/testdata/class/implicit_import.carbon index 980f84c62011..fe59b75f3471 100644 --- a/toolchain/check/testdata/class/implicit_import.carbon +++ b/toolchain/check/testdata/class/implicit_import.carbon @@ -34,8 +34,7 @@ class C {} impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+4]]:1-8: error: redeclaration of `class C` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_redecl_after_def.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+3]]:1-8: error: redeclaration of `class C` is redundant [RedeclRedundant] // CHECK:STDERR: redecl_after_def.carbon:4:1-9: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: class C; @@ -50,8 +49,7 @@ class C {} impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+4]]:1-9: error: redefinition of `class C` [RedeclRedef] -// CHECK:STDERR: imported from: fail_redef_after_def.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+3]]:1-9: error: redefinition of `class C` [RedeclRedef] // CHECK:STDERR: redef_after_def.carbon:4:1-9: note: previously defined here [RedeclPrevDef] // CHECK:STDERR: class C {} @@ -67,8 +65,7 @@ alias B = C; impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+4]]:7: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_def_alias.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+3]]:7: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: def_alias.carbon:5:7: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: class B {} @@ -200,7 +197,7 @@ class B {} // CHECK:STDOUT: %C.08d9e3.1: type = class_type @C.1 [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %C.08d9e3.2: type = class_type @C.loc8 [concrete] +// CHECK:STDOUT: %C.08d9e3.2: type = class_type @C.loc7 [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -215,7 +212,7 @@ class B {} // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_31.1 = import // CHECK:STDOUT: %default.import.loc2_31.2 = import -// CHECK:STDOUT: %C.decl: type = class_decl @C.loc8 [concrete = constants.%C.08d9e3.2] {} {} +// CHECK:STDOUT: %C.decl: type = class_decl @C.loc7 [concrete = constants.%C.08d9e3.2] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C.1 [from "redef_after_def.carbon"] { @@ -225,7 +222,7 @@ class B {} // CHECK:STDOUT: .Self = imports.%Main.import_ref.e47 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @C.loc8 { +// CHECK:STDOUT: class @C.loc7 { // CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/no_definition_in_impl_file.carbon b/toolchain/check/testdata/class/no_definition_in_impl_file.carbon index 641a2375572a..935f0ec4284f 100644 --- a/toolchain/check/testdata/class/no_definition_in_impl_file.carbon +++ b/toolchain/check/testdata/class/no_definition_in_impl_file.carbon @@ -52,8 +52,7 @@ class C; impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+6]]:1-8: error: redeclaration of `class C` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+5]]:1-8: error: redeclaration of `class C` is redundant [RedeclRedundant] // CHECK:STDERR: decl_in_api_decl_in_impl.carbon:4:1-8: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: // CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+2]]:1-8: error: no definition found for declaration in impl file [MissingDefinitionInImpl] @@ -70,8 +69,7 @@ class D; impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE+4]]:1-8: error: redeclaration of `class D` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE+3]]:1-8: error: redeclaration of `class D` is redundant [RedeclRedundant] // CHECK:STDERR: decl_in_api_decl_and_definition_in_impl.carbon:4:1-8: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: class D; diff --git a/toolchain/check/testdata/function/declaration/extern.carbon b/toolchain/check/testdata/function/declaration/extern.carbon index bf0a5368e218..977153b9224b 100644 --- a/toolchain/check/testdata/function/declaration/extern.carbon +++ b/toolchain/check/testdata/function/declaration/extern.carbon @@ -63,8 +63,7 @@ library "[[@TEST_NAME]]"; import library "basic"; -// CHECK:STDERR: fail_extern_library_in_importer.carbon:[[@LINE+4]]:1-30: error: cannot declare imported `fn F` as `extern library` [ExternLibraryInImporter] -// CHECK:STDERR: imported from: fail_extern_library_in_importer.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_library_in_importer.carbon:[[@LINE+3]]:1-30: error: cannot declare imported `fn F` as `extern library` [ExternLibraryInImporter] // CHECK:STDERR: basic.carbon:4:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern library "basic" fn F(); diff --git a/toolchain/check/testdata/function/declaration/extern_library.carbon b/toolchain/check/testdata/function/declaration/extern_library.carbon index ab1de916fab7..3e7e445ad023 100644 --- a/toolchain/check/testdata/function/declaration/extern_library.carbon +++ b/toolchain/check/testdata/function/declaration/extern_library.carbon @@ -32,8 +32,7 @@ library "[[@TEST_NAME]]"; import library "extern_library"; -// CHECK:STDERR: fail_extern_library_nonowner.carbon:[[@LINE+4]]:1-14: error: declaration in library "extern_library_nonowner" doesn't match `extern library` declaration [ExternLibraryIncorrect] -// CHECK:STDERR: imported from: fail_extern_library_nonowner.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_library_nonowner.carbon:[[@LINE+3]]:1-14: error: declaration in library "extern_library_nonowner" doesn't match `extern library` declaration [ExternLibraryIncorrect] // CHECK:STDERR: extern_library.carbon:4:1-45: note: previously declared with `extern library` here [ExternLibraryExpected] // CHECK:STDERR: extern fn F(); @@ -44,8 +43,7 @@ library "[[@TEST_NAME]]"; import library "extern_library"; -// CHECK:STDERR: fail_extern_library_nonextern.carbon:[[@LINE+4]]:1-7: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_extern_library_nonextern.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_library_nonextern.carbon:[[@LINE+3]]:1-7: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern_library.carbon:4:1-45: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn F(); @@ -56,8 +54,7 @@ library "[[@TEST_NAME]]"; import library "extern_library"; -// CHECK:STDERR: fail_extern_library_redecl.carbon:[[@LINE+4]]:1-45: error: declaration in library "extern_library_redecl" doesn't match `extern library` declaration [ExternLibraryIncorrect] -// CHECK:STDERR: imported from: fail_extern_library_redecl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_library_redecl.carbon:[[@LINE+3]]:1-45: error: declaration in library "extern_library_redecl" doesn't match `extern library` declaration [ExternLibraryIncorrect] // CHECK:STDERR: extern_library.carbon:4:1-45: note: previously declared with `extern library` here [ExternLibraryExpected] // CHECK:STDERR: extern library "extern_library_owner" fn F(); @@ -72,9 +69,8 @@ extern library "extern_library_owner" fn F(); library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_extern_library_collision.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_extern_library_collision.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: extern_library_copy.carbon:4:1-45: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_extern_library_collision.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: extern_library.carbon:4:1-45: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "extern_library"; @@ -118,8 +114,7 @@ library "[[@TEST_NAME]]"; import library "extern_of_import"; -// CHECK:STDERR: fail_extern_of_import_redecl.carbon:[[@LINE+4]]:1-41: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_extern_of_import_redecl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_of_import_redecl.carbon:[[@LINE+3]]:1-41: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern_of_import.carbon:4:1-7: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern library "extern_of_import" fn F(); diff --git a/toolchain/check/testdata/function/declaration/extern_library_for_default.carbon b/toolchain/check/testdata/function/declaration/extern_library_for_default.carbon index 5ef734a2ffef..cb3fa7092a5a 100644 --- a/toolchain/check/testdata/function/declaration/extern_library_for_default.carbon +++ b/toolchain/check/testdata/function/declaration/extern_library_for_default.carbon @@ -32,8 +32,7 @@ package Foo library "[[@TEST_NAME]]"; import library default; -// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+4]]:1-14: error: declaration in library "wrong_library" doesn't match `extern library` declaration [ExternLibraryIncorrect] -// CHECK:STDERR: imported from: fail_wrong_library.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+3]]:1-14: error: declaration in library "wrong_library" doesn't match `extern library` declaration [ExternLibraryIncorrect] // CHECK:STDERR: default.carbon:4:1-33: note: previously declared with `extern library` here [ExternLibraryExpected] // CHECK:STDERR: extern fn F(); diff --git a/toolchain/check/testdata/function/declaration/extern_library_from_default.carbon b/toolchain/check/testdata/function/declaration/extern_library_from_default.carbon index 4cd9323750c0..99bed74bb6c8 100644 --- a/toolchain/check/testdata/function/declaration/extern_library_from_default.carbon +++ b/toolchain/check/testdata/function/declaration/extern_library_from_default.carbon @@ -30,8 +30,7 @@ library "[[@TEST_NAME]]"; import library "extern_library"; -// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+4]]:1-14: error: declaration in library "wrong_library" doesn't match `extern library` declaration [ExternLibraryIncorrect] -// CHECK:STDERR: imported from: fail_wrong_library.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_wrong_library.carbon:[[@LINE+3]]:1-14: error: declaration in library "wrong_library" doesn't match `extern library` declaration [ExternLibraryIncorrect] // CHECK:STDERR: extern_library.carbon:4:1-30: note: previously declared with `extern library` here [ExternLibraryExpected] // CHECK:STDERR: extern fn F(); diff --git a/toolchain/check/testdata/function/declaration/implicit_import.carbon b/toolchain/check/testdata/function/declaration/implicit_import.carbon index 8d68f310d561..26fc0e09e679 100644 --- a/toolchain/check/testdata/function/declaration/implicit_import.carbon +++ b/toolchain/check/testdata/function/declaration/implicit_import.carbon @@ -34,8 +34,7 @@ extern fn A(); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+6]]:1-7: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_extern_api.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+5]]:1-7: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern_api.carbon:4:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: // CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+2]]:1-7: error: no definition found for declaration in impl file [MissingDefinitionInImpl] @@ -52,8 +51,7 @@ fn A(); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+4]]:1-14: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_extern_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+3]]:1-14: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern_impl.carbon:4:1-7: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn A(); diff --git a/toolchain/check/testdata/function/declaration/import.carbon b/toolchain/check/testdata/function/declaration/import.carbon index b3d8dd99e2f1..b917e18735a9 100644 --- a/toolchain/check/testdata/function/declaration/import.carbon +++ b/toolchain/check/testdata/function/declaration/import.carbon @@ -62,28 +62,23 @@ library "[[@TEST_NAME]]"; import library "api"; -// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+4]]:1-14: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_redecl_api.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+3]]:1-14: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: api.carbon:4:1-7: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn A(); -// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+4]]:1-27: error: redeclarations of `fn B` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_redecl_api.carbon:[[@LINE-8]]:1 [InImport] +// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+3]]:1-27: error: redeclarations of `fn B` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: api.carbon:5:1-20: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn B(b: i32) -> i32; -// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+4]]:1-36: error: redeclarations of `fn C` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_redecl_api.carbon:[[@LINE-13]]:1 [InImport] +// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+3]]:1-36: error: redeclarations of `fn C` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: api.carbon:6:1-29: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn C(c: (i32,)) -> {.c: i32}; -// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+4]]:1-14: error: redeclaration of `fn D` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_redecl_api.carbon:[[@LINE-18]]:1 [InImport] +// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+3]]:1-14: error: redeclaration of `fn D` is redundant [RedeclRedundant] // CHECK:STDERR: api.carbon:7:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn D(); -// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+4]]:1-17: error: redeclarations of `fn E` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_redecl_api.carbon:[[@LINE-23]]:1 [InImport] +// CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+3]]:1-17: error: redeclarations of `fn E` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: api.carbon:10:1-10: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn NS.E(); @@ -116,29 +111,24 @@ var e: () = NS.E(); library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+25]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+20]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:4:1-42: error: duplicate name `A` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+23]]:1 [InImport] // CHECK:STDERR: api.carbon:4:1-7: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+20]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+16]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:5:1-55: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+18]]:1 [InImport] // CHECK:STDERR: api.carbon:5:1-20: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+15]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+12]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:6:1-64: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+13]]:1 [InImport] // CHECK:STDERR: api.carbon:6:1-29: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+10]]:1 [InImport] -// CHECK:STDERR: extern_api.carbon:7:1-42: error: duplicate name `D` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+8]]:1 [InImport] +// CHECK:STDERR: extern_api.carbon:7:1-42: error: duplicate name `D` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: api.carbon:7:1-14: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:10:1-45: error: duplicate name `E` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: api.carbon:10:1-10: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "api"; @@ -154,29 +144,24 @@ var e: () = NS.E(); library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+25]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+20]]:1 [InImport] // CHECK:STDERR: api.carbon:4:1-7: error: duplicate name `A` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+23]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:4:1-42: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+20]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+16]]:1 [InImport] // CHECK:STDERR: api.carbon:5:1-20: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+18]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:5:1-55: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+15]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+12]]:1 [InImport] // CHECK:STDERR: api.carbon:6:1-29: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+13]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:6:1-64: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+10]]:1 [InImport] -// CHECK:STDERR: api.carbon:7:1-14: error: duplicate name `D` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+8]]:1 [InImport] +// CHECK:STDERR: api.carbon:7:1-14: error: duplicate name `D` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: extern_api.carbon:7:1-42: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: api.carbon:10:1-10: error: duplicate name `E` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_merge_reverse.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: extern_api.carbon:10:1-45: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "extern_api"; @@ -704,23 +689,23 @@ import library "extern_api"; // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {} {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [concrete = constants.%B] {} { -// CHECK:STDOUT: %i32.loc15_24: type = type_literal constants.%i32 [concrete = constants.%i32] -// CHECK:STDOUT: %.loc15: Core.Form = init_form %i32.loc15_24 [concrete = constants.%.0b3] +// CHECK:STDOUT: %i32.loc13_24: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc13: Core.Form = init_form %i32.loc13_24 [concrete = constants.%.0b3] // CHECK:STDOUT: %b.param: %i32 = value_param call_param0 -// CHECK:STDOUT: %i32.loc15_16: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %i32.loc13_16: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %b: %i32 = wrapper_binding b, %b.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [concrete = constants.%C] {} { -// CHECK:STDOUT: %i32.loc20_32: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %i32.loc17_32: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c] -// CHECK:STDOUT: %.loc20_35: Core.Form = init_form %struct_type.c [concrete = constants.%.fc2] +// CHECK:STDOUT: %.loc17_35: Core.Form = init_form %struct_type.c [concrete = constants.%.fc2] // CHECK:STDOUT: %c.param: %tuple.type.294 = value_param call_param0 -// CHECK:STDOUT: %.loc20_21.1: type = splice_block %.loc20_21.3 [concrete = constants.%tuple.type.294] { -// CHECK:STDOUT: %i32.loc20_17: type = type_literal constants.%i32 [concrete = constants.%i32] -// CHECK:STDOUT: %.loc20_21.2: %tuple.type.135 = tuple_literal (%i32.loc20_17) [concrete = constants.%tuple.f7a] -// CHECK:STDOUT: %.loc20_21.3: type = converted %.loc20_21.2, constants.%tuple.type.294 [concrete = constants.%tuple.type.294] +// CHECK:STDOUT: %.loc17_21.1: type = splice_block %.loc17_21.3 [concrete = constants.%tuple.type.294] { +// CHECK:STDOUT: %i32.loc17_17: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc17_21.2: %tuple.type.135 = tuple_literal (%i32.loc17_17) [concrete = constants.%tuple.f7a] +// CHECK:STDOUT: %.loc17_21.3: type = converted %.loc17_21.2, constants.%tuple.type.294 [concrete = constants.%tuple.type.294] // CHECK:STDOUT: } // CHECK:STDOUT: %c: %tuple.type.294 = wrapper_binding c, %c.param // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param call_param1 @@ -729,9 +714,9 @@ import library "extern_api"; // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [concrete = constants.%D] {} {} // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [concrete = constants.%E] {} {} // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var_storage %a.var_patt [concrete] -// CHECK:STDOUT: %.loc32_9.1: type = splice_block %.loc32_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc32_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc32_9.3: type = converted %.loc32_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc27_9.1: type = splice_block %.loc27_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc27_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc27_9.3: type = converted %.loc27_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = wrapper_binding a, %a.var [concrete = %a.var] // CHECK:STDOUT: name_binding_decl { @@ -739,15 +724,15 @@ import library "extern_api"; // CHECK:STDOUT: %a.var_patt: %pattern_type.cb1 = var_pattern %a.patt [concrete = constants.%a.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var_storage %b.var_patt [concrete] -// CHECK:STDOUT: %i32.loc33: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %i32.loc28: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %b: ref %i32 = wrapper_binding b, %b.var [concrete = %b.var] // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %b.patt: %pattern_type.d94 = ref_binding_pattern b [concrete = constants.%b.patt.920] // CHECK:STDOUT: %b.var_patt: %pattern_type.d94 = var_pattern %b.patt [concrete = constants.%b.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var_storage %c.var_patt [concrete] -// CHECK:STDOUT: %.loc34: type = splice_block %struct_type.c [concrete = constants.%struct_type.c] { -// CHECK:STDOUT: %i32.loc34: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc29: type = splice_block %struct_type.c [concrete = constants.%struct_type.c] { +// CHECK:STDOUT: %i32.loc29: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c] // CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = wrapper_binding c, %c.var [concrete = %c.var] @@ -756,9 +741,9 @@ import library "extern_api"; // CHECK:STDOUT: %c.var_patt: %pattern_type.51a = var_pattern %c.patt [concrete = constants.%c.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var_storage %d.var_patt [concrete] -// CHECK:STDOUT: %.loc35_9.1: type = splice_block %.loc35_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc35_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc35_9.3: type = converted %.loc35_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc30_9.1: type = splice_block %.loc30_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc30_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc30_9.3: type = converted %.loc30_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = wrapper_binding d, %d.var [concrete = %d.var] // CHECK:STDOUT: name_binding_decl { @@ -766,9 +751,9 @@ import library "extern_api"; // CHECK:STDOUT: %d.var_patt: %pattern_type.cb1 = var_pattern %d.patt [concrete = constants.%d.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var_storage %e.var_patt [concrete] -// CHECK:STDOUT: %.loc36_9.1: type = splice_block %.loc36_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc36_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc36_9.3: type = converted %.loc36_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc31_9.1: type = splice_block %.loc31_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc31_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc31_9.3: type = converted %.loc31_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = wrapper_binding e, %e.var [concrete = %e.var] // CHECK:STDOUT: name_binding_decl { @@ -793,29 +778,29 @@ import library "extern_api"; // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref() // CHECK:STDOUT: assign file.%a.var, %A.call // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [concrete = constants.%B] -// CHECK:STDOUT: %int_1.loc33: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc33: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] -// CHECK:STDOUT: %bound_method.loc33_16.1: = bound_method %int_1.loc33, %impl.elem0.loc33 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc33: = specific_function %impl.elem0.loc33, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc33_16.2: = bound_method %int_1.loc33, %specific_fn.loc33 [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc33: init %i32 = call %bound_method.loc33_16.2(%int_1.loc33) [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc33_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc33 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc33_16.2: %i32 = converted %int_1.loc33, %.loc33_16.1 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc33_16.2) +// CHECK:STDOUT: %int_1.loc28: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %impl.elem0.loc28: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] +// CHECK:STDOUT: %bound_method.loc28_16.1: = bound_method %int_1.loc28, %impl.elem0.loc28 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] +// CHECK:STDOUT: %specific_fn.loc28: = specific_function %impl.elem0.loc28, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc28_16.2: = bound_method %int_1.loc28, %specific_fn.loc28 [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28: init %i32 = call %bound_method.loc28_16.2(%int_1.loc28) [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc28_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc28_16.2: %i32 = converted %int_1.loc28, %.loc28_16.1 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc28_16.2) // CHECK:STDOUT: assign file.%b.var, %B.call // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %int_1.loc34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc34_25.1: %tuple.type.985 = tuple_literal (%int_1.loc34) [concrete = constants.%tuple.378] -// CHECK:STDOUT: %impl.elem0.loc34: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] -// CHECK:STDOUT: %bound_method.loc34_25.1: = bound_method %int_1.loc34, %impl.elem0.loc34 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc34: = specific_function %impl.elem0.loc34, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc34_25.2: = bound_method %int_1.loc34, %specific_fn.loc34 [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc34: init %i32 = call %bound_method.loc34_25.2(%int_1.loc34) [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc34_25.2: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc34 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc34_25.3: %i32 = converted %int_1.loc34, %.loc34_25.2 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %tuple: %tuple.type.294 = tuple_value (%.loc34_25.3) [concrete = constants.%tuple.f6b] -// CHECK:STDOUT: %.loc34_25.4: %tuple.type.294 = converted %.loc34_25.1, %tuple [concrete = constants.%tuple.f6b] -// CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc34_25.4) +// CHECK:STDOUT: %int_1.loc29: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc29_25.1: %tuple.type.985 = tuple_literal (%int_1.loc29) [concrete = constants.%tuple.378] +// CHECK:STDOUT: %impl.elem0.loc29: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] +// CHECK:STDOUT: %bound_method.loc29_25.1: = bound_method %int_1.loc29, %impl.elem0.loc29 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] +// CHECK:STDOUT: %specific_fn.loc29: = specific_function %impl.elem0.loc29, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc29_25.2: = bound_method %int_1.loc29, %specific_fn.loc29 [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc29: init %i32 = call %bound_method.loc29_25.2(%int_1.loc29) [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc29_25.2: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc29 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc29_25.3: %i32 = converted %int_1.loc29, %.loc29_25.2 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %tuple: %tuple.type.294 = tuple_value (%.loc29_25.3) [concrete = constants.%tuple.f6b] +// CHECK:STDOUT: %.loc29_25.4: %tuple.type.294 = converted %.loc29_25.1, %tuple [concrete = constants.%tuple.f6b] +// CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc29_25.4) // CHECK:STDOUT: assign file.%c.var, %C.call // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [concrete = constants.%D] // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref() @@ -1142,9 +1127,9 @@ import library "extern_api"; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var_storage %a.var_patt [concrete] -// CHECK:STDOUT: %.loc32_9.1: type = splice_block %.loc32_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc32_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc32_9.3: type = converted %.loc32_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc27_9.1: type = splice_block %.loc27_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc27_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc27_9.3: type = converted %.loc27_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = wrapper_binding a, %a.var [concrete = %a.var] // CHECK:STDOUT: name_binding_decl { @@ -1152,15 +1137,15 @@ import library "extern_api"; // CHECK:STDOUT: %a.var_patt: %pattern_type.cb1 = var_pattern %a.patt [concrete = constants.%a.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var_storage %b.var_patt [concrete] -// CHECK:STDOUT: %i32.loc33: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %i32.loc28: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %b: ref %i32 = wrapper_binding b, %b.var [concrete = %b.var] // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %b.patt: %pattern_type.d94 = ref_binding_pattern b [concrete = constants.%b.patt.920] // CHECK:STDOUT: %b.var_patt: %pattern_type.d94 = var_pattern %b.patt [concrete = constants.%b.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var_storage %c.var_patt [concrete] -// CHECK:STDOUT: %.loc34: type = splice_block %struct_type.c [concrete = constants.%struct_type.c] { -// CHECK:STDOUT: %i32.loc34: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc29: type = splice_block %struct_type.c [concrete = constants.%struct_type.c] { +// CHECK:STDOUT: %i32.loc29: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c] // CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = wrapper_binding c, %c.var [concrete = %c.var] @@ -1169,9 +1154,9 @@ import library "extern_api"; // CHECK:STDOUT: %c.var_patt: %pattern_type.51a = var_pattern %c.patt [concrete = constants.%c.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var_storage %d.var_patt [concrete] -// CHECK:STDOUT: %.loc35_9.1: type = splice_block %.loc35_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc35_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc35_9.3: type = converted %.loc35_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc30_9.1: type = splice_block %.loc30_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc30_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc30_9.3: type = converted %.loc30_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = wrapper_binding d, %d.var [concrete = %d.var] // CHECK:STDOUT: name_binding_decl { @@ -1179,9 +1164,9 @@ import library "extern_api"; // CHECK:STDOUT: %d.var_patt: %pattern_type.cb1 = var_pattern %d.patt [concrete = constants.%d.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var_storage %e.var_patt [concrete] -// CHECK:STDOUT: %.loc36_9.1: type = splice_block %.loc36_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc36_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc36_9.3: type = converted %.loc36_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc31_9.1: type = splice_block %.loc31_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc31_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc31_9.3: type = converted %.loc31_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = wrapper_binding e, %e.var [concrete = %e.var] // CHECK:STDOUT: name_binding_decl { @@ -1206,29 +1191,29 @@ import library "extern_api"; // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref() // CHECK:STDOUT: assign file.%a.var, %A.call // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%Main.B [concrete = constants.%B] -// CHECK:STDOUT: %int_1.loc33: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc33: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] -// CHECK:STDOUT: %bound_method.loc33_16.1: = bound_method %int_1.loc33, %impl.elem0.loc33 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc33: = specific_function %impl.elem0.loc33, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc33_16.2: = bound_method %int_1.loc33, %specific_fn.loc33 [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc33: init %i32 = call %bound_method.loc33_16.2(%int_1.loc33) [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc33_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc33 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc33_16.2: %i32 = converted %int_1.loc33, %.loc33_16.1 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc33_16.2) +// CHECK:STDOUT: %int_1.loc28: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %impl.elem0.loc28: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] +// CHECK:STDOUT: %bound_method.loc28_16.1: = bound_method %int_1.loc28, %impl.elem0.loc28 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] +// CHECK:STDOUT: %specific_fn.loc28: = specific_function %impl.elem0.loc28, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc28_16.2: = bound_method %int_1.loc28, %specific_fn.loc28 [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28: init %i32 = call %bound_method.loc28_16.2(%int_1.loc28) [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc28_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc28_16.2: %i32 = converted %int_1.loc28, %.loc28_16.1 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc28_16.2) // CHECK:STDOUT: assign file.%b.var, %B.call // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [concrete = constants.%C] -// CHECK:STDOUT: %int_1.loc34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc34_25.1: %tuple.type.985 = tuple_literal (%int_1.loc34) [concrete = constants.%tuple.378] -// CHECK:STDOUT: %impl.elem0.loc34: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] -// CHECK:STDOUT: %bound_method.loc34_25.1: = bound_method %int_1.loc34, %impl.elem0.loc34 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc34: = specific_function %impl.elem0.loc34, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc34_25.2: = bound_method %int_1.loc34, %specific_fn.loc34 [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc34: init %i32 = call %bound_method.loc34_25.2(%int_1.loc34) [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc34_25.2: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc34 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc34_25.3: %i32 = converted %int_1.loc34, %.loc34_25.2 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %tuple: %tuple.type.294 = tuple_value (%.loc34_25.3) [concrete = constants.%tuple.f6b] -// CHECK:STDOUT: %.loc34_25.4: %tuple.type.294 = converted %.loc34_25.1, %tuple [concrete = constants.%tuple.f6b] -// CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc34_25.4) +// CHECK:STDOUT: %int_1.loc29: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc29_25.1: %tuple.type.985 = tuple_literal (%int_1.loc29) [concrete = constants.%tuple.378] +// CHECK:STDOUT: %impl.elem0.loc29: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] +// CHECK:STDOUT: %bound_method.loc29_25.1: = bound_method %int_1.loc29, %impl.elem0.loc29 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] +// CHECK:STDOUT: %specific_fn.loc29: = specific_function %impl.elem0.loc29, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc29_25.2: = bound_method %int_1.loc29, %specific_fn.loc29 [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc29: init %i32 = call %bound_method.loc29_25.2(%int_1.loc29) [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc29_25.2: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc29 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc29_25.3: %i32 = converted %int_1.loc29, %.loc29_25.2 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %tuple: %tuple.type.294 = tuple_value (%.loc29_25.3) [concrete = constants.%tuple.f6b] +// CHECK:STDOUT: %.loc29_25.4: %tuple.type.294 = converted %.loc29_25.1, %tuple [concrete = constants.%tuple.f6b] +// CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc29_25.4) // CHECK:STDOUT: assign file.%c.var, %C.call // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%Main.D [concrete = constants.%D] // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref() @@ -1336,9 +1321,9 @@ import library "extern_api"; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var_storage %a.var_patt [concrete] -// CHECK:STDOUT: %.loc32_9.1: type = splice_block %.loc32_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc32_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc32_9.3: type = converted %.loc32_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc27_9.1: type = splice_block %.loc27_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc27_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc27_9.3: type = converted %.loc27_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %a: ref %empty_tuple.type = wrapper_binding a, %a.var [concrete = %a.var] // CHECK:STDOUT: name_binding_decl { @@ -1346,15 +1331,15 @@ import library "extern_api"; // CHECK:STDOUT: %a.var_patt: %pattern_type.cb1 = var_pattern %a.patt [concrete = constants.%a.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %b.var: ref %i32 = var_storage %b.var_patt [concrete] -// CHECK:STDOUT: %i32.loc33: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %i32.loc28: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %b: ref %i32 = wrapper_binding b, %b.var [concrete = %b.var] // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %b.patt: %pattern_type.d94 = ref_binding_pattern b [concrete = constants.%b.patt.920] // CHECK:STDOUT: %b.var_patt: %pattern_type.d94 = var_pattern %b.patt [concrete = constants.%b.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %c.var: ref %struct_type.c = var_storage %c.var_patt [concrete] -// CHECK:STDOUT: %.loc34: type = splice_block %struct_type.c [concrete = constants.%struct_type.c] { -// CHECK:STDOUT: %i32.loc34: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc29: type = splice_block %struct_type.c [concrete = constants.%struct_type.c] { +// CHECK:STDOUT: %i32.loc29: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [concrete = constants.%struct_type.c] // CHECK:STDOUT: } // CHECK:STDOUT: %c: ref %struct_type.c = wrapper_binding c, %c.var [concrete = %c.var] @@ -1363,9 +1348,9 @@ import library "extern_api"; // CHECK:STDOUT: %c.var_patt: %pattern_type.51a = var_pattern %c.patt [concrete = constants.%c.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var_storage %d.var_patt [concrete] -// CHECK:STDOUT: %.loc35_9.1: type = splice_block %.loc35_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc35_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc35_9.3: type = converted %.loc35_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc30_9.1: type = splice_block %.loc30_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc30_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc30_9.3: type = converted %.loc30_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %d: ref %empty_tuple.type = wrapper_binding d, %d.var [concrete = %d.var] // CHECK:STDOUT: name_binding_decl { @@ -1373,9 +1358,9 @@ import library "extern_api"; // CHECK:STDOUT: %d.var_patt: %pattern_type.cb1 = var_pattern %d.patt [concrete = constants.%d.var_patt] // CHECK:STDOUT: } // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var_storage %e.var_patt [concrete] -// CHECK:STDOUT: %.loc36_9.1: type = splice_block %.loc36_9.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc36_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc36_9.3: type = converted %.loc36_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc31_9.1: type = splice_block %.loc31_9.3 [concrete = constants.%empty_tuple.type] { +// CHECK:STDOUT: %.loc31_9.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc31_9.3: type = converted %.loc31_9.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] // CHECK:STDOUT: } // CHECK:STDOUT: %e: ref %empty_tuple.type = wrapper_binding e, %e.var [concrete = %e.var] // CHECK:STDOUT: name_binding_decl { @@ -1400,29 +1385,29 @@ import library "extern_api"; // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref() // CHECK:STDOUT: assign file.%a.var, %A.call // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%Main.B [concrete = constants.%B] -// CHECK:STDOUT: %int_1.loc33: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc33: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] -// CHECK:STDOUT: %bound_method.loc33_16.1: = bound_method %int_1.loc33, %impl.elem0.loc33 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc33: = specific_function %impl.elem0.loc33, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc33_16.2: = bound_method %int_1.loc33, %specific_fn.loc33 [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc33: init %i32 = call %bound_method.loc33_16.2(%int_1.loc33) [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc33_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc33 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc33_16.2: %i32 = converted %int_1.loc33, %.loc33_16.1 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc33_16.2) +// CHECK:STDOUT: %int_1.loc28: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %impl.elem0.loc28: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] +// CHECK:STDOUT: %bound_method.loc28_16.1: = bound_method %int_1.loc28, %impl.elem0.loc28 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] +// CHECK:STDOUT: %specific_fn.loc28: = specific_function %impl.elem0.loc28, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc28_16.2: = bound_method %int_1.loc28, %specific_fn.loc28 [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28: init %i32 = call %bound_method.loc28_16.2(%int_1.loc28) [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc28_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc28_16.2: %i32 = converted %int_1.loc28, %.loc28_16.1 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc28_16.2) // CHECK:STDOUT: assign file.%b.var, %B.call // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [concrete = constants.%C] -// CHECK:STDOUT: %int_1.loc34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %.loc34_25.1: %tuple.type.985 = tuple_literal (%int_1.loc34) [concrete = constants.%tuple.378] -// CHECK:STDOUT: %impl.elem0.loc34: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] -// CHECK:STDOUT: %bound_method.loc34_25.1: = bound_method %int_1.loc34, %impl.elem0.loc34 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] -// CHECK:STDOUT: %specific_fn.loc34: = specific_function %impl.elem0.loc34, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc34_25.2: = bound_method %int_1.loc34, %specific_fn.loc34 [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc34: init %i32 = call %bound_method.loc34_25.2(%int_1.loc34) [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc34_25.2: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc34 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %.loc34_25.3: %i32 = converted %int_1.loc34, %.loc34_25.2 [concrete = constants.%int_1.68a] -// CHECK:STDOUT: %tuple: %tuple.type.294 = tuple_value (%.loc34_25.3) [concrete = constants.%tuple.f6b] -// CHECK:STDOUT: %.loc34_25.4: %tuple.type.294 = converted %.loc34_25.1, %tuple [concrete = constants.%tuple.f6b] -// CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc34_25.4) +// CHECK:STDOUT: %int_1.loc29: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %.loc29_25.1: %tuple.type.985 = tuple_literal (%int_1.loc29) [concrete = constants.%tuple.378] +// CHECK:STDOUT: %impl.elem0.loc29: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] +// CHECK:STDOUT: %bound_method.loc29_25.1: = bound_method %int_1.loc29, %impl.elem0.loc29 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] +// CHECK:STDOUT: %specific_fn.loc29: = specific_function %impl.elem0.loc29, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc29_25.2: = bound_method %int_1.loc29, %specific_fn.loc29 [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc29: init %i32 = call %bound_method.loc29_25.2(%int_1.loc29) [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc29_25.2: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc29 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %.loc29_25.3: %i32 = converted %int_1.loc29, %.loc29_25.2 [concrete = constants.%int_1.68a] +// CHECK:STDOUT: %tuple: %tuple.type.294 = tuple_value (%.loc29_25.3) [concrete = constants.%tuple.f6b] +// CHECK:STDOUT: %.loc29_25.4: %tuple.type.294 = converted %.loc29_25.1, %tuple [concrete = constants.%tuple.f6b] +// CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc29_25.4) // CHECK:STDOUT: assign file.%c.var, %C.call // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%Main.D [concrete = constants.%D] // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref() diff --git a/toolchain/check/testdata/function/declaration/no_definition_in_impl_file.carbon b/toolchain/check/testdata/function/declaration/no_definition_in_impl_file.carbon index b9351ca6ef7a..dac824acbe7e 100644 --- a/toolchain/check/testdata/function/declaration/no_definition_in_impl_file.carbon +++ b/toolchain/check/testdata/function/declaration/no_definition_in_impl_file.carbon @@ -52,8 +52,7 @@ fn C(); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+6]]:1-7: error: redeclaration of `fn C` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+5]]:1-7: error: redeclaration of `fn C` is redundant [RedeclRedundant] // CHECK:STDERR: decl_in_api_decl_in_impl.carbon:4:1-7: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: // CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+2]]:1-7: error: no definition found for declaration in impl file [MissingDefinitionInImpl] @@ -70,8 +69,7 @@ fn D(); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE+4]]:1-7: error: redeclaration of `fn D` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE+3]]:1-7: error: redeclaration of `fn D` is redundant [RedeclRedundant] // CHECK:STDERR: decl_in_api_decl_and_definition_in_impl.carbon:4:1-7: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn D(); diff --git a/toolchain/check/testdata/function/deduced_return/fail_redecl.carbon b/toolchain/check/testdata/function/deduced_return/fail_redecl.carbon index 24664e621687..0e75c1c37c68 100644 --- a/toolchain/check/testdata/function/deduced_return/fail_redecl.carbon +++ b/toolchain/check/testdata/function/deduced_return/fail_redecl.carbon @@ -93,8 +93,7 @@ fn F() -> auto { return 0 as i32; } // --- fail_api_def.impl.carbon impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_api_def.impl.carbon:[[@LINE+6]]:1-14: error: redeclaration of function with deduced return type [DeducedReturnTypeRedecl] -// CHECK:STDERR: imported from: fail_api_def.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_api_def.impl.carbon:[[@LINE+5]]:1-14: error: redeclaration of function with deduced return type [DeducedReturnTypeRedecl] // CHECK:STDERR: api_def.carbon:3:1-16: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: // CHECK:STDERR: fail_api_def.impl.carbon:[[@LINE+2]]:1-14: error: no definition found for declaration in impl file [MissingDefinitionInImpl] @@ -109,8 +108,7 @@ fn F() -> i32; // --- fail_api_decl.impl.carbon impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_api_decl.impl.carbon:[[@LINE+4]]:1-16: error: redeclaration of function with deduced return type [DeducedReturnTypeRedecl] -// CHECK:STDERR: imported from: fail_api_decl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_api_decl.impl.carbon:[[@LINE+3]]:1-16: error: redeclaration of function with deduced return type [DeducedReturnTypeRedecl] // CHECK:STDERR: api_decl.carbon:3:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn F() -> auto { return 0 as i32; } diff --git a/toolchain/check/testdata/function/definition/default_values.carbon b/toolchain/check/testdata/function/definition/default_values.carbon index 6636d81e2c5a..b2d0d05c8342 100644 --- a/toolchain/check/testdata/function/definition/default_values.carbon +++ b/toolchain/check/testdata/function/definition/default_values.carbon @@ -27,8 +27,7 @@ fn F(x: i32 = 0, y: i32 = 1, z: i32 = 2); // --- fail_imported_default_presence_mismatch.impl.carbon impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_imported_default_presence_mismatch.impl.carbon:[[@LINE+4]]:13-18: error: redeclaration differs at parameter 1 [RedeclParamDiffers] -// CHECK:STDERR: imported from: fail_imported_default_presence_mismatch.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_imported_default_presence_mismatch.impl.carbon:[[@LINE+3]]:13-18: error: redeclaration differs at parameter 1 [RedeclParamDiffers] // CHECK:STDERR: imported_default_presence_mismatch.carbon:3:6-15: note: previous declaration's corresponding parameter here [RedeclParamPrevious] // CHECK:STDERR: fn F(unused x: i32, unused y: i32 = 1, unused z: i32 = 2) { } @@ -41,8 +40,7 @@ fn F(x: i32 = 0, y: i32 = 10); // --- fail_imported_defaults_different_values.impl.carbon impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_imported_defaults_different_values.impl.carbon:[[@LINE+4]]:25-42: error: redeclaration differs at parameter 2 [RedeclParamDiffers] -// CHECK:STDERR: imported from: fail_imported_defaults_different_values.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_imported_defaults_different_values.impl.carbon:[[@LINE+3]]:25-42: error: redeclaration differs at parameter 2 [RedeclParamDiffers] // CHECK:STDERR: imported_defaults_different_values.carbon:3:18-28: note: previous declaration's corresponding parameter here [RedeclParamPrevious] // CHECK:STDERR: fn F(unused x: i32 = 0, unused y: i32 = 22) { } diff --git a/toolchain/check/testdata/function/definition/extern_library.carbon b/toolchain/check/testdata/function/definition/extern_library.carbon index 152e9f7130b0..a86cf2be1805 100644 --- a/toolchain/check/testdata/function/definition/extern_library.carbon +++ b/toolchain/check/testdata/function/definition/extern_library.carbon @@ -58,8 +58,7 @@ extern fn F(); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_two_file_impl_mismatch.impl.carbon:[[@LINE+4]]:1-8: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_two_file_impl_mismatch.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_two_file_impl_mismatch.impl.carbon:[[@LINE+3]]:1-8: error: redeclarations of `fn F` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: two_file_impl_mismatch.carbon:4:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn F() {} diff --git a/toolchain/check/testdata/function/definition/implicit_import.carbon b/toolchain/check/testdata/function/definition/implicit_import.carbon index 00136ed0549f..5827a9ead3aa 100644 --- a/toolchain/check/testdata/function/definition/implicit_import.carbon +++ b/toolchain/check/testdata/function/definition/implicit_import.carbon @@ -34,8 +34,7 @@ extern fn A(); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+4]]:1-8: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_extern_api.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_api.impl.carbon:[[@LINE+3]]:1-8: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern_api.carbon:4:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn A() {} @@ -50,8 +49,7 @@ fn A(); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+4]]:1-15: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_extern_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_extern_impl.impl.carbon:[[@LINE+3]]:1-15: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern_impl.carbon:4:1-7: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn A() {} @@ -66,8 +64,7 @@ fn A() {} impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+4]]:1-7: error: redeclaration of `fn A` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_redecl_after_def.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_redecl_after_def.impl.carbon:[[@LINE+3]]:1-7: error: redeclaration of `fn A` is redundant [RedeclRedundant] // CHECK:STDERR: redecl_after_def.carbon:4:1-8: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn A(); @@ -82,8 +79,7 @@ fn A() {} impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+4]]:1-8: error: redefinition of `fn A` [RedeclRedef] -// CHECK:STDERR: imported from: fail_redef_after_def.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_redef_after_def.impl.carbon:[[@LINE+3]]:1-8: error: redefinition of `fn A` [RedeclRedef] // CHECK:STDERR: redef_after_def.carbon:4:1-8: note: previously defined here [RedeclPrevDef] // CHECK:STDERR: fn A() {} @@ -99,8 +95,7 @@ alias B = A; impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+4]]:4: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_def_alias.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_def_alias.impl.carbon:[[@LINE+3]]:4: error: duplicate name `B` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: def_alias.carbon:5:7: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: fn B() {} @@ -287,7 +282,7 @@ fn B() {} // CHECK:STDOUT: type: type = facet_type [concrete] // CHECK:STDOUT: %A.type.9f4a6d.1: type = fn_type @A.1 [concrete] // CHECK:STDOUT: %A.921eb9.1: %A.type.9f4a6d.1 = struct_value () [concrete] -// CHECK:STDOUT: %A.type.9f4a6d.2: type = fn_type @A.loc8 [concrete] +// CHECK:STDOUT: %A.type.9f4a6d.2: type = fn_type @A.loc7 [concrete] // CHECK:STDOUT: %A.921eb9.2: %A.type.9f4a6d.2 = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -301,12 +296,12 @@ fn B() {} // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_31.1 = import // CHECK:STDOUT: %default.import.loc2_31.2 = import -// CHECK:STDOUT: %A.decl: %A.type.9f4a6d.2 = fn_decl @A.loc8 [concrete = constants.%A.921eb9.2] {} {} +// CHECK:STDOUT: %A.decl: %A.type.9f4a6d.2 = fn_decl @A.loc7 [concrete = constants.%A.921eb9.2] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @A.1 [from "redef_after_def.carbon"]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @A.loc8() { +// CHECK:STDOUT: fn @A.loc7() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/definition/import.carbon b/toolchain/check/testdata/function/definition/import.carbon index 55dcb2119aa7..e8d47d3e725d 100644 --- a/toolchain/check/testdata/function/definition/import.carbon +++ b/toolchain/check/testdata/function/definition/import.carbon @@ -51,13 +51,11 @@ library "[[@TEST_NAME]]"; import library "fns"; -// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+4]]:1-8: error: redeclaration of `fn A` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_def_ownership.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+3]]:1-8: error: redeclaration of `fn A` is redundant [RedeclRedundant] // CHECK:STDERR: fns.carbon:4:1-8: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn A() {}; -// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+4]]:1-20: error: redeclaration of `fn B` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_def_ownership.carbon:[[@LINE-8]]:1 [InImport] +// CHECK:STDERR: fail_def_ownership.carbon:[[@LINE+3]]:1-20: error: redeclaration of `fn B` is redundant [RedeclRedundant] // CHECK:STDERR: fns.carbon:5:1-21: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn B(b: i32) -> i32; @@ -68,14 +66,12 @@ library "[[@TEST_NAME]]"; import library "extern"; -// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+4]]:1-7: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_redecl_then_def.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+3]]:1-7: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern.carbon:4:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn A(); -// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+4]]:1-8: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_redecl_then_def.carbon:[[@LINE-9]]:1 [InImport] +// CHECK:STDERR: fail_redecl_then_def.carbon:[[@LINE+3]]:1-8: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: extern.carbon:4:1-14: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn A() {} @@ -86,8 +82,7 @@ library "[[@TEST_NAME]]"; import library "fns"; -// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+4]]:1-14: error: redeclarations of `fn D` must match use of `extern` [RedeclExternMismatch] -// CHECK:STDERR: imported from: fail_mix_extern_decl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_mix_extern_decl.carbon:[[@LINE+3]]:1-14: error: redeclarations of `fn D` must match use of `extern` [RedeclExternMismatch] // CHECK:STDERR: fns.carbon:7:1-7: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: extern fn D(); @@ -413,7 +408,7 @@ fn D() {} // CHECK:STDOUT: type: type = facet_type [concrete] // CHECK:STDOUT: %A.type.9f4a6d.1: type = fn_type @A.1 [concrete] // CHECK:STDOUT: %A.921eb9.1: %A.type.9f4a6d.1 = struct_value () [concrete] -// CHECK:STDOUT: %A.type.9f4a6d.2: type = fn_type @A.loc10 [concrete] +// CHECK:STDOUT: %A.type.9f4a6d.2: type = fn_type @A.loc9 [concrete] // CHECK:STDOUT: %A.921eb9.2: %A.type.9f4a6d.2 = struct_value () [concrete] // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %Int.type: type = parameterized_class_name_type @Int [concrete] @@ -446,12 +441,12 @@ fn D() {} // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %A.decl: %A.type.9f4a6d.2 = fn_decl @A.loc10 [concrete = constants.%A.921eb9.2] {} {} +// CHECK:STDOUT: %A.decl: %A.type.9f4a6d.2 = fn_decl @A.loc9 [concrete = constants.%A.921eb9.2] {} {} // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [concrete = constants.%B] {} { -// CHECK:STDOUT: %i32.loc15_17: type = type_literal constants.%i32 [concrete = constants.%i32] -// CHECK:STDOUT: %.loc15: Core.Form = init_form %i32.loc15_17 [concrete = constants.%.0b3] +// CHECK:STDOUT: %i32.loc13_17: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %.loc13: Core.Form = init_form %i32.loc13_17 [concrete = constants.%.0b3] // CHECK:STDOUT: %b.param: %i32 = value_param call_param0 -// CHECK:STDOUT: %i32.loc15_9: type = type_literal constants.%i32 [concrete = constants.%i32] +// CHECK:STDOUT: %i32.loc13_9: type = type_literal constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: %b: %i32 = wrapper_binding b, %b.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param @@ -460,7 +455,7 @@ fn D() {} // CHECK:STDOUT: // CHECK:STDOUT: fn @A.1 [from "fns.carbon"]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @A.loc10() { +// CHECK:STDOUT: fn @A.loc9() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -484,13 +479,13 @@ fn D() {} // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .A = %A.decl.loc10 +// CHECK:STDOUT: .A = %A.decl.loc9 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %A.decl.loc10: %A.type = fn_decl @A [concrete = constants.%A] {} {} -// CHECK:STDOUT: %A.decl.loc16: %A.type = fn_decl @A [concrete = constants.%A] {} {} +// CHECK:STDOUT: %A.decl.loc9: %A.type = fn_decl @A [concrete = constants.%A] {} {} +// CHECK:STDOUT: %A.decl.loc14: %A.type = fn_decl @A [concrete = constants.%A] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: extern fn @A() [from "extern.carbon"] { @@ -521,13 +516,13 @@ fn D() {} // CHECK:STDOUT: .A = imports.%Main.A // CHECK:STDOUT: .B = imports.%Main.B // CHECK:STDOUT: .C = imports.%Main.C -// CHECK:STDOUT: .D = %D.decl.loc10 +// CHECK:STDOUT: .D = %D.decl.loc9 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %D.decl.loc10: %D.type = fn_decl @D [concrete = constants.%D] {} {} -// CHECK:STDOUT: %D.decl.loc12: %D.type = fn_decl @D [concrete = constants.%D] {} {} +// CHECK:STDOUT: %D.decl.loc9: %D.type = fn_decl @D [concrete = constants.%D] {} {} +// CHECK:STDOUT: %D.decl.loc11: %D.type = fn_decl @D [concrete = constants.%D] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @D() [from "fns.carbon"] { diff --git a/toolchain/check/testdata/function/generic/fail_deduce_imported_function.carbon b/toolchain/check/testdata/function/generic/fail_deduce_imported_function.carbon index 5e735ef5df74..5822cba7e6bc 100644 --- a/toolchain/check/testdata/function/generic/fail_deduce_imported_function.carbon +++ b/toolchain/check/testdata/function/generic/fail_deduce_imported_function.carbon @@ -30,8 +30,7 @@ fn B() { // CHECK:STDERR: A({.b = {}}); - // CHECK:STDERR: fail_deduce_imported_function.carbon:[[@LINE+4]]:3-18: error: cannot deduce value for generic parameter `T` [DeductionIncomplete] - // CHECK:STDERR: imported from: fail_deduce_imported_function.carbon:[[@LINE-11]]:1 [InImport] + // CHECK:STDERR: fail_deduce_imported_function.carbon:[[@LINE+3]]:3-18: error: cannot deduce value for generic parameter `T` [DeductionIncomplete] // CHECK:STDERR: lib.carbon:4:1-31: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: Lib.A({.b = {}}); @@ -228,9 +227,9 @@ fn B() { // CHECK:STDOUT: %.loc10_12: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] // CHECK:STDOUT: %.loc10_13: %struct_type.b = struct_literal (%.loc10_12) [concrete = constants.%struct] // CHECK:STDOUT: %Lib.ref: = name_ref Lib, imports.%Lib [concrete = imports.%Lib] -// CHECK:STDOUT: %A.ref.loc16: %A.type.42a = name_ref A, imports.%Lib.A [concrete = constants.%A.b9a] -// CHECK:STDOUT: %.loc16_16: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] -// CHECK:STDOUT: %.loc16_17: %struct_type.b = struct_literal (%.loc16_16) [concrete = constants.%struct] +// CHECK:STDOUT: %A.ref.loc15: %A.type.42a = name_ref A, imports.%Lib.A [concrete = constants.%A.b9a] +// CHECK:STDOUT: %.loc15_16: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] +// CHECK:STDOUT: %.loc15_17: %struct_type.b = struct_literal (%.loc15_16) [concrete = constants.%struct] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/eval_musteval.carbon b/toolchain/check/testdata/impl/eval_musteval.carbon index 85c1ce049b59..be9185651b4e 100644 --- a/toolchain/check/testdata/impl/eval_musteval.carbon +++ b/toolchain/check/testdata/impl/eval_musteval.carbon @@ -150,18 +150,16 @@ import library "interface"; class B { adapt {}; } impl B as Runtime { - // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+5]]:3-38: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] - // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+4]]:3-38: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] - // CHECK:STDERR: imported from: fail_impl_musteval.carbon:[[@LINE-7]]:1 [InImport] + // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+4]]:3-38: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+3]]:3-38: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: interface.carbon:5:3-21: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: musteval fn F(unused self) -> type { return B; } } impl B as Eval { - // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+5]]:3-38: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] - // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+4]]:3-38: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] - // CHECK:STDERR: imported from: fail_impl_musteval.carbon:[[@LINE-16]]:1 [InImport] + // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+4]]:3-38: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: fail_impl_musteval.carbon:[[@LINE+3]]:3-38: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: interface.carbon:9:3-26: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: musteval fn F(unused self) -> type { return B; } @@ -197,9 +195,8 @@ impl B as Core.ImplicitAs(BView) { } impl B as MustEval { - // CHECK:STDERR: fail_todo_impl_musteval_from_musteval_thunk.carbon:[[@LINE+5]]:3-45: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] - // CHECK:STDERR: fail_todo_impl_musteval_from_musteval_thunk.carbon:[[@LINE+4]]:3-45: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] - // CHECK:STDERR: imported from: fail_todo_impl_musteval_from_musteval_thunk.carbon:[[@LINE-12]]:1 [InImport] + // CHECK:STDERR: fail_todo_impl_musteval_from_musteval_thunk.carbon:[[@LINE+4]]:3-45: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] + // CHECK:STDERR: fail_todo_impl_musteval_from_musteval_thunk.carbon:[[@LINE+3]]:3-45: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: interface.carbon:13:3-30: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: musteval fn F(unused self: BView) -> type { return B; } diff --git a/toolchain/check/testdata/impl/import_interface_assoc_const.carbon b/toolchain/check/testdata/impl/import_interface_assoc_const.carbon index c432ccc202aa..3bc6970ab535 100644 --- a/toolchain/check/testdata/impl/import_interface_assoc_const.carbon +++ b/toolchain/check/testdata/impl/import_interface_assoc_const.carbon @@ -89,11 +89,10 @@ import library "interface"; class C6 { } impl C6 as I where .T = {}; -// CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE+6]]:1-14: error: associated constant T not given a value in impl of interface I [ImplAssociatedConstantNeedsValue] -// CHECK:STDERR: imported from: fail_missing_on_definition.carbon:[[@LINE-5]]:1 [InImport] +// CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE+5]]:1-14: error: associated constant T not given a value in impl of interface I [ImplAssociatedConstantNeedsValue] // CHECK:STDERR: interface.carbon:3:19-25: note: associated constant declared here [AssociatedConstantHere] // CHECK:STDERR: -// CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE-5]]:1-27: error: impl declared but not defined [ImplMissingDefinition] +// CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE-4]]:1-27: error: impl declared but not defined [ImplMissingDefinition] // CHECK:STDERR: impl C6 as I { } @@ -1002,7 +1001,7 @@ impl CD as IF where .F = 0 { // CHECK:STDOUT: %C6.ref: type = name_ref C6, file.%C6.decl [concrete = constants.%C6] // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc12: = impl_self_witness @C6.as.I.impl.e1b87a.2.%C6.ref, @I [concrete = constants.%.7ff] +// CHECK:STDOUT: %.loc11: = impl_self_witness @C6.as.I.impl.e1b87a.2.%C6.ref, @I [concrete = constants.%.7ff] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @I [from "interface.carbon"] { diff --git a/toolchain/check/testdata/impl/lookup/fail_poison_custom_witness.carbon b/toolchain/check/testdata/impl/lookup/fail_poison_custom_witness.carbon index d8b6d4f911ea..b57379927c3f 100644 --- a/toolchain/check/testdata/impl/lookup/fail_poison_custom_witness.carbon +++ b/toolchain/check/testdata/impl/lookup/fail_poison_custom_witness.carbon @@ -56,8 +56,7 @@ struct A { }; '''; -// CHECK:STDERR: fail_poison_custom_witness.carbon:[[@LINE+4]]:1-9: error: found `impl` for Cpp.A as SubobjectDestroy, which has a custom witness [PoisonedImplLookupCustomResult] -// CHECK:STDERR: imported from: fail_poison_custom_witness.carbon:[[@LINE-12]]:1 [InImport] +// CHECK:STDERR: fail_poison_custom_witness.carbon:[[@LINE+3]]:1-9: error: found `impl` for Cpp.A as SubobjectDestroy, which has a custom witness [PoisonedImplLookupCustomResult] // CHECK:STDERR: destroy.carbon:8:1-45: note: the use tried to select the `impl` here, but a custom witness was already chosen [PoisonedImplLookupCustomResultNoteBadImpl] // CHECK:STDERR: class B { diff --git a/toolchain/check/testdata/impl/lookup/impl_overlap.carbon b/toolchain/check/testdata/impl/lookup/impl_overlap.carbon index fe7a1578cb07..3fef44c57a8f 100644 --- a/toolchain/check/testdata/impl/lookup/impl_overlap.carbon +++ b/toolchain/check/testdata/impl/lookup/impl_overlap.carbon @@ -175,8 +175,7 @@ class C {} // Can't write a final impl in both the interface's file and the root self // type's file (when they are different files). // -// CHECK:STDERR: fail_final_impl_with_both_interface_and_self_but_different_files.carbon:[[@LINE+4]]:1-23: error: `final impl` overlaps with `final impl` from another file [FinalImplOverlapsDifferentFile] -// CHECK:STDERR: imported from: fail_final_impl_with_both_interface_and_self_but_different_files.carbon:[[@LINE-8]]:1 [InImport] +// CHECK:STDERR: fail_final_impl_with_both_interface_and_self_but_different_files.carbon:[[@LINE+3]]:1-23: error: `final impl` overlaps with `final impl` from another file [FinalImplOverlapsDifferentFile] // CHECK:STDERR: interface_z_with_impl.carbon:9:1-39: note: imported `final impl` here [FinalImplOverlapsDifferentFileNote] // CHECK:STDERR: final impl C as Z(()) {} @@ -191,8 +190,7 @@ class C {} // This final impl is overlapped by a final impl in the interface file, and you // can't write a final impl in two different files. // -// CHECK:STDERR: fail_final_overlaps_final_from_other_file.carbon:[[@LINE+4]]:1-22: error: `final impl` overlaps with `final impl` from another file [FinalImplOverlapsDifferentFile] -// CHECK:STDERR: imported from: fail_final_overlaps_final_from_other_file.carbon:[[@LINE-8]]:1 [InImport] +// CHECK:STDERR: fail_final_overlaps_final_from_other_file.carbon:[[@LINE+3]]:1-22: error: `final impl` overlaps with `final impl` from another file [FinalImplOverlapsDifferentFile] // CHECK:STDERR: interface_z_with_impl.carbon:9:1-39: note: imported `final impl` here [FinalImplOverlapsDifferentFileNote] // CHECK:STDERR: final impl C as Z(C) {} @@ -206,8 +204,7 @@ class C {} // This non-final impl is subsumed by a final impl in the interface file. // -// CHECK:STDERR: fail_final_overlaps_non_final_from_other_file.carbon:[[@LINE+4]]:1-16: error: `impl` will never be used [ImplFinalOverlapsNonFinal] -// CHECK:STDERR: imported from: fail_final_overlaps_non_final_from_other_file.carbon:[[@LINE-7]]:1 [InImport] +// CHECK:STDERR: fail_final_overlaps_non_final_from_other_file.carbon:[[@LINE+3]]:1-16: error: `impl` will never be used [ImplFinalOverlapsNonFinal] // CHECK:STDERR: interface_z_with_impl.carbon:9:1-39: note: `final impl` declared here would always be used instead [ImplFinalOverlapsNonFinalNote] // CHECK:STDERR: impl C as Z(C) {} diff --git a/toolchain/check/testdata/impl/orphan.carbon b/toolchain/check/testdata/impl/orphan.carbon index 26d7341a516c..fc4351c40130 100644 --- a/toolchain/check/testdata/impl/orphan.carbon +++ b/toolchain/check/testdata/impl/orphan.carbon @@ -351,8 +351,7 @@ library "[[@TEST_NAME]]"; import library "use_extern_class"; -// CHECK:STDERR: fail_todo_extern_class.carbon:[[@LINE+2]]:1-15: error: redeclaration of `class C` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_todo_extern_class.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_todo_extern_class.carbon:[[@LINE+1]]:1-15: error: redeclaration of `class C` is redundant [RedeclRedundant] extern class C; // --- fail_use_extern_class.carbon diff --git a/toolchain/check/testdata/impl/redeclaration.carbon b/toolchain/check/testdata/impl/redeclaration.carbon index 6201d84ebb7a..56346060efbc 100644 --- a/toolchain/check/testdata/impl/redeclaration.carbon +++ b/toolchain/check/testdata/impl/redeclaration.carbon @@ -191,8 +191,7 @@ class D { // But that means it overlaps fully with the impl from the api file, which is // a separate error. - // CHECK:STDERR: fail_decl_of_imported_impl_in_new_scope.impl.carbon:[[@LINE+4]]:3-15: error: found non-final `impl` with the same type structure as another non-final `impl` [ImplNonFinalSameTypeStructure] - // CHECK:STDERR: imported from: fail_decl_of_imported_impl_in_new_scope.impl.carbon:[[@LINE-8]]:1 [InImport] + // CHECK:STDERR: fail_decl_of_imported_impl_in_new_scope.impl.carbon:[[@LINE+3]]:3-15: error: found non-final `impl` with the same type structure as another non-final `impl` [ImplNonFinalSameTypeStructure] // CHECK:STDERR: decl_of_imported_impl_in_new_scope.carbon:5:1-13: note: other `impl` here [ImplNonFinalSameTypeStructureNote] // CHECK:STDERR: impl C as Z {} diff --git a/toolchain/check/testdata/impl/using_invalid_interface.carbon b/toolchain/check/testdata/impl/using_invalid_interface.carbon index 90a8e9875074..f8729b629369 100644 --- a/toolchain/check/testdata/impl/using_invalid_interface.carbon +++ b/toolchain/check/testdata/impl/using_invalid_interface.carbon @@ -42,8 +42,7 @@ class C { } } -// CHECK:STDERR: fail_misusing_invalid_interface.carbon:[[@LINE+4]]:28-33: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch] -// CHECK:STDERR: imported from: fail_misusing_invalid_interface.carbon:[[@LINE-15]]:1 [InImport] +// CHECK:STDERR: fail_misusing_invalid_interface.carbon:[[@LINE+3]]:28-33: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch] // CHECK:STDERR: fail_invalid_interface.carbon:12:3-29: note: calling function declared here [InCallToEntity] // CHECK:STDERR: fn F(generic T: IMisuse) { T.Op(); } @@ -66,8 +65,7 @@ class ArgC {} class C { impl as IMisuse where .Arg = ArgC { - // CHECK:STDERR: fail_using_invalid_interface.carbon:[[@LINE+4]]:27-38: error: cannot convert type `ArgC` into type implementing `I` [ConversionFailureTypeToFacet] - // CHECK:STDERR: imported from: fail_using_invalid_interface.carbon:[[@LINE-7]]:1 [InImport] + // CHECK:STDERR: fail_using_invalid_interface.carbon:[[@LINE+3]]:27-38: error: cannot convert type `ArgC` into type implementing `I` [ConversionFailureTypeToFacet] // CHECK:STDERR: fail_invalid_interface.carbon:5:14-17: note: initializing generic parameter `T` declared here [InitializingGenericParam] // CHECK:STDERR: fn Op(unused self) -> ArgToI(ArgC) { @@ -76,8 +74,7 @@ class C { } } -// CHECK:STDERR: fail_using_invalid_interface.carbon:[[@LINE+4]]:28-33: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch] -// CHECK:STDERR: imported from: fail_using_invalid_interface.carbon:[[@LINE-17]]:1 [InImport] +// CHECK:STDERR: fail_using_invalid_interface.carbon:[[@LINE+3]]:28-33: error: 0 arguments passed to function expecting 1 argument [CallArgCountMismatch] // CHECK:STDERR: fail_invalid_interface.carbon:12:3-29: note: calling function declared here [InCallToEntity] // CHECK:STDERR: fn F(generic T: IMisuse) { T.Op(); } diff --git a/toolchain/check/testdata/interface/fail_definition_imported.carbon b/toolchain/check/testdata/interface/fail_definition_imported.carbon index ec49cd5c26e0..4734707086e5 100644 --- a/toolchain/check/testdata/interface/fail_definition_imported.carbon +++ b/toolchain/check/testdata/interface/fail_definition_imported.carbon @@ -24,8 +24,7 @@ library "[[@TEST_NAME]]"; import library "a"; // TODO: Replace this diagnostic with one that better describes the error, such as 'DeclaredInMultipleLibraries'. -// CHECK:STDERR: fail_b.carbon:[[@LINE+4]]:1-13: error: redeclaration of `interface I` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_b.carbon:[[@LINE-4]]:1 [InImport] +// CHECK:STDERR: fail_b.carbon:[[@LINE+3]]:1-13: error: redeclaration of `interface I` is redundant [RedeclRedundant] // CHECK:STDERR: a.carbon:4:1-12: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: interface I {} diff --git a/toolchain/check/testdata/interface/modifiers.carbon b/toolchain/check/testdata/interface/modifiers.carbon index 123432b2af64..22c988206fa8 100644 --- a/toolchain/check/testdata/interface/modifiers.carbon +++ b/toolchain/check/testdata/interface/modifiers.carbon @@ -186,8 +186,7 @@ library "[[@TEST_NAME]]"; import library "final_interfaces"; class C { - // CHECK:STDERR: fail_impl_final.carbon:[[@LINE+4]]:3-23: error: attempted to implement `M`, which is final in interface `FinalMethod` [ImplFinalFunction] - // CHECK:STDERR: imported from: fail_impl_final.carbon:[[@LINE-4]]:1 [InImport] + // CHECK:STDERR: fail_impl_final.carbon:[[@LINE+3]]:3-23: error: attempted to implement `M`, which is final in interface `FinalMethod` [ImplFinalFunction] // CHECK:STDERR: final_interfaces.carbon:10:3-27: note: associated function M declared here [AssociatedFunctionHere] // CHECK:STDERR: impl as FinalMethod { diff --git a/toolchain/check/testdata/interface/no_definition_in_impl_file.carbon b/toolchain/check/testdata/interface/no_definition_in_impl_file.carbon index c24d89fbc561..9d78761c8cdb 100644 --- a/toolchain/check/testdata/interface/no_definition_in_impl_file.carbon +++ b/toolchain/check/testdata/interface/no_definition_in_impl_file.carbon @@ -52,8 +52,7 @@ interface C; impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+6]]:1-12: error: redeclaration of `interface C` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+5]]:1-12: error: redeclaration of `interface C` is redundant [RedeclRedundant] // CHECK:STDERR: decl_in_api_decl_in_impl.carbon:4:1-12: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: // CHECK:STDERR: fail_decl_in_api_decl_in_impl.impl.carbon:[[@LINE+2]]:1-12: error: no definition found for declaration in impl file [MissingDefinitionInImpl] @@ -70,8 +69,7 @@ interface D; impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE+4]]:1-12: error: redeclaration of `interface D` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_decl_in_api_decl_and_definition_in_impl.impl.carbon:[[@LINE+3]]:1-12: error: redeclaration of `interface D` is redundant [RedeclRedundant] // CHECK:STDERR: decl_in_api_decl_and_definition_in_impl.carbon:4:1-12: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: interface D; diff --git a/toolchain/check/testdata/interface/observe.carbon b/toolchain/check/testdata/interface/observe.carbon index 92c7661a073f..6ae82cb4dddb 100644 --- a/toolchain/check/testdata/interface/observe.carbon +++ b/toolchain/check/testdata/interface/observe.carbon @@ -38,8 +38,7 @@ import library "transitive"; fn F[T: Transitive](t: T) { var a: T.A = t.GetA(); - // CHECK:STDERR: fail_todo_equivalent.carbon:[[@LINE+4]]:3-13: error: cannot convert type `T.(Transitive.A)` that implements `P & Core.Destroy` into type implementing `R & Core.Destroy where...` [ConversionFailureFacetToFacet] - // CHECK:STDERR: imported from: fail_todo_equivalent.carbon:[[@LINE-6]]:1 [InImport] + // CHECK:STDERR: fail_todo_equivalent.carbon:[[@LINE+3]]:3-13: error: cannot convert type `T.(Transitive.A)` that implements `P & Core.Destroy` into type implementing `R & Core.Destroy where...` [ConversionFailureFacetToFacet] // CHECK:STDERR: transitive.carbon:14:3-24: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: t.TakesC(a); @@ -146,8 +145,7 @@ fn F[U: Z](t: U.Z1) { var a: U.Z1.A = t.GetA(); // Depends on the observe statement in Transitive, which is the type of `Z1`. - // CHECK:STDERR: fail_todo_observe_from_type_of_assoc_constant.carbon:[[@LINE+4]]:3-13: error: cannot convert type `U.(Z.Z1).(Transitive.A)` that implements `P & Core.Destroy` into type implementing `R & Core.Destroy where...` [ConversionFailureFacetToFacet] - // CHECK:STDERR: imported from: fail_todo_observe_from_type_of_assoc_constant.carbon:[[@LINE-12]]:1 [InImport] + // CHECK:STDERR: fail_todo_observe_from_type_of_assoc_constant.carbon:[[@LINE+3]]:3-13: error: cannot convert type `U.(Z.Z1).(Transitive.A)` that implements `P & Core.Destroy` into type implementing `R & Core.Destroy where...` [ConversionFailureFacetToFacet] // CHECK:STDERR: transitive.carbon:14:3-24: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: t.TakesC(a); @@ -419,8 +417,7 @@ import library "generic_observe"; fn F[W: A, X: I(W)](x: X) { var v: X.V = x.GetV(); - // CHECK:STDERR: fail_todo_generic_import.carbon:[[@LINE+4]]:3-13: error: cannot convert type `X.(I(W).V)` that implements `C & Core.Destroy where...` into type implementing `A` [ConversionFailureFacetToFacet] - // CHECK:STDERR: imported from: fail_todo_generic_import.carbon:[[@LINE-6]]:1 [InImport] + // CHECK:STDERR: fail_todo_generic_import.carbon:[[@LINE+3]]:3-13: error: cannot convert type `X.(I(W).V)` that implements `C & Core.Destroy where...` into type implementing `A` [ConversionFailureFacetToFacet] // CHECK:STDERR: generic_observe.carbon:12:3-24: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: x.TakesT(v); diff --git a/toolchain/check/testdata/interface/syntactic_merge.carbon b/toolchain/check/testdata/interface/syntactic_merge.carbon index 5886c9815dfd..3a19c2750227 100644 --- a/toolchain/check/testdata/interface/syntactic_merge.carbon +++ b/toolchain/check/testdata/interface/syntactic_merge.carbon @@ -72,13 +72,11 @@ interface Bar(a: D); impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+4]]:11-13: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_todo_two_file.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+3]]:11-13: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: two_file.carbon:7:1-20: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: interface Foo(a: C) {} -// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+4]]:11-13: error: duplicate name `Bar` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_todo_two_file.impl.carbon:[[@LINE-8]]:1 [InImport] +// CHECK:STDERR: fail_todo_two_file.impl.carbon:[[@LINE+3]]:11-13: error: duplicate name `Bar` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: two_file.carbon:8:1-20: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: interface Bar(a: D) {} @@ -139,8 +137,7 @@ alias D = C; // TODO: This fails because importing interfaces doesn't work well. It should // fail due to `C` versus `D`, but may succeed if importing interfaces is fixed // before syntax matching on imports is supported. -// CHECK:STDERR: fail_alias_two_file.impl.carbon:[[@LINE+4]]:11-13: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_alias_two_file.impl.carbon:[[@LINE-8]]:1 [InImport] +// CHECK:STDERR: fail_alias_two_file.impl.carbon:[[@LINE+3]]:11-13: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: alias_two_file.carbon:6:1-20: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: interface Foo(a: D) {} @@ -644,15 +641,15 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: %a: %C = symbolic_binding a, 0 [symbolic] // CHECK:STDOUT: %Foo.type.bc6a25.1: type = generic_interface_type @Foo.1 [concrete] // CHECK:STDOUT: %Foo.generic.d3ea5a.1: %Foo.type.bc6a25.1 = struct_value () [concrete] -// CHECK:STDOUT: %Foo.type.bc6a25.2: type = generic_interface_type @Foo.loc8 [concrete] +// CHECK:STDOUT: %Foo.type.bc6a25.2: type = generic_interface_type @Foo.loc7 [concrete] // CHECK:STDOUT: %Foo.generic.d3ea5a.2: %Foo.type.bc6a25.2 = struct_value () [concrete] -// CHECK:STDOUT: %Foo.type.137: type = facet_type <@Foo.loc8, @Foo.loc8(%a)> [symbolic] +// CHECK:STDOUT: %Foo.type.137: type = facet_type <@Foo.loc7, @Foo.loc7(%a)> [symbolic] // CHECK:STDOUT: %Self.4d3: %Foo.type.137 = symbolic_binding Self, 1 [symbolic] // CHECK:STDOUT: %Bar.type.3f06c8.1: type = generic_interface_type @Bar.1 [concrete] // CHECK:STDOUT: %Bar.generic.b3011f.1: %Bar.type.3f06c8.1 = struct_value () [concrete] -// CHECK:STDOUT: %Bar.type.3f06c8.2: type = generic_interface_type @Bar.loc13 [concrete] +// CHECK:STDOUT: %Bar.type.3f06c8.2: type = generic_interface_type @Bar.loc11 [concrete] // CHECK:STDOUT: %Bar.generic.b3011f.2: %Bar.type.3f06c8.2 = struct_value () [concrete] -// CHECK:STDOUT: %Bar.type.309: type = facet_type <@Bar.loc13, @Bar.loc13(%a)> [symbolic] +// CHECK:STDOUT: %Bar.type.309: type = facet_type <@Bar.loc11, @Bar.loc11(%a)> [symbolic] // CHECK:STDOUT: %Self.3ee: %Bar.type.309 = symbolic_binding Self, 1 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -676,23 +673,23 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_24.1 = import // CHECK:STDOUT: %default.import.loc2_24.2 = import -// CHECK:STDOUT: %Foo.decl: %Foo.type.bc6a25.2 = interface_decl @Foo.loc8 [concrete = constants.%Foo.generic.d3ea5a.2] { -// CHECK:STDOUT: %a.patt.loc8_16.1: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc8_16.2 (constants.%a.patt)] +// CHECK:STDOUT: %Foo.decl: %Foo.type.bc6a25.2 = interface_decl @Foo.loc7 [concrete = constants.%Foo.generic.d3ea5a.2] { +// CHECK:STDOUT: %a.patt.loc7_16.1: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc7_16.2 (constants.%a.patt)] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc8: type = splice_block %C.ref [concrete = constants.%C] { +// CHECK:STDOUT: %.loc7: type = splice_block %C.ref [concrete = constants.%C] { // CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C] // CHECK:STDOUT: } -// CHECK:STDOUT: %a.loc8_16.2: %C = symbolic_binding a, 0 [symbolic = %a.loc8_16.1 (constants.%a)] +// CHECK:STDOUT: %a.loc7_16.2: %C = symbolic_binding a, 0 [symbolic = %a.loc7_16.1 (constants.%a)] // CHECK:STDOUT: } -// CHECK:STDOUT: %Bar.decl: %Bar.type.3f06c8.2 = interface_decl @Bar.loc13 [concrete = constants.%Bar.generic.b3011f.2] { -// CHECK:STDOUT: %a.patt.loc13_16.1: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc13_16.2 (constants.%a.patt)] +// CHECK:STDOUT: %Bar.decl: %Bar.type.3f06c8.2 = interface_decl @Bar.loc11 [concrete = constants.%Bar.generic.b3011f.2] { +// CHECK:STDOUT: %a.patt.loc11_16.1: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc11_16.2 (constants.%a.patt)] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc13: type = splice_block %D.ref [concrete = constants.%C] { +// CHECK:STDOUT: %.loc11: type = splice_block %D.ref [concrete = constants.%C] { // CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen] // CHECK:STDOUT: %D.ref: type = name_ref D, imports.%Main.D [concrete = constants.%C] // CHECK:STDOUT: } -// CHECK:STDOUT: %a.loc13_16.2: %C = symbolic_binding a, 0 [symbolic = %a.loc13_16.1 (constants.%a)] +// CHECK:STDOUT: %a.loc11_16.2: %C = symbolic_binding a, 0 [symbolic = %a.loc11_16.1 (constants.%a)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -703,20 +700,20 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: interface; // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic interface @Foo.loc8(%a.loc8_16.2: %C) { -// CHECK:STDOUT: %a.patt.loc8_16.2: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc8_16.2 (constants.%a.patt)] -// CHECK:STDOUT: %a.loc8_16.1: %C = symbolic_binding a, 0 [symbolic = %a.loc8_16.1 (constants.%a)] +// CHECK:STDOUT: generic interface @Foo.loc7(%a.loc7_16.2: %C) { +// CHECK:STDOUT: %a.patt.loc7_16.2: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc7_16.2 (constants.%a.patt)] +// CHECK:STDOUT: %a.loc7_16.1: %C = symbolic_binding a, 0 [symbolic = %a.loc7_16.1 (constants.%a)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Foo.type: type = facet_type <@Foo.loc8, @Foo.loc8(%a.loc8_16.1)> [symbolic = %Foo.type (constants.%Foo.type.137)] -// CHECK:STDOUT: %Self.loc8_21.2: @Foo.loc8.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc8_21.2 (constants.%Self.4d3)] +// CHECK:STDOUT: %Foo.type: type = facet_type <@Foo.loc7, @Foo.loc7(%a.loc7_16.1)> [symbolic = %Foo.type (constants.%Foo.type.137)] +// CHECK:STDOUT: %Self.loc7_21.2: @Foo.loc7.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc7_21.2 (constants.%Self.4d3)] // CHECK:STDOUT: // CHECK:STDOUT: interface { -// CHECK:STDOUT: %Self.loc8_21.1: @Foo.loc8.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc8_21.2 (constants.%Self.4d3)] -// CHECK:STDOUT: %Foo.WithSelf.decl = interface_with_self_decl @Foo.loc8 [concrete] +// CHECK:STDOUT: %Self.loc7_21.1: @Foo.loc7.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc7_21.2 (constants.%Self.4d3)] +// CHECK:STDOUT: %Foo.WithSelf.decl = interface_with_self_decl @Foo.loc7 [concrete] // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self.loc8_21.1 +// CHECK:STDOUT: .Self = %Self.loc7_21.1 // CHECK:STDOUT: witness = () // CHECK:STDOUT: // CHECK:STDOUT: !requires: @@ -730,20 +727,20 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: interface; // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic interface @Bar.loc13(%a.loc13_16.2: %C) { -// CHECK:STDOUT: %a.patt.loc13_16.2: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc13_16.2 (constants.%a.patt)] -// CHECK:STDOUT: %a.loc13_16.1: %C = symbolic_binding a, 0 [symbolic = %a.loc13_16.1 (constants.%a)] +// CHECK:STDOUT: generic interface @Bar.loc11(%a.loc11_16.2: %C) { +// CHECK:STDOUT: %a.patt.loc11_16.2: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc11_16.2 (constants.%a.patt)] +// CHECK:STDOUT: %a.loc11_16.1: %C = symbolic_binding a, 0 [symbolic = %a.loc11_16.1 (constants.%a)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Bar.type: type = facet_type <@Bar.loc13, @Bar.loc13(%a.loc13_16.1)> [symbolic = %Bar.type (constants.%Bar.type.309)] -// CHECK:STDOUT: %Self.loc13_21.2: @Bar.loc13.%Bar.type (%Bar.type.309) = symbolic_binding Self, 1 [symbolic = %Self.loc13_21.2 (constants.%Self.3ee)] +// CHECK:STDOUT: %Bar.type: type = facet_type <@Bar.loc11, @Bar.loc11(%a.loc11_16.1)> [symbolic = %Bar.type (constants.%Bar.type.309)] +// CHECK:STDOUT: %Self.loc11_21.2: @Bar.loc11.%Bar.type (%Bar.type.309) = symbolic_binding Self, 1 [symbolic = %Self.loc11_21.2 (constants.%Self.3ee)] // CHECK:STDOUT: // CHECK:STDOUT: interface { -// CHECK:STDOUT: %Self.loc13_21.1: @Bar.loc13.%Bar.type (%Bar.type.309) = symbolic_binding Self, 1 [symbolic = %Self.loc13_21.2 (constants.%Self.3ee)] -// CHECK:STDOUT: %Bar.WithSelf.decl = interface_with_self_decl @Bar.loc13 [concrete] +// CHECK:STDOUT: %Self.loc11_21.1: @Bar.loc11.%Bar.type (%Bar.type.309) = symbolic_binding Self, 1 [symbolic = %Self.loc11_21.2 (constants.%Self.3ee)] +// CHECK:STDOUT: %Bar.WithSelf.decl = interface_with_self_decl @Bar.loc11 [concrete] // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self.loc13_21.1 +// CHECK:STDOUT: .Self = %Self.loc11_21.1 // CHECK:STDOUT: witness = () // CHECK:STDOUT: // CHECK:STDOUT: !requires: @@ -762,9 +759,9 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: %a => constants.%a // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Foo.loc8(constants.%a) { -// CHECK:STDOUT: %a.patt.loc8_16.2 => constants.%a.patt -// CHECK:STDOUT: %a.loc8_16.1 => constants.%a +// CHECK:STDOUT: specific @Foo.loc7(constants.%a) { +// CHECK:STDOUT: %a.patt.loc7_16.2 => constants.%a.patt +// CHECK:STDOUT: %a.loc7_16.1 => constants.%a // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Foo.WithSelf(constants.%a, constants.%Self.4d3) {} @@ -774,9 +771,9 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: %a => constants.%a // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Bar.loc13(constants.%a) { -// CHECK:STDOUT: %a.patt.loc13_16.2 => constants.%a.patt -// CHECK:STDOUT: %a.loc13_16.1 => constants.%a +// CHECK:STDOUT: specific @Bar.loc11(constants.%a) { +// CHECK:STDOUT: %a.patt.loc11_16.2 => constants.%a.patt +// CHECK:STDOUT: %a.loc11_16.1 => constants.%a // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Bar.WithSelf(constants.%a, constants.%Self.3ee) {} @@ -1133,9 +1130,9 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: %a: %C = symbolic_binding a, 0 [symbolic] // CHECK:STDOUT: %Foo.type.bc6a25.1: type = generic_interface_type @Foo.1 [concrete] // CHECK:STDOUT: %Foo.generic.d3ea5a.1: %Foo.type.bc6a25.1 = struct_value () [concrete] -// CHECK:STDOUT: %Foo.type.bc6a25.2: type = generic_interface_type @Foo.loc13 [concrete] +// CHECK:STDOUT: %Foo.type.bc6a25.2: type = generic_interface_type @Foo.loc12 [concrete] // CHECK:STDOUT: %Foo.generic.d3ea5a.2: %Foo.type.bc6a25.2 = struct_value () [concrete] -// CHECK:STDOUT: %Foo.type.137: type = facet_type <@Foo.loc13, @Foo.loc13(%a)> [symbolic] +// CHECK:STDOUT: %Foo.type.137: type = facet_type <@Foo.loc12, @Foo.loc12(%a)> [symbolic] // CHECK:STDOUT: %Self: %Foo.type.137 = symbolic_binding Self, 1 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1157,14 +1154,14 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: %default.import.loc2_30.2 = import // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C] // CHECK:STDOUT: %D: type = alias_binding D, %C.ref [concrete = constants.%C] -// CHECK:STDOUT: %Foo.decl: %Foo.type.bc6a25.2 = interface_decl @Foo.loc13 [concrete = constants.%Foo.generic.d3ea5a.2] { -// CHECK:STDOUT: %a.patt.loc13_16.1: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc13_16.2 (constants.%a.patt)] +// CHECK:STDOUT: %Foo.decl: %Foo.type.bc6a25.2 = interface_decl @Foo.loc12 [concrete = constants.%Foo.generic.d3ea5a.2] { +// CHECK:STDOUT: %a.patt.loc12_16.1: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc12_16.2 (constants.%a.patt)] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc13: type = splice_block %D.ref [concrete = constants.%C] { +// CHECK:STDOUT: %.loc12: type = splice_block %D.ref [concrete = constants.%C] { // CHECK:STDOUT: %.Self.frozen: type = symbolic_binding .Self [symbolic_self = constants.%.Self.frozen] // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D [concrete = constants.%C] // CHECK:STDOUT: } -// CHECK:STDOUT: %a.loc13_16.2: %C = symbolic_binding a, 0 [symbolic = %a.loc13_16.1 (constants.%a)] +// CHECK:STDOUT: %a.loc12_16.2: %C = symbolic_binding a, 0 [symbolic = %a.loc12_16.1 (constants.%a)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1175,20 +1172,20 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: interface; // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic interface @Foo.loc13(%a.loc13_16.2: %C) { -// CHECK:STDOUT: %a.patt.loc13_16.2: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc13_16.2 (constants.%a.patt)] -// CHECK:STDOUT: %a.loc13_16.1: %C = symbolic_binding a, 0 [symbolic = %a.loc13_16.1 (constants.%a)] +// CHECK:STDOUT: generic interface @Foo.loc12(%a.loc12_16.2: %C) { +// CHECK:STDOUT: %a.patt.loc12_16.2: %pattern_type = symbolic_binding_pattern a, 0 [symbolic = %a.patt.loc12_16.2 (constants.%a.patt)] +// CHECK:STDOUT: %a.loc12_16.1: %C = symbolic_binding a, 0 [symbolic = %a.loc12_16.1 (constants.%a)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Foo.type: type = facet_type <@Foo.loc13, @Foo.loc13(%a.loc13_16.1)> [symbolic = %Foo.type (constants.%Foo.type.137)] -// CHECK:STDOUT: %Self.loc13_21.2: @Foo.loc13.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc13_21.2 (constants.%Self)] +// CHECK:STDOUT: %Foo.type: type = facet_type <@Foo.loc12, @Foo.loc12(%a.loc12_16.1)> [symbolic = %Foo.type (constants.%Foo.type.137)] +// CHECK:STDOUT: %Self.loc12_21.2: @Foo.loc12.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc12_21.2 (constants.%Self)] // CHECK:STDOUT: // CHECK:STDOUT: interface { -// CHECK:STDOUT: %Self.loc13_21.1: @Foo.loc13.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc13_21.2 (constants.%Self)] -// CHECK:STDOUT: %Foo.WithSelf.decl = interface_with_self_decl @Foo.loc13 [concrete] +// CHECK:STDOUT: %Self.loc12_21.1: @Foo.loc12.%Foo.type (%Foo.type.137) = symbolic_binding Self, 1 [symbolic = %Self.loc12_21.2 (constants.%Self)] +// CHECK:STDOUT: %Foo.WithSelf.decl = interface_with_self_decl @Foo.loc12 [concrete] // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = %Self.loc13_21.1 +// CHECK:STDOUT: .Self = %Self.loc12_21.1 // CHECK:STDOUT: witness = () // CHECK:STDOUT: // CHECK:STDOUT: !requires: @@ -1207,9 +1204,9 @@ interface Foo(a: const (const C)) {} // CHECK:STDOUT: %a => constants.%a // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Foo.loc13(constants.%a) { -// CHECK:STDOUT: %a.patt.loc13_16.2 => constants.%a.patt -// CHECK:STDOUT: %a.loc13_16.1 => constants.%a +// CHECK:STDOUT: specific @Foo.loc12(constants.%a) { +// CHECK:STDOUT: %a.patt.loc12_16.2 => constants.%a.patt +// CHECK:STDOUT: %a.loc12_16.1 => constants.%a // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Foo.WithSelf(constants.%a, constants.%Self) {} diff --git a/toolchain/check/testdata/interop/cpp/class/import/access.carbon b/toolchain/check/testdata/interop/cpp/class/import/access.carbon index f9c8606724a9..173ea8e3e4b9 100644 --- a/toolchain/check/testdata/interop/cpp/class/import/access.carbon +++ b/toolchain/check/testdata/interop/cpp/class/import/access.carbon @@ -70,8 +70,7 @@ library "[[@TEST_NAME]]"; import Cpp library "non_function_member_protected.h"; fn F(c: Cpp.NonFunctionMemberProtected) { - // CHECK:STDERR: fail_import_non_function_member_protected.carbon:[[@LINE+4]]:35-49: error: cannot access protected member `instance_data` of type `Cpp.NonFunctionMemberProtected` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_non_function_member_protected.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_non_function_member_protected.carbon:[[@LINE+3]]:35-49: error: cannot access protected member `instance_data` of type `Cpp.NonFunctionMemberProtected` [ClassInvalidMemberAccess] // CHECK:STDERR: ./non_function_member_protected.h:2:7: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: let unused instance_data: i32 = c.instance_data; @@ -92,8 +91,7 @@ class Derived { } fn F(d: Derived) { - // CHECK:STDERR: fail_import_non_function_member_protected_extend.carbon:[[@LINE+4]]:35-49: error: cannot access protected member `instance_data` of type `Derived` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_non_function_member_protected_extend.carbon:[[@LINE-8]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_non_function_member_protected_extend.carbon:[[@LINE+3]]:35-49: error: cannot access protected member `instance_data` of type `Derived` [ClassInvalidMemberAccess] // CHECK:STDERR: ./non_function_member_protected.h:2:7: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: let unused instance_data: i32 = d.instance_data; @@ -139,8 +137,7 @@ library "[[@TEST_NAME]]"; import Cpp library "non_function_member_private.h"; fn F(c: Cpp.NonFunctionMemberPrivate) { - // CHECK:STDERR: fail_import_non_function_member_private.carbon:[[@LINE+4]]:35-49: error: cannot access private member `instance_data` of type `Cpp.NonFunctionMemberPrivate` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_non_function_member_private.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_non_function_member_private.carbon:[[@LINE+3]]:35-49: error: cannot access private member `instance_data` of type `Cpp.NonFunctionMemberPrivate` [ClassInvalidMemberAccess] // CHECK:STDERR: ./non_function_member_private.h:2:7: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: let unused instance_data: i32 = c.instance_data; @@ -159,8 +156,7 @@ import Cpp library "non_function_member_private.h"; class Derived { extend base: Cpp.NonFunctionMemberPrivate; fn F(self) { - // CHECK:STDERR: fail_import_non_function_member_private_extend.carbon:[[@LINE+4]]:37-54: error: cannot access private member `instance_data` of type `Cpp.NonFunctionMemberPrivate` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_non_function_member_private_extend.carbon:[[@LINE-6]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_non_function_member_private_extend.carbon:[[@LINE+3]]:37-54: error: cannot access private member `instance_data` of type `Cpp.NonFunctionMemberPrivate` [ClassInvalidMemberAccess] // CHECK:STDERR: ./non_function_member_private.h:2:7: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: let unused instance_data: i32 = self.instance_data; @@ -168,8 +164,7 @@ class Derived { } fn F(d: Derived) { - // CHECK:STDERR: fail_import_non_function_member_private_extend.carbon:[[@LINE+4]]:35-49: error: cannot access private member `instance_data` of type `Cpp.NonFunctionMemberPrivate` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_non_function_member_private_extend.carbon:[[@LINE-15]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_non_function_member_private_extend.carbon:[[@LINE+3]]:35-49: error: cannot access private member `instance_data` of type `Cpp.NonFunctionMemberPrivate` [ClassInvalidMemberAccess] // CHECK:STDERR: ./non_function_member_private.h:2:7: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: let unused instance_data: i32 = d.instance_data; @@ -265,8 +260,7 @@ class Derived { fn F(self) { //@dump-sem-ir-begin // TODO: It should be possible to call protected methods in the base class. - // CHECK:STDERR: fail_todo_import_function_member_protected_extend_call_instance_in_member.carbon:[[@LINE+5]]:5-20: error: no matching function for call to 'instance_fn' [CppInteropParseError] - // CHECK:STDERR: included from: fail_todo_import_function_member_protected_extend_call_instance_in_member.carbon:[[@LINE-8]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_import_function_member_protected_extend_call_instance_in_member.carbon:[[@LINE+4]]:5-20: error: no matching function for call to 'instance_fn' [CppInteropParseError] // CHECK:STDERR: ./function_member_protected.h:4:8: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./function_member_protected.h:4:19-20: note: cannot convert argument of incomplete type 'const Carbon::Main::Derived' to 'FunctionMemberProtected' for object argument [CppInteropParseNoteReason] // CHECK:STDERR: @@ -389,13 +383,11 @@ library "[[@TEST_NAME]]"; import Cpp library "overload_set.h"; fn F() { - // CHECK:STDERR: fail_import_overload_set_protected.carbon:[[@LINE+4]]:3-64: error: cannot access protected member `OverloadSet` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_protected.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_protected.carbon:[[@LINE+3]]:3-64: error: cannot access protected member `OverloadSet` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:11:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Cpp.OverloadSet.OverloadSet(Cpp.ProtectedCall.ProtectedCall()); - // CHECK:STDERR: fail_import_overload_set_protected.carbon:[[@LINE+4]]:3-61: error: cannot access protected member `Overload` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_protected.carbon:[[@LINE-9]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_protected.carbon:[[@LINE+3]]:3-61: error: cannot access protected member `Overload` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:12:15: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Cpp.OverloadSet.Overload(Cpp.ProtectedCall.ProtectedCall()); @@ -442,13 +434,11 @@ library "[[@TEST_NAME]]"; import Cpp library "overload_set.h"; fn F() { - // CHECK:STDERR: fail_import_overload_set_private.carbon:[[@LINE+4]]:3-60: error: cannot access private member `OverloadSet` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_private.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_private.carbon:[[@LINE+3]]:3-60: error: cannot access private member `OverloadSet` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:14:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Cpp.OverloadSet.OverloadSet(Cpp.PrivateCall.PrivateCall()); - // CHECK:STDERR: fail_import_overload_set_private.carbon:[[@LINE+4]]:3-57: error: cannot access private member `Overload` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_private.carbon:[[@LINE-9]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_private.carbon:[[@LINE+3]]:3-57: error: cannot access private member `Overload` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:15:15: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Cpp.OverloadSet.Overload(Cpp.PrivateCall.PrivateCall()); @@ -464,16 +454,14 @@ class D { extend base: Cpp.OverloadSet; fn MakePrivate() -> D { - // CHECK:STDERR: fail_import_overload_set_private_base.carbon:[[@LINE+4]]:21-62: error: cannot access private member `OverloadSet` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_private_base.carbon:[[@LINE-7]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_private_base.carbon:[[@LINE+3]]:21-62: error: cannot access private member `OverloadSet` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:14:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: return {.base = OverloadSet(Cpp.PrivateCall.PrivateCall())}; } fn CallPrivate() { - // CHECK:STDERR: fail_import_overload_set_private_base.carbon:[[@LINE+4]]:5-43: error: cannot access private member `Overload` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_private_base.carbon:[[@LINE-15]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_private_base.carbon:[[@LINE+3]]:5-43: error: cannot access private member `Overload` of type `Cpp.OverloadSet` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:15:15: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Overload(Cpp.PrivateCall.PrivateCall()); @@ -507,15 +495,11 @@ library "[[@TEST_NAME]]"; import Cpp library "overload_set_base_class.h"; fn F() { - // CHECK:STDERR: fail_import_overload_set_public_base_class_call_non_public.carbon:[[@LINE+5]]:3-64: error: cannot access protected member `Overload` of type `Cpp.OverloadPublic` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_public_base_class_call_non_public.carbon:[[@LINE-4]]:10 [InCppInclude] - // CHECK:STDERR: included from: ./overload_set_base_class.h:2:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_public_base_class_call_non_public.carbon:[[@LINE+3]]:3-64: error: cannot access protected member `Overload` of type `Cpp.OverloadPublic` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:12:15: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Cpp.OverloadPublic.Overload(Cpp.ProtectedCall.ProtectedCall()); - // CHECK:STDERR: fail_import_overload_set_public_base_class_call_non_public.carbon:[[@LINE+5]]:3-60: error: cannot access private member `Overload` of type `Cpp.OverloadPublic` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_public_base_class_call_non_public.carbon:[[@LINE-10]]:10 [InCppInclude] - // CHECK:STDERR: included from: ./overload_set_base_class.h:2:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_public_base_class_call_non_public.carbon:[[@LINE+3]]:3-60: error: cannot access private member `Overload` of type `Cpp.OverloadPublic` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:15:15: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Cpp.OverloadPublic.Overload(Cpp.PrivateCall.PrivateCall()); @@ -548,9 +532,7 @@ class Derived { extend base: Cpp.OverloadPublic; fn F() { - // CHECK:STDERR: fail_import_overload_set_public_base_class_derived_call_private.carbon:[[@LINE+5]]:5-43: error: cannot access private member `Overload` of type `Cpp.OverloadPublic` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_public_base_class_derived_call_private.carbon:[[@LINE-7]]:10 [InCppInclude] - // CHECK:STDERR: included from: ./overload_set_base_class.h:2:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_public_base_class_derived_call_private.carbon:[[@LINE+3]]:5-43: error: cannot access private member `Overload` of type `Cpp.OverloadPublic` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:15:15: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Overload(Cpp.PrivateCall.PrivateCall()); @@ -605,9 +587,7 @@ class Derived { extend base: Cpp.OverloadProtected; fn F() { - // CHECK:STDERR: fail_import_overload_set_protected_base_class_derived_call_private.carbon:[[@LINE+5]]:5-43: error: cannot access private member `Overload` of type `Cpp.OverloadProtected` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_import_overload_set_protected_base_class_derived_call_private.carbon:[[@LINE-7]]:10 [InCppInclude] - // CHECK:STDERR: included from: ./overload_set_base_class.h:2:10 [InCppInclude] + // CHECK:STDERR: fail_import_overload_set_protected_base_class_derived_call_private.carbon:[[@LINE+3]]:5-43: error: cannot access private member `Overload` of type `Cpp.OverloadProtected` [ClassInvalidMemberAccess] // CHECK:STDERR: ./overload_set.h:15:15: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: Overload(Cpp.PrivateCall.PrivateCall()); diff --git a/toolchain/check/testdata/interop/cpp/class/import/constructor.carbon b/toolchain/check/testdata/interop/cpp/class/import/constructor.carbon index 91f1b51e315a..bd071449151e 100644 --- a/toolchain/check/testdata/interop/cpp/class/import/constructor.carbon +++ b/toolchain/check/testdata/interop/cpp/class/import/constructor.carbon @@ -208,13 +208,11 @@ library "[[@TEST_NAME]]"; import Cpp library "deleted.h"; fn F() { - // CHECK:STDERR: fail_import_deleted.carbon:[[@LINE+4]]:32-52: error: call to deleted function 'DeletedC' [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_deleted.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_deleted.carbon:[[@LINE+3]]:32-52: error: call to deleted function 'DeletedC' [CppInteropParseError] // CHECK:STDERR: ./deleted.h:4:3: note: candidate constructor has been explicitly deleted [CppInteropParseNote] // CHECK:STDERR: let unused c: Cpp.DeletedC = Cpp.DeletedC.DeletedC(); - // CHECK:STDERR: fail_import_deleted.carbon:[[@LINE+5]]:32-52: error: call to deleted function 'DeletedD' [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_deleted.carbon:[[@LINE-9]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_deleted.carbon:[[@LINE+4]]:32-52: error: call to deleted function 'DeletedD' [CppInteropParseError] // CHECK:STDERR: ./deleted.h:9:3: note: candidate constructor has been explicitly deleted [CppInteropParseNote] // CHECK:STDERR: ./deleted.h:10:3: note: candidate constructor [CppInteropParseNote] // CHECK:STDERR: diff --git a/toolchain/check/testdata/interop/cpp/class/import/method.carbon b/toolchain/check/testdata/interop/cpp/class/import/method.carbon index 53b3e65fafe8..69f739d0724f 100644 --- a/toolchain/check/testdata/interop/cpp/class/import/method.carbon +++ b/toolchain/check/testdata/interop/cpp/class/import/method.carbon @@ -59,27 +59,23 @@ library "[[@TEST_NAME]]"; import Cpp library "object_param_qualifiers.h"; fn Value(v: Cpp.HasQualifiers) { - // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+4]]:3-9: error: no matching function for call to 'plain' [CppInteropParseError] - // CHECK:STDERR: included from: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+3]]:3-9: error: no matching function for call to 'plain' [CppInteropParseError] // CHECK:STDERR: ./object_param_qualifiers.h:3:8: note: candidate function not viable: 'this' argument has type 'const HasQualifiers', but method is not marked const [CppInteropParseNote] // CHECK:STDERR: v.plain(); // TODO: This should remain invalid once we support `volatile`. - // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'volatile_this' [CppInteropParseError] - // CHECK:STDERR: included from: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE-11]]:10 [InCppInclude] + // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+3]]:3-17: error: no matching function for call to 'volatile_this' [CppInteropParseError] // CHECK:STDERR: ./object_param_qualifiers.h:5:8: note: candidate function not viable: 'this' argument has type 'const HasQualifiers', but method is not marked const [CppInteropParseNote] // CHECK:STDERR: v.volatile_this(); - // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+4]]:3-12: error: no matching function for call to 'ref_this' [CppInteropParseError] - // CHECK:STDERR: included from: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE-17]]:10 [InCppInclude] + // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+3]]:3-12: error: no matching function for call to 'ref_this' [CppInteropParseError] // CHECK:STDERR: ./object_param_qualifiers.h:7:8: note: candidate function not viable: 'this' argument has type 'const HasQualifiers', but method is not marked const [CppInteropParseNote] // CHECK:STDERR: v.ref_this(); - // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+4]]:3-16: error: no matching function for call to 'ref_ref_this' [CppInteropParseError] - // CHECK:STDERR: included from: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE-23]]:10 [InCppInclude] + // CHECK:STDERR: fail_bad_object_param_qualifiers_by_value.carbon:[[@LINE+3]]:3-16: error: no matching function for call to 'ref_ref_this' [CppInteropParseError] // CHECK:STDERR: ./object_param_qualifiers.h:10:8: note: candidate function not viable: 'this' argument has type 'const HasQualifiers', but method is not marked const [CppInteropParseNote] // CHECK:STDERR: v.ref_ref_this(); @@ -105,15 +101,13 @@ library "[[@TEST_NAME]]"; import Cpp library "object_param_qualifiers.h"; fn Ref(p: Cpp.HasQualifiers*) { - // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'ref_ref_this' [CppInteropParseError] - // CHECK:STDERR: included from: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'ref_ref_this' [CppInteropParseError] // CHECK:STDERR: ./object_param_qualifiers.h:10:8: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./object_param_qualifiers.h:10:20-21: note: expects an rvalue for object argument [CppInteropParseNoteReason] // CHECK:STDERR: p->ref_ref_this(); - // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE+5]]:3-23: error: no matching function for call to 'const_ref_ref_this' [CppInteropParseError] - // CHECK:STDERR: included from: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE-11]]:10 [InCppInclude] + // CHECK:STDERR: fail_bad_object_param_qualifiers_ref_ref.carbon:[[@LINE+4]]:3-23: error: no matching function for call to 'const_ref_ref_this' [CppInteropParseError] // CHECK:STDERR: ./object_param_qualifiers.h:11:8: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./object_param_qualifiers.h:11:26-27: note: expects an rvalue for object argument [CppInteropParseNoteReason] // CHECK:STDERR: @@ -129,8 +123,7 @@ import Cpp library "object_param_qualifiers.h"; fn Make() -> Cpp.HasQualifiers; fn F() { - // CHECK:STDERR: fail_bad_object_param_qualifiers_for_temporary.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'ref_this' [CppInteropParseError] - // CHECK:STDERR: included from: fail_bad_object_param_qualifiers_for_temporary.carbon:[[@LINE-6]]:10 [InCppInclude] + // CHECK:STDERR: fail_bad_object_param_qualifiers_for_temporary.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'ref_this' [CppInteropParseError] // CHECK:STDERR: ./object_param_qualifiers.h:7:8: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./object_param_qualifiers.h:7:16-17: note: expects an lvalue for object argument [CppInteropParseNoteReason] // CHECK:STDERR: diff --git a/toolchain/check/testdata/interop/cpp/class/import/override.carbon b/toolchain/check/testdata/interop/cpp/class/import/override.carbon index 54b90e350129..f957c7dc0cf8 100644 --- a/toolchain/check/testdata/interop/cpp/class/import/override.carbon +++ b/toolchain/check/testdata/interop/cpp/class/import/override.carbon @@ -41,8 +41,7 @@ import Cpp library "overload.h"; class Overload0Params { extend base: Cpp.OverloadedBase; // - // CHECK:STDERR: fail_overload_no_matching_arity.carbon:[[@LINE+6]]:3-22: error: override without compatible virtual in base class [OverrideWithoutVirtualInBase] - // CHECK:STDERR: included from: fail_overload_no_matching_arity.carbon:[[@LINE-6]]:10 [InCppInclude] + // CHECK:STDERR: fail_overload_no_matching_arity.carbon:[[@LINE+5]]:3-22: error: override without compatible virtual in base class [OverrideWithoutVirtualInBase] // CHECK:STDERR: ./overload.h:6:16: note: base class function has more parameters (1 vs 0 excluding `self`) [OverrideCandidateArityMismatch] // CHECK:STDERR: ./overload.h:7:16: note: base class function has more parameters (1 vs 0 excluding `self`) [OverrideCandidateArityMismatch] // CHECK:STDERR: ./overload.h:8:16: note: base class function has more parameters (2 vs 0 excluding `self`) [OverrideCandidateArityMismatch] @@ -53,8 +52,7 @@ class Overload0Params { class Overload3Params { extend base: Cpp.OverloadedBase; // - // CHECK:STDERR: fail_overload_no_matching_arity.carbon:[[@LINE+6]]:3-52: error: override without compatible virtual in base class [OverrideWithoutVirtualInBase] - // CHECK:STDERR: included from: fail_overload_no_matching_arity.carbon:[[@LINE-18]]:10 [InCppInclude] + // CHECK:STDERR: fail_overload_no_matching_arity.carbon:[[@LINE+5]]:3-52: error: override without compatible virtual in base class [OverrideWithoutVirtualInBase] // CHECK:STDERR: ./overload.h:6:16: note: base class function has fewer parameters (1 vs 3 excluding `self`) [OverrideCandidateArityMismatch] // CHECK:STDERR: ./overload.h:7:16: note: base class function has fewer parameters (1 vs 3 excluding `self`) [OverrideCandidateArityMismatch] // CHECK:STDERR: ./overload.h:8:16: note: base class function has fewer parameters (2 vs 3 excluding `self`) [OverrideCandidateArityMismatch] @@ -72,14 +70,13 @@ import Cpp library "overload.h"; class OverloadX { extend base: Cpp.OverloadedBase; // - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+10]]:3-32: error: cannot implicitly convert expression of type `Cpp.Y` to `Cpp.X` [ConversionFailure] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+9]]:3-32: note: type `Cpp.Y` does not implement interface `Core.ImplicitAs(Cpp.X)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+8]]:23-30: note: initializing function parameter [InCallToFunctionParam] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+9]]:3-32: error: cannot implicitly convert expression of type `Cpp.Y` to `Cpp.X` [ConversionFailure] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+8]]:3-32: note: type `Cpp.Y` does not implement interface `Core.ImplicitAs(Cpp.X)` [MissingImplInMemberAccessInContext] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+7]]:23-30: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+6]]:3-32: error: cannot implicitly convert expression of type `Cpp.Y` to `Cpp.X` [ConversionFailure] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+5]]:3-32: note: type `Cpp.Y` does not implement interface `Core.ImplicitAs(Cpp.X)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+4]]:23-30: note: initializing function parameter [InCallToFunctionParam] - // CHECK:STDERR: included from: fail_overload_type.carbon:[[@LINE-12]]:10 [InCppInclude] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+5]]:3-32: error: cannot implicitly convert expression of type `Cpp.Y` to `Cpp.X` [ConversionFailure] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+4]]:3-32: note: type `Cpp.Y` does not implement interface `Core.ImplicitAs(Cpp.X)` [MissingImplInMemberAccessInContext] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+3]]:23-30: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: ./overload.h:7:16: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: override fn f(self, x: Cpp.X); @@ -88,14 +85,13 @@ class OverloadX { class OverloadY { extend base: Cpp.OverloadedBase; // - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+10]]:3-32: error: cannot implicitly convert expression of type `Cpp.X` to `Cpp.Y` [ConversionFailure] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+9]]:3-32: note: type `Cpp.X` does not implement interface `Core.ImplicitAs(Cpp.Y)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+8]]:23-30: note: initializing function parameter [InCallToFunctionParam] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+9]]:3-32: error: cannot implicitly convert expression of type `Cpp.X` to `Cpp.Y` [ConversionFailure] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+8]]:3-32: note: type `Cpp.X` does not implement interface `Core.ImplicitAs(Cpp.Y)` [MissingImplInMemberAccessInContext] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+7]]:23-30: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+6]]:3-32: error: cannot implicitly convert expression of type `Cpp.X` to `Cpp.Y` [ConversionFailure] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+5]]:3-32: note: type `Cpp.X` does not implement interface `Core.ImplicitAs(Cpp.Y)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+4]]:23-30: note: initializing function parameter [InCallToFunctionParam] - // CHECK:STDERR: included from: fail_overload_type.carbon:[[@LINE-28]]:10 [InCppInclude] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+5]]:3-32: error: cannot implicitly convert expression of type `Cpp.X` to `Cpp.Y` [ConversionFailure] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+4]]:3-32: note: type `Cpp.X` does not implement interface `Core.ImplicitAs(Cpp.Y)` [MissingImplInMemberAccessInContext] + // CHECK:STDERR: fail_overload_type.carbon:[[@LINE+3]]:23-30: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: ./overload.h:6:16: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: override fn f(self, y: Cpp.Y); diff --git a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon index 8d01c5461cde..4bdc4aa4c630 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_bridged.carbon @@ -234,8 +234,7 @@ library "[[@TEST_NAME]]"; import Cpp library "short_param.h"; fn F() { - // CHECK:STDERR: fail_import_short_param_overflow_max.carbon:[[@LINE+4]]:11-16: error: integer value 32768 too large for type `i16` [IntTooLargeForType] - // CHECK:STDERR: included from: fail_import_short_param_overflow_max.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_short_param_overflow_max.carbon:[[@LINE+3]]:11-16: error: integer value 32768 too large for type `i16` [IntTooLargeForType] // CHECK:STDERR: ./short_param.h:2:16: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.foo(0x8000); @@ -260,8 +259,7 @@ library "[[@TEST_NAME]]"; import Cpp library "short_param.h"; fn F() { - // CHECK:STDERR: fail_import_short_param_overflow_min.carbon:[[@LINE+4]]:11-17: error: integer value -32769 too large for type `i16` [IntTooLargeForType] - // CHECK:STDERR: included from: fail_import_short_param_overflow_min.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_short_param_overflow_min.carbon:[[@LINE+3]]:11-17: error: integer value -32769 too large for type `i16` [IntTooLargeForType] // CHECK:STDERR: ./short_param.h:2:16: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.foo(-0x8001); @@ -274,9 +272,8 @@ library "[[@TEST_NAME]]"; import Cpp library "short_param.h"; fn F() { - // CHECK:STDERR: fail_import_short_param_int32_arg.carbon:[[@LINE+5]]:11-18: error: cannot implicitly convert expression of type `i32` to `i16` [ConversionFailure] - // CHECK:STDERR: fail_import_short_param_int32_arg.carbon:[[@LINE+4]]:11-18: note: type `i32` does not implement interface `Core.ImplicitAs(i16)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_import_short_param_int32_arg.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_short_param_int32_arg.carbon:[[@LINE+4]]:11-18: error: cannot implicitly convert expression of type `i32` to `i16` [ConversionFailure] + // CHECK:STDERR: fail_import_short_param_int32_arg.carbon:[[@LINE+3]]:11-18: note: type `i32` does not implement interface `Core.ImplicitAs(i16)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./short_param.h:2:16: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.foo(1 as i32); diff --git a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_direct.carbon b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_direct.carbon index 661dd6418479..3165426e2d89 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_direct.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/arithmetic_types_direct.carbon @@ -54,8 +54,7 @@ library "[[@TEST_NAME]]"; import Cpp library "int_param.h"; fn F() { - // CHECK:STDERR: fail_import_int_param_overflow_max.carbon:[[@LINE+4]]:11-21: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType] - // CHECK:STDERR: included from: fail_import_int_param_overflow_max.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_int_param_overflow_max.carbon:[[@LINE+3]]:11-21: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType] // CHECK:STDERR: ./int_param.h:2:14: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.foo(0x8000_0000); @@ -80,8 +79,7 @@ library "[[@TEST_NAME]]"; import Cpp library "int_param.h"; fn F() { - // CHECK:STDERR: fail_import_int_param_overflow_min.carbon:[[@LINE+4]]:11-22: error: integer value -2147483649 too large for type `i32` [IntTooLargeForType] - // CHECK:STDERR: included from: fail_import_int_param_overflow_min.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_int_param_overflow_min.carbon:[[@LINE+3]]:11-22: error: integer value -2147483649 too large for type `i32` [IntTooLargeForType] // CHECK:STDERR: ./int_param.h:2:14: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.foo(-0x8000_0001); @@ -156,16 +154,14 @@ import Cpp library "unsigned_int_param.h"; fn F() { Cpp.foo(0); - // CHECK:STDERR: fail_import_unsigned_int_param_overflow.carbon:[[@LINE+4]]:11-12: error: negative integer value -1 converted to unsigned type `u32` [NegativeIntInUnsignedType] - // CHECK:STDERR: included from: fail_import_unsigned_int_param_overflow.carbon:[[@LINE-6]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_unsigned_int_param_overflow.carbon:[[@LINE+3]]:11-12: error: negative integer value -1 converted to unsigned type `u32` [NegativeIntInUnsignedType] // CHECK:STDERR: ./unsigned_int_param.h:2:23: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.foo(-1); Cpp.foo(0x0_FFFF_FFFF); - // CHECK:STDERR: fail_import_unsigned_int_param_overflow.carbon:[[@LINE+4]]:11-23: error: integer value 4294967296 too large for type `u32` [IntTooLargeForType] - // CHECK:STDERR: included from: fail_import_unsigned_int_param_overflow.carbon:[[@LINE-14]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_unsigned_int_param_overflow.carbon:[[@LINE+3]]:11-23: error: integer value 4294967296 too large for type `u32` [IntTooLargeForType] // CHECK:STDERR: ./unsigned_int_param.h:2:23: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.foo(0x1_0000_0000); diff --git a/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon b/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon index 6a14f3caf642..9604384803f3 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/decayed_param.carbon @@ -51,16 +51,14 @@ fn F() { Cpp.TakesFunction(Cpp.Function); var n: array(i32, 42); - // CHECK:STDERR: fail_todo_call_params_2.carbon:[[@LINE+5]]:3-19: error: no matching function for call to 'TakesFunction' [CppInteropParseError] - // CHECK:STDERR: included from: fail_todo_call_params_2.carbon:[[@LINE-12]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_call_params_2.carbon:[[@LINE+4]]:3-19: error: no matching function for call to 'TakesFunction' [CppInteropParseError] // CHECK:STDERR: ./params.h:3:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./params.h:3:20-29: note: no known conversion from 'int * _Nonnull' to 'int (*)(int)' for 1st argument [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.TakesFunction(&n[0]); - // CHECK:STDERR: fail_todo_call_params_2.carbon:[[@LINE+5]]:21-31: error: cannot implicitly convert expression of type `Cpp.nullptr_t` to `` [ConversionFailure] - // CHECK:STDERR: fail_todo_call_params_2.carbon:[[@LINE+4]]:21-31: note: type `Cpp.nullptr_t` does not implement interface `Core.ImplicitAs()` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_todo_call_params_2.carbon:[[@LINE-20]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_call_params_2.carbon:[[@LINE+4]]:21-31: error: cannot implicitly convert expression of type `Cpp.nullptr_t` to `` [ConversionFailure] + // CHECK:STDERR: fail_todo_call_params_2.carbon:[[@LINE+3]]:21-31: note: type `Cpp.nullptr_t` does not implement interface `Core.ImplicitAs()` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./params.h:3:24: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.TakesFunction(Cpp.nullptr); @@ -876,25 +874,25 @@ fn F() { // CHECK:STDOUT: %n.patt: %pattern_type.9c3 = ref_binding_pattern n [concrete = constants.%n.patt.368] // CHECK:STDOUT: %n.var_patt: %pattern_type.9c3 = var_pattern %n.patt [concrete = constants.%n.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc20: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesFunction.ref.loc20: %TakesFunction.cpp_overload_set.type = name_ref TakesFunction, imports.%TakesFunction.cpp_overload_set.value [concrete = constants.%TakesFunction.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc19: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesFunction.ref.loc19: %TakesFunction.cpp_overload_set.type = name_ref TakesFunction, imports.%TakesFunction.cpp_overload_set.value [concrete = constants.%TakesFunction.cpp_overload_set.value] // CHECK:STDOUT: %n.ref: ref %Array.3b5 = name_ref n, %n // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] // CHECK:STDOUT: %impl.elem0: %.33a = impl_witness_access constants.%ImplicitAs.impl_witness.d73, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f60] -// CHECK:STDOUT: %bound_method.loc20_24.1: = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] +// CHECK:STDOUT: %bound_method.loc19_24.1: = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound] // CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc20_24.2: = bound_method %int_0, %specific_fn [concrete = constants.%bound_method] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc20_24.2(%int_0) [concrete = constants.%int_0.753] -// CHECK:STDOUT: %.loc20_24.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.753] -// CHECK:STDOUT: %.loc20_24.2: %i32 = converted %int_0, %.loc20_24.1 [concrete = constants.%int_0.753] -// CHECK:STDOUT: %.loc20_25: ref %i32 = array_index %n.ref, %.loc20_24.2 -// CHECK:STDOUT: %addr: %ptr.a17 = addr_of %.loc20_25 -// CHECK:STDOUT: %Cpp.ref.loc27_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesFunction.ref.loc27: %TakesFunction.cpp_overload_set.type = name_ref TakesFunction, imports.%TakesFunction.cpp_overload_set.value [concrete = constants.%TakesFunction.cpp_overload_set.value] -// CHECK:STDOUT: %Cpp.ref.loc27_21: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %bound_method.loc19_24.2: = bound_method %int_0, %specific_fn [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc19_24.2(%int_0) [concrete = constants.%int_0.753] +// CHECK:STDOUT: %.loc19_24.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.753] +// CHECK:STDOUT: %.loc19_24.2: %i32 = converted %int_0, %.loc19_24.1 [concrete = constants.%int_0.753] +// CHECK:STDOUT: %.loc19_25: ref %i32 = array_index %n.ref, %.loc19_24.2 +// CHECK:STDOUT: %addr: %ptr.a17 = addr_of %.loc19_25 +// CHECK:STDOUT: %Cpp.ref.loc25_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesFunction.ref.loc25: %TakesFunction.cpp_overload_set.type = name_ref TakesFunction, imports.%TakesFunction.cpp_overload_set.value [concrete = constants.%TakesFunction.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc25_21: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: // CHECK:STDOUT: %nullptr.ref: %Cpp.nullptr_t = name_ref nullptr, %uninit [concrete = constants.%uninit] -// CHECK:STDOUT: %.loc27: %.659 = converted %nullptr.ref, [concrete = ] +// CHECK:STDOUT: %.loc25: %.659 = converted %nullptr.ref, [concrete = ] // CHECK:STDOUT: %TakesFunction.call: init %empty_tuple.type = call imports.%TakesFunction.decl() // CHECK:STDOUT: %Destroy.facet.loc14_3.1: %Destroy.type = facet_value constants.%Array.3b5, (constants.%DestroyImpl.impl_witness.be3, constants.%custom_witness.b80ef6.3) [concrete = constants.%Destroy.facet.843] // CHECK:STDOUT: %.loc14_3.2: %Destroy.type = converted constants.%Array.3b5, %Destroy.facet.loc14_3.1 [concrete = constants.%Destroy.facet.843] diff --git a/toolchain/check/testdata/interop/cpp/function/import/default_arg.carbon b/toolchain/check/testdata/interop/cpp/function/import/default_arg.carbon index 8e7b4f43728c..aba3822ead59 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/default_arg.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/default_arg.carbon @@ -63,50 +63,43 @@ import Cpp library "functions.h"; fn Call() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+5]]:3-20: error: no matching function for call to 'GlobalNoReturn' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_too_few_args.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+4]]:3-20: error: no matching function for call to 'GlobalNoReturn' [CppInteropParseError] // CHECK:STDERR: ./functions.h:2:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./functions.h:2:21-54: note: requires at least 2 arguments, but 1 was provided [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.GlobalNoReturn(1); - // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+5]]:3-20: error: no matching function for call to 'GlobalNoReturn' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_too_few_args.carbon:[[@LINE-12]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+4]]:3-20: error: no matching function for call to 'GlobalNoReturn' [CppInteropParseError] // CHECK:STDERR: ./functions.h:2:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./functions.h:2:21-54: note: requires at least 2 arguments, but 0 were provided [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.GlobalNoReturn(); - // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+5]]:3-21: error: no matching function for call to 'GlobalReturnInt' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_too_few_args.carbon:[[@LINE-19]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+4]]:3-21: error: no matching function for call to 'GlobalReturnInt' [CppInteropParseError] // CHECK:STDERR: ./functions.h:3:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./functions.h:3:22-55: note: requires at least 2 arguments, but 1 was provided [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.GlobalReturnInt(1); - // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+5]]:3-21: error: no matching function for call to 'GlobalReturnInt' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_too_few_args.carbon:[[@LINE-26]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+4]]:3-21: error: no matching function for call to 'GlobalReturnInt' [CppInteropParseError] // CHECK:STDERR: ./functions.h:3:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./functions.h:3:22-55: note: requires at least 2 arguments, but 0 were provided [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.GlobalReturnInt(); - // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'B' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_too_few_args.carbon:[[@LINE-33]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'B' [CppInteropParseError] // CHECK:STDERR: ./functions.h:6:8: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./functions.h:6:10-25: note: requires at least argument 'a', but no arguments were provided [CppInteropParseNoteReason] // CHECK:STDERR: ({} as Cpp.X).B(); - // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+5]]:3-9: error: no matching function for call to 'C' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_too_few_args.carbon:[[@LINE-40]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+4]]:3-9: error: no matching function for call to 'C' [CppInteropParseError] // CHECK:STDERR: ./functions.h:7:15: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./functions.h:7:17-32: note: requires at least argument 'a', but no arguments were provided [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.X.C(); - // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'D' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_too_few_args.carbon:[[@LINE-47]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_too_few_args.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'D' [CppInteropParseError] // CHECK:STDERR: ./functions.h:8:8: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./functions.h:8:10-33: note: requires at least non-object argument 'a', but no arguments were provided [CppInteropParseNoteReason] // CHECK:STDERR: @@ -928,49 +921,49 @@ fn Call() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Call() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %Cpp.ref.loc13: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %GlobalNoReturn.ref.loc13: %GlobalNoReturn.cpp_overload_set.type = name_ref GlobalNoReturn, imports.%GlobalNoReturn.cpp_overload_set.value [concrete = constants.%GlobalNoReturn.cpp_overload_set.value] -// CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %Cpp.ref.loc20: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %GlobalNoReturn.ref.loc20: %GlobalNoReturn.cpp_overload_set.type = name_ref GlobalNoReturn, imports.%GlobalNoReturn.cpp_overload_set.value [concrete = constants.%GlobalNoReturn.cpp_overload_set.value] -// CHECK:STDOUT: %Cpp.ref.loc27: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %GlobalReturnInt.ref.loc27: %GlobalReturnInt.cpp_overload_set.type = name_ref GlobalReturnInt, imports.%GlobalReturnInt.cpp_overload_set.value [concrete = constants.%GlobalReturnInt.cpp_overload_set.value] -// CHECK:STDOUT: %int_1.loc27: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] -// CHECK:STDOUT: %Cpp.ref.loc34: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %GlobalReturnInt.ref.loc34: %GlobalReturnInt.cpp_overload_set.type = name_ref GlobalReturnInt, imports.%GlobalReturnInt.cpp_overload_set.value [concrete = constants.%GlobalReturnInt.cpp_overload_set.value] -// CHECK:STDOUT: %.loc41_5.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] -// CHECK:STDOUT: %Cpp.ref.loc41: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %X.ref.loc41: type = name_ref X, imports.%X.decl [concrete = constants.%X] -// CHECK:STDOUT: %.loc41_5.2: ref %X = temporary_storage -// CHECK:STDOUT: %.loc41_5.3: init %X to %.loc41_5.2 = class_init () [concrete = constants.%X.val] -// CHECK:STDOUT: %.loc41_7.1: init %X = converted %.loc41_5.1, %.loc41_5.3 [concrete = constants.%X.val] -// CHECK:STDOUT: %.loc41_7.2: ref %X = temporary %.loc41_5.2, %.loc41_7.1 [concrete = constants.%.414] +// CHECK:STDOUT: %Cpp.ref.loc12: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %GlobalNoReturn.ref.loc12: %GlobalNoReturn.cpp_overload_set.type = name_ref GlobalNoReturn, imports.%GlobalNoReturn.cpp_overload_set.value [concrete = constants.%GlobalNoReturn.cpp_overload_set.value] +// CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %Cpp.ref.loc18: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %GlobalNoReturn.ref.loc18: %GlobalNoReturn.cpp_overload_set.type = name_ref GlobalNoReturn, imports.%GlobalNoReturn.cpp_overload_set.value [concrete = constants.%GlobalNoReturn.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc24: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %GlobalReturnInt.ref.loc24: %GlobalReturnInt.cpp_overload_set.type = name_ref GlobalReturnInt, imports.%GlobalReturnInt.cpp_overload_set.value [concrete = constants.%GlobalReturnInt.cpp_overload_set.value] +// CHECK:STDOUT: %int_1.loc24: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] +// CHECK:STDOUT: %Cpp.ref.loc30: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %GlobalReturnInt.ref.loc30: %GlobalReturnInt.cpp_overload_set.type = name_ref GlobalReturnInt, imports.%GlobalReturnInt.cpp_overload_set.value [concrete = constants.%GlobalReturnInt.cpp_overload_set.value] +// CHECK:STDOUT: %.loc36_5.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] +// CHECK:STDOUT: %Cpp.ref.loc36: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %X.ref.loc36: type = name_ref X, imports.%X.decl [concrete = constants.%X] +// CHECK:STDOUT: %.loc36_5.2: ref %X = temporary_storage +// CHECK:STDOUT: %.loc36_5.3: init %X to %.loc36_5.2 = class_init () [concrete = constants.%X.val] +// CHECK:STDOUT: %.loc36_7.1: init %X = converted %.loc36_5.1, %.loc36_5.3 [concrete = constants.%X.val] +// CHECK:STDOUT: %.loc36_7.2: ref %X = temporary %.loc36_5.2, %.loc36_7.1 [concrete = constants.%.414] // CHECK:STDOUT: %B.ref: %X.B.cpp_overload_set.type = name_ref B, imports.%X.B.cpp_overload_set.value [concrete = constants.%X.B.cpp_overload_set.value] -// CHECK:STDOUT: %bound_method.loc41: = bound_method %.loc41_7.2, %B.ref [concrete = constants.%bound_method.f8c] -// CHECK:STDOUT: %Destroy.facet.loc41_7.1: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %.loc41_7.3: %Destroy.type = converted constants.%X, %Destroy.facet.loc41_7.1 [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %Destroy.facet.loc41_7.2: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %.loc41_7.4: %Destroy.type = converted constants.%X, %Destroy.facet.loc41_7.2 [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %bound_method.loc36: = bound_method %.loc36_7.2, %B.ref [concrete = constants.%bound_method.f8c] +// CHECK:STDOUT: %Destroy.facet.loc36_7.1: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %.loc36_7.3: %Destroy.type = converted constants.%X, %Destroy.facet.loc36_7.1 [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %Destroy.facet.loc36_7.2: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %.loc36_7.4: %Destroy.type = converted constants.%X, %Destroy.facet.loc36_7.2 [concrete = constants.%Destroy.facet] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call.loc41: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%.loc41_7.2) +// CHECK:STDOUT: %SelfDestruct.call.loc36: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%.loc36_7.2) +// CHECK:STDOUT: %Cpp.ref.loc42: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %X.ref.loc42: type = name_ref X, imports.%X.decl [concrete = constants.%X] +// CHECK:STDOUT: %C.ref: %X.C.cpp_overload_set.type = name_ref C, imports.%X.C.cpp_overload_set.value [concrete = constants.%X.C.cpp_overload_set.value] +// CHECK:STDOUT: %.loc48_5.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] // CHECK:STDOUT: %Cpp.ref.loc48: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %X.ref.loc48: type = name_ref X, imports.%X.decl [concrete = constants.%X] -// CHECK:STDOUT: %C.ref: %X.C.cpp_overload_set.type = name_ref C, imports.%X.C.cpp_overload_set.value [concrete = constants.%X.C.cpp_overload_set.value] -// CHECK:STDOUT: %.loc55_5.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct] -// CHECK:STDOUT: %Cpp.ref.loc55: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %X.ref.loc55: type = name_ref X, imports.%X.decl [concrete = constants.%X] -// CHECK:STDOUT: %.loc55_5.2: ref %X = temporary_storage -// CHECK:STDOUT: %.loc55_5.3: init %X to %.loc55_5.2 = class_init () [concrete = constants.%X.val] -// CHECK:STDOUT: %.loc55_7.1: init %X = converted %.loc55_5.1, %.loc55_5.3 [concrete = constants.%X.val] -// CHECK:STDOUT: %.loc55_7.2: ref %X = temporary %.loc55_5.2, %.loc55_7.1 [concrete = constants.%.414] +// CHECK:STDOUT: %.loc48_5.2: ref %X = temporary_storage +// CHECK:STDOUT: %.loc48_5.3: init %X to %.loc48_5.2 = class_init () [concrete = constants.%X.val] +// CHECK:STDOUT: %.loc48_7.1: init %X = converted %.loc48_5.1, %.loc48_5.3 [concrete = constants.%X.val] +// CHECK:STDOUT: %.loc48_7.2: ref %X = temporary %.loc48_5.2, %.loc48_7.1 [concrete = constants.%.414] // CHECK:STDOUT: %D.ref: %X.D.cpp_overload_set.type = name_ref D, imports.%X.D.cpp_overload_set.value [concrete = constants.%X.D.cpp_overload_set.value] -// CHECK:STDOUT: %bound_method.loc55: = bound_method %.loc55_7.2, %D.ref [concrete = constants.%bound_method.9a8] -// CHECK:STDOUT: %Destroy.facet.loc55_7.1: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %.loc55_7.3: %Destroy.type = converted constants.%X, %Destroy.facet.loc55_7.1 [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %Destroy.facet.loc55_7.2: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %.loc55_7.4: %Destroy.type = converted constants.%X, %Destroy.facet.loc55_7.2 [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %bound_method.loc48: = bound_method %.loc48_7.2, %D.ref [concrete = constants.%bound_method.9a8] +// CHECK:STDOUT: %Destroy.facet.loc48_7.1: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %.loc48_7.3: %Destroy.type = converted constants.%X, %Destroy.facet.loc48_7.1 [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %Destroy.facet.loc48_7.2: %Destroy.type = facet_value constants.%X, (constants.%DestroyImpl.impl_witness.a05, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %.loc48_7.4: %Destroy.type = converted constants.%X, %Destroy.facet.loc48_7.2 [concrete = constants.%Destroy.facet] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call.loc55: init %empty_tuple.type = call %SelfDestruct.specific_fn.2(%.loc55_7.2) +// CHECK:STDOUT: %SelfDestruct.call.loc48: init %empty_tuple.type = call %SelfDestruct.specific_fn.2(%.loc48_7.2) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/function/import/function.carbon b/toolchain/check/testdata/interop/cpp/function/import/function.carbon index ac1a92da5467..8cdb1e5f1283 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/function.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/function.carbon @@ -81,8 +81,7 @@ library "[[@TEST_NAME]]"; import Cpp library "special_name.h"; fn MyF() { - // CHECK:STDERR: fail_import_special_name_call_escaped_no_match.carbon:[[@LINE+5]]:3-12: error: no matching function for call to 'base' [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_special_name_call_escaped_no_match.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_special_name_call_escaped_no_match.carbon:[[@LINE+4]]:3-12: error: no matching function for call to 'base' [CppInteropParseError] // CHECK:STDERR: ./special_name.h:2:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./special_name.h:2:10-11: note: requires 0 arguments, but 1 was provided [CppInteropParseNoteReason] // CHECK:STDERR: diff --git a/toolchain/check/testdata/interop/cpp/function/import/function_ptr.carbon b/toolchain/check/testdata/interop/cpp/function/import/function_ptr.carbon index 6ac3f3e64bc6..57f6917183f7 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/function_ptr.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/function_ptr.carbon @@ -126,6 +126,8 @@ fn F() { // --- forward_decl.h +// CHECK:STDERR: error: calling function with incomplete return type 'Incomplete' [CppInteropParseError] +// CHECK:STDERR: ./forward_decl.h:[[@LINE+1]]:7: note: forward declaration of 'Incomplete' [CppInteropParseNote] class Incomplete; using CallbackType = Incomplete (*)(); @@ -146,9 +148,6 @@ fn F() { // --- fail_use_forward_decl.carbon library "[[@TEST_NAME]]"; -// CHECK:STDERR: error: calling function with incomplete return type 'Incomplete' [CppInteropParseError] -// CHECK:STDERR: included from: fail_use_forward_decl.carbon:[[@LINE+2]]:10 [InCppInclude] -// CHECK:STDERR: ./forward_decl.h:2:7: note: forward declaration of 'Incomplete' [CppInteropParseNote] import Cpp library "forward_decl.h"; fn F() { @@ -156,7 +155,7 @@ fn F() { // CHECK:STDERR: // CHECK:STDERR: fail_use_forward_decl.carbon:[[@LINE+5]]:3-24: error: function returns incomplete type `Cpp.Incomplete` [IncompleteTypeInFunctionReturnType] // CHECK:STDERR: included from: fail_use_forward_decl.carbon:[[@LINE-6]]:10 [InCppInclude] - // CHECK:STDERR: ./forward_decl.h:2:7: note: class was forward declared here [ClassForwardDeclaredHere] + // CHECK:STDERR: ./forward_decl.h:4:7: note: class was forward declared here [ClassForwardDeclaredHere] // CHECK:STDERR: note: return type declared here [IncompleteReturnTypeHere] // CHECK:STDERR: Cpp.ReturnCallback()(); diff --git a/toolchain/check/testdata/interop/cpp/function/import/overloads.carbon b/toolchain/check/testdata/interop/cpp/function/import/overloads.carbon index e7926c11fd13..f8ceebfb848b 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/overloads.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/overloads.carbon @@ -174,8 +174,7 @@ library "[[@TEST_NAME]]"; import Cpp library "negative_literal_passed_to_unsigned.h"; fn F() { - // CHECK:STDERR: fail_import_negative_literal_passed_to_unsigned.carbon:[[@LINE+4]]:27-28: error: negative integer value -1 converted to unsigned type `u32` [NegativeIntInUnsignedType] - // CHECK:STDERR: included from: fail_import_negative_literal_passed_to_unsigned.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_negative_literal_passed_to_unsigned.carbon:[[@LINE+3]]:27-28: error: negative integer value -1 converted to unsigned type `u32` [NegativeIntInUnsignedType] // CHECK:STDERR: ./negative_literal_passed_to_unsigned.h:2:39: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.neg_to_unsigned_foo(-1); @@ -203,8 +202,7 @@ library "[[@TEST_NAME]]"; import Cpp library "floating_point_literal.h"; fn F() { - // CHECK:STDERR: fail_import_large_floating_point_literal.carbon:[[@LINE+4]]:25-32: error: value 18*10^307 too large for floating-point type `f64` [FloatLiteralTooLargeForType] - // CHECK:STDERR: included from: fail_import_large_floating_point_literal.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_large_floating_point_literal.carbon:[[@LINE+3]]:25-32: error: value 18*10^307 too large for floating-point type `f64` [FloatLiteralTooLargeForType] // CHECK:STDERR: ./floating_point_literal.h:3:31: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.float_literal_foo(1.8e+308); @@ -249,37 +247,32 @@ import Cpp library "struct_init.h"; fn MakeThreeFields() -> {.a: i32, .b: i32, .c: i32}; fn ThreeFields(value: {.a: i32, .b: i32, .c: i32}, ref reference: {.a: i32, .b: i32, .c: i32}) { - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+5]]:23-46: error: cannot implicitly convert expression of type `{.a: Core.IntLiteral, .b: Core.IntLiteral, .c: Core.IntLiteral}` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-46: note: type `{.a: Core.IntLiteral, .b: Core.IntLiteral, .c: Core.IntLiteral}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_todo_struct_init_nonempty.carbon:[[@LINE-7]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-46: error: cannot implicitly convert expression of type `{.a: Core.IntLiteral, .b: Core.IntLiteral, .c: Core.IntLiteral}` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+3]]:23-46: note: type `{.a: Core.IntLiteral, .b: Core.IntLiteral, .c: Core.IntLiteral}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields({.a = 1, .b = 2, .c = 3}); - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+5]]:23-27: error: cannot implicitly convert expression of type `{.a: i32, .b: i32, .c: i32}` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-27: note: type `{.a: i32, .b: i32, .c: i32}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_todo_struct_init_nonempty.carbon:[[@LINE-14]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-27: error: cannot implicitly convert expression of type `{.a: i32, .b: i32, .c: i32}` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+3]]:23-27: note: type `{.a: i32, .b: i32, .c: i32}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields(value); - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+5]]:23-31: error: cannot implicitly convert expression of type `{.a: i32, .b: i32, .c: i32}` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-31: note: type `{.a: i32, .b: i32, .c: i32}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_todo_struct_init_nonempty.carbon:[[@LINE-21]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-31: error: cannot implicitly convert expression of type `{.a: i32, .b: i32, .c: i32}` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+3]]:23-31: note: type `{.a: i32, .b: i32, .c: i32}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields(reference); - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+5]]:23-39: error: cannot implicitly convert expression of type `{.a: i32, .b: i32, .c: i32}` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-39: note: type `{.a: i32, .b: i32, .c: i32}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_todo_struct_init_nonempty.carbon:[[@LINE-28]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-39: error: cannot implicitly convert expression of type `{.a: i32, .b: i32, .c: i32}` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+3]]:23-39: note: type `{.a: i32, .b: i32, .c: i32}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields(MakeThreeFields()); - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+5]]:23-46: error: cannot implicitly convert expression of type `{.b: Core.IntLiteral, .c: Core.IntLiteral, .a: Core.IntLiteral}` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-46: note: type `{.b: Core.IntLiteral, .c: Core.IntLiteral, .a: Core.IntLiteral}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_todo_struct_init_nonempty.carbon:[[@LINE-35]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+4]]:23-46: error: cannot implicitly convert expression of type `{.b: Core.IntLiteral, .c: Core.IntLiteral, .a: Core.IntLiteral}` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_todo_struct_init_nonempty.carbon:[[@LINE+3]]:23-46: note: type `{.b: Core.IntLiteral, .c: Core.IntLiteral, .a: Core.IntLiteral}` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields({.b = 1, .c = 2, .a = 3}); @@ -292,15 +285,13 @@ library "[[@TEST_NAME]]"; import Cpp library "struct_init.h"; fn F() { - // CHECK:STDERR: fail_struct_init_field_mismatch.carbon:[[@LINE+5]]:3-21: error: no matching function for call to 'PassThreeFields' [CppInteropParseError] - // CHECK:STDERR: included from: fail_struct_init_field_mismatch.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_field_mismatch.carbon:[[@LINE+4]]:3-21: error: no matching function for call to 'PassThreeFields' [CppInteropParseError] // CHECK:STDERR: ./struct_init.h:10:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./struct_init.h:10:22-34: note: cannot convert initializer list argument to 'ThreeFields' [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.PassThreeFields({.a = 1, .b = 2, .c = 3, .d = 4}); - // CHECK:STDERR: fail_struct_init_field_mismatch.carbon:[[@LINE+5]]:3-21: error: no matching function for call to 'PassThreeFields' [CppInteropParseError] - // CHECK:STDERR: included from: fail_struct_init_field_mismatch.carbon:[[@LINE-11]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_field_mismatch.carbon:[[@LINE+4]]:3-21: error: no matching function for call to 'PassThreeFields' [CppInteropParseError] // CHECK:STDERR: ./struct_init.h:10:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./struct_init.h:10:22-34: note: cannot convert initializer list argument to 'ThreeFields' [CppInteropParseNoteReason] // CHECK:STDERR: @@ -331,30 +322,26 @@ import Cpp library "struct_init.h"; fn MakeEmpty() -> (); fn Empty(value: (), ref reference: ()) { - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:20-21: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-21: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-10]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-21: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:20-21: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:4:28: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassNoFields(()); - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:20-24: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-24: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-17]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-24: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:20-24: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:4:28: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassNoFields(value); - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:20-28: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-28: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-24]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-28: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:20-28: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:4:28: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassNoFields(reference); - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:20-30: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-30: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-31]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:20-30: error: cannot implicitly convert expression of type `()` to `Cpp.NoFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:20-30: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.NoFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:4:28: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassNoFields(MakeEmpty()); @@ -363,30 +350,26 @@ fn Empty(value: (), ref reference: ()) { fn MakeThreeFields() -> (i32, i32, i32); fn ThreeFields(value: (i32, i32, i32), ref reference: (i32, i32, i32)) { - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:23-31: error: cannot implicitly convert expression of type `(Core.IntLiteral, Core.IntLiteral, Core.IntLiteral)` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-31: note: type `(Core.IntLiteral, Core.IntLiteral, Core.IntLiteral)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-42]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-31: error: cannot implicitly convert expression of type `(Core.IntLiteral, Core.IntLiteral, Core.IntLiteral)` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:23-31: note: type `(Core.IntLiteral, Core.IntLiteral, Core.IntLiteral)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields((1, 2, 3)); - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:23-27: error: cannot implicitly convert expression of type `(i32, i32, i32)` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-27: note: type `(i32, i32, i32)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-49]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-27: error: cannot implicitly convert expression of type `(i32, i32, i32)` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:23-27: note: type `(i32, i32, i32)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields(value); - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:23-31: error: cannot implicitly convert expression of type `(i32, i32, i32)` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-31: note: type `(i32, i32, i32)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-56]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-31: error: cannot implicitly convert expression of type `(i32, i32, i32)` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:23-31: note: type `(i32, i32, i32)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields(reference); - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+5]]:23-39: error: cannot implicitly convert expression of type `(i32, i32, i32)` to `Cpp.ThreeFields` [ConversionFailure] - // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-39: note: type `(i32, i32, i32)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_struct_init_from_tuple.carbon:[[@LINE-63]]:10 [InCppInclude] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+4]]:23-39: error: cannot implicitly convert expression of type `(i32, i32, i32)` to `Cpp.ThreeFields` [ConversionFailure] + // CHECK:STDERR: fail_struct_init_from_tuple.carbon:[[@LINE+3]]:23-39: note: type `(i32, i32, i32)` does not implement interface `Core.ImplicitAs(Cpp.ThreeFields)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./struct_init.h:10:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassThreeFields(MakeThreeFields()); @@ -410,16 +393,14 @@ import Cpp library "int_from_struct.h"; fn F() { // C++ permits `{}` to be used to initialize an int, but Carbon does not. - // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+5]]:15-16: error: cannot implicitly convert expression of type `{}` to `i32` [ConversionFailure] - // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+4]]:15-16: note: type `{}` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_int_from_struct.carbon:[[@LINE-7]]:10 [InCppInclude] + // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+4]]:15-16: error: cannot implicitly convert expression of type `{}` to `i32` [ConversionFailure] + // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+3]]:15-16: note: type `{}` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./int_from_struct.h:2:18: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassInt({}); - // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+5]]:15-16: error: cannot implicitly convert expression of type `()` to `i32` [ConversionFailure] - // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+4]]:15-16: note: type `()` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_int_from_struct.carbon:[[@LINE-14]]:10 [InCppInclude] + // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+4]]:15-16: error: cannot implicitly convert expression of type `()` to `i32` [ConversionFailure] + // CHECK:STDERR: fail_int_from_struct.carbon:[[@LINE+3]]:15-16: note: type `()` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./int_from_struct.h:2:18: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassInt(()); @@ -435,16 +416,14 @@ fn F() { // C++ overload resolution prefers to convert `{}` to `int` rather than to an // empty struct. So that's the overload we pick, even though we can't call it. - // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+5]]:22-23: error: cannot implicitly convert expression of type `{}` to `i32` [ConversionFailure] - // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+4]]:22-23: note: type `{}` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_int_from_struct_overloaded.carbon:[[@LINE-8]]:10 [InCppInclude] + // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+4]]:22-23: error: cannot implicitly convert expression of type `{}` to `i32` [ConversionFailure] + // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+3]]:22-23: note: type `{}` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./int_from_struct.h:6:25: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassOverloaded({}); - // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+5]]:22-23: error: cannot implicitly convert expression of type `()` to `i32` [ConversionFailure] - // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+4]]:22-23: note: type `()` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_int_from_struct_overloaded.carbon:[[@LINE-15]]:10 [InCppInclude] + // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+4]]:22-23: error: cannot implicitly convert expression of type `()` to `i32` [ConversionFailure] + // CHECK:STDERR: fail_int_from_struct_overloaded.carbon:[[@LINE+3]]:22-23: note: type `()` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./int_from_struct.h:6:25: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.PassOverloaded(()); @@ -470,8 +449,7 @@ library "[[@TEST_NAME]]"; import Cpp library "nested_structs.h"; fn F() { - // CHECK:STDERR: fail_pass_nested_structs_inner_field_mismatch.carbon:[[@LINE+5]]:3-11: error: no matching function for call to 'TakeB' [CppInteropParseError] - // CHECK:STDERR: included from: fail_pass_nested_structs_inner_field_mismatch.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_pass_nested_structs_inner_field_mismatch.carbon:[[@LINE+4]]:3-11: error: no matching function for call to 'TakeB' [CppInteropParseError] // CHECK:STDERR: ./nested_structs.h:11:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./nested_structs.h:11:12: note: cannot convert initializer list argument to 'B' [CppInteropParseNoteReason] // CHECK:STDERR: @@ -485,9 +463,8 @@ library "[[@TEST_NAME]]"; import Cpp library "nested_structs.h"; fn F() { - // CHECK:STDERR: fail_todo_pass_nested_structs.carbon:[[@LINE+5]]:13-43: error: cannot implicitly convert expression of type `{.a: {.x: Core.IntLiteral, .y: Core.IntLiteral}, .n: Core.IntLiteral}` to `Cpp.B` [ConversionFailure] - // CHECK:STDERR: fail_todo_pass_nested_structs.carbon:[[@LINE+4]]:13-43: note: type `{.a: {.x: Core.IntLiteral, .y: Core.IntLiteral}, .n: Core.IntLiteral}` does not implement interface `Core.ImplicitAs(Cpp.B)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_todo_pass_nested_structs.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_pass_nested_structs.carbon:[[@LINE+4]]:13-43: error: cannot implicitly convert expression of type `{.a: {.x: Core.IntLiteral, .y: Core.IntLiteral}, .n: Core.IntLiteral}` to `Cpp.B` [ConversionFailure] + // CHECK:STDERR: fail_todo_pass_nested_structs.carbon:[[@LINE+3]]:13-43: note: type `{.a: {.x: Core.IntLiteral, .y: Core.IntLiteral}, .n: Core.IntLiteral}` does not implement interface `Core.ImplicitAs(Cpp.B)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./nested_structs.h:11:13: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.TakeB({.a = {.x = 1, .y = 2}, .n = 3}); @@ -522,9 +499,8 @@ library "[[@TEST_NAME]]"; import Cpp library "signedness_change.h"; fn F() { - // CHECK:STDERR: fail_signedness_change_rejected.carbon:[[@LINE+5]]:22-29: error: cannot implicitly convert expression of type `i32` to `u32` [ConversionFailure] - // CHECK:STDERR: fail_signedness_change_rejected.carbon:[[@LINE+4]]:22-29: note: type `i32` does not implement interface `Core.ImplicitAs(u32)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_signedness_change_rejected.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_signedness_change_rejected.carbon:[[@LINE+4]]:22-29: error: cannot implicitly convert expression of type `i32` to `u32` [ConversionFailure] + // CHECK:STDERR: fail_signedness_change_rejected.carbon:[[@LINE+3]]:22-29: note: type `i32` does not implement interface `Core.ImplicitAs(u32)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./signedness_change.h:2:34: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.signedness_foo(1 as i32); @@ -541,9 +517,8 @@ library "[[@TEST_NAME]]"; import Cpp library "downsizing_rejected.h"; fn F() { - // CHECK:STDERR: fail_import_downsizing_rejected.carbon:[[@LINE+5]]:22-29: error: cannot implicitly convert expression of type `i32` to `i16` [ConversionFailure] - // CHECK:STDERR: fail_import_downsizing_rejected.carbon:[[@LINE+4]]:22-29: note: type `i32` does not implement interface `Core.ImplicitAs(i16)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_import_downsizing_rejected.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_downsizing_rejected.carbon:[[@LINE+4]]:22-29: error: cannot implicitly convert expression of type `i32` to `i16` [ConversionFailure] + // CHECK:STDERR: fail_import_downsizing_rejected.carbon:[[@LINE+3]]:22-29: note: type `i32` does not implement interface `Core.ImplicitAs(i16)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./downsizing_rejected.h:2:27: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: Cpp.downsizing_foo(1 as i32); @@ -564,8 +539,7 @@ library "[[@TEST_NAME]]"; import Cpp library "no_viable_function.h"; fn F() { - // CHECK:STDERR: fail_import_no_viable_function.carbon:[[@LINE+5]]:3-19: error: no matching function for call to 'no_viable_foo' [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_no_viable_function.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_no_viable_function.carbon:[[@LINE+4]]:3-19: error: no matching function for call to 'no_viable_foo' [CppInteropParseError] // CHECK:STDERR: ./no_viable_function.h:2:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./no_viable_function.h:2:20-33: note: requires 2 arguments, but 1 was provided [CppInteropParseNoteReason] // CHECK:STDERR: @@ -588,8 +562,7 @@ library "[[@TEST_NAME]]"; import Cpp library "ambiguous_overload.h"; fn F() { - // CHECK:STDERR: fail_import_ambiguous_overload.carbon:[[@LINE+5]]:3-19: error: call to 'ambiguous_foo' is ambiguous [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_ambiguous_overload.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_ambiguous_overload.carbon:[[@LINE+4]]:3-19: error: call to 'ambiguous_foo' is ambiguous [CppInteropParseError] // CHECK:STDERR: ./ambiguous_overload.h:2:6: note: candidate function [CppInteropParseNote] // CHECK:STDERR: ./ambiguous_overload.h:3:6: note: candidate function [CppInteropParseNote] // CHECK:STDERR: @@ -612,8 +585,7 @@ library "[[@TEST_NAME]]"; import Cpp library "deleted_function.h"; fn F() { - // CHECK:STDERR: fail_import_deleted_function.carbon:[[@LINE+5]]:3-17: error: call to deleted function 'deleted_foo' [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_deleted_function.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_deleted_function.carbon:[[@LINE+4]]:3-17: error: call to deleted function 'deleted_foo' [CppInteropParseError] // CHECK:STDERR: ./deleted_function.h:3:6: note: candidate function has been explicitly deleted [CppInteropParseNote] // CHECK:STDERR: ./deleted_function.h:2:6: note: candidate function [CppInteropParseNote] // CHECK:STDERR: diff --git a/toolchain/check/testdata/interop/cpp/function/import/pointer.carbon b/toolchain/check/testdata/interop/cpp/function/import/pointer.carbon index 61c25414aa0a..9e53612b88b7 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/pointer.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/pointer.carbon @@ -43,8 +43,7 @@ fn G() -> const Cpp.NonNullableParamS; fn F() { var s: const Cpp.NonNullableParamS = G(); - // CHECK:STDERR: fail_import_non_nullable_pointer_param_using_const_value.carbon:[[@LINE+5]]:3-28: error: no matching function for call to 'non_nullable_param_foo' [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_non_nullable_pointer_param_using_const_value.carbon:[[@LINE-7]]:10 [InCppInclude] + // CHECK:STDERR: fail_import_non_nullable_pointer_param_using_const_value.carbon:[[@LINE+4]]:3-28: error: no matching function for call to 'non_nullable_param_foo' [CppInteropParseError] // CHECK:STDERR: ./non_nullable_pointer_param.h:4:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./non_nullable_pointer_param.h:4:29-55: note: 1st argument ('const NonNullableParamS * _Nonnull') would lose const qualifier [CppInteropParseNoteReason] // CHECK:STDERR: diff --git a/toolchain/check/testdata/interop/cpp/function/import/reference.carbon b/toolchain/check/testdata/interop/cpp/function/import/reference.carbon index 57e5e6dada87..b95df8c72663 100644 --- a/toolchain/check/testdata/interop/cpp/function/import/reference.carbon +++ b/toolchain/check/testdata/interop/cpp/function/import/reference.carbon @@ -44,31 +44,27 @@ fn F() { //@dump-sem-ir-begin var v: Cpp.S; let s: Cpp.S = v; - // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_lvalue_ref.carbon:[[@LINE-7]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] // CHECK:STDERR: ./param_lvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_lvalue_ref.h:5:18-19: note: 1st argument ('const S') would lose const qualifier [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.TakesLValue(s); - // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_lvalue_ref.carbon:[[@LINE-14]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] // CHECK:STDERR: ./param_lvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_lvalue_ref.h:5:18-19: note: 1st argument ('const S') would lose const qualifier [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.TakesLValue(s as const Cpp.S); var t: Cpp.T; - // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_lvalue_ref.carbon:[[@LINE-22]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] // CHECK:STDERR: ./param_lvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_lvalue_ref.h:5:18-19: note: no known conversion from 'T' to 'S &' for 1st argument [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.TakesLValue(t); var u: Cpp.S; - // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_lvalue_ref.carbon:[[@LINE-30]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_lvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesLValue' [CppInteropParseError] // CHECK:STDERR: ./param_lvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_lvalue_ref.h:5:18-19: note: 1st argument ('const S') would lose const qualifier [CppInteropParseNoteReason] // CHECK:STDERR: @@ -123,8 +119,7 @@ import Cpp library "param_rvalue_ref.h"; fn F() { let s: Cpp.S = {}; - // CHECK:STDERR: fail_param_value_arg_for_rvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_value_arg_for_rvalue_ref.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_value_arg_for_rvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] // CHECK:STDERR: ./param_rvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_rvalue_ref.h:5:18-20: note: 1st argument ('const S') would lose const qualifier [CppInteropParseNoteReason] // CHECK:STDERR: @@ -140,23 +135,20 @@ import Cpp library "param_rvalue_ref.h"; fn F() { //@dump-sem-ir-begin var s: Cpp.S; - // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_rvalue_ref.carbon:[[@LINE-6]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] // CHECK:STDERR: ./param_rvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_rvalue_ref.h:5:18-20: note: expects an rvalue for 1st argument [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.TakesRValue(s); var t: Cpp.T; - // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_rvalue_ref.carbon:[[@LINE-14]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] // CHECK:STDERR: ./param_rvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_rvalue_ref.h:5:18-20: note: no known conversion from 'T' to 'S' for 1st argument [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.TakesRValue(t); - // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+5]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_rvalue_ref.carbon:[[@LINE-21]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_rvalue_ref.carbon:[[@LINE+4]]:3-17: error: no matching function for call to 'TakesRValue' [CppInteropParseError] // CHECK:STDERR: ./param_rvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_rvalue_ref.h:5:18-20: note: 1st argument ('const S') would lose const qualifier [CppInteropParseNoteReason] // CHECK:STDERR: @@ -213,8 +205,7 @@ import Cpp library "param_const_lvalue_ref.h"; fn F() { var t: Cpp.T; - // CHECK:STDERR: fail_call_param_const_lvalue_ref_with_wrong_type.carbon:[[@LINE+5]]:3-22: error: no matching function for call to 'TakesConstLValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_call_param_const_lvalue_ref_with_wrong_type.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_call_param_const_lvalue_ref_with_wrong_type.carbon:[[@LINE+4]]:3-22: error: no matching function for call to 'TakesConstLValue' [CppInteropParseError] // CHECK:STDERR: ./param_const_lvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_const_lvalue_ref.h:5:23-30: note: no known conversion from 'T' to 'const S' for 1st argument [CppInteropParseNoteReason] // CHECK:STDERR: @@ -269,16 +260,14 @@ import Cpp library "param_const_rvalue_ref.h"; fn F() { //@dump-sem-ir-begin var s: Cpp.S; - // CHECK:STDERR: fail_param_lvalue_ref_arg_const_rvalue_ref.carbon:[[@LINE+5]]:3-22: error: no matching function for call to 'TakesConstRValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_lvalue_ref_arg_const_rvalue_ref.carbon:[[@LINE-6]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_lvalue_ref_arg_const_rvalue_ref.carbon:[[@LINE+4]]:3-22: error: no matching function for call to 'TakesConstRValue' [CppInteropParseError] // CHECK:STDERR: ./param_const_rvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_const_rvalue_ref.h:5:23-31: note: expects an rvalue for 1st argument [CppInteropParseNoteReason] // CHECK:STDERR: Cpp.TakesConstRValue(s); var t: Cpp.T; - // CHECK:STDERR: fail_param_lvalue_ref_arg_const_rvalue_ref.carbon:[[@LINE+5]]:3-22: error: no matching function for call to 'TakesConstRValue' [CppInteropParseError] - // CHECK:STDERR: included from: fail_param_lvalue_ref_arg_const_rvalue_ref.carbon:[[@LINE-14]]:10 [InCppInclude] + // CHECK:STDERR: fail_param_lvalue_ref_arg_const_rvalue_ref.carbon:[[@LINE+4]]:3-22: error: no matching function for call to 'TakesConstRValue' [CppInteropParseError] // CHECK:STDERR: ./param_const_rvalue_ref.h:5:6: note: candidate function not viable [CppInteropParseNote] // CHECK:STDERR: ./param_const_rvalue_ref.h:5:23-31: note: no known conversion from 'T' to 'const S' for 1st argument [CppInteropParseNoteReason] // CHECK:STDERR: @@ -618,28 +607,28 @@ fn PassConstRef(ref x: const XByRef) { // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %s.patt: %pattern_type.0f5 = value_binding_pattern s [concrete = constants.%s.patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc15: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesLValue.ref.loc15: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] -// CHECK:STDOUT: %s.ref.loc15: %S = name_ref s, %s -// CHECK:STDOUT: %Cpp.ref.loc22_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesLValue.ref.loc22: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] -// CHECK:STDOUT: %s.ref.loc22: %S = name_ref s, %s -// CHECK:STDOUT: %Cpp.ref.loc22_30: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %S.ref.loc22: type = name_ref S, imports.%S.decl [concrete = constants.%S] -// CHECK:STDOUT: %const.loc22: type = const_type %S.ref.loc22 [concrete = constants.%const] -// CHECK:STDOUT: %.loc22_21.1: %const = as_compatible %s.ref.loc22 -// CHECK:STDOUT: %.loc22_21.2: %const = converted %s.ref.loc22, %.loc22_21.1 +// CHECK:STDOUT: %Cpp.ref.loc14: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesLValue.ref.loc14: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] +// CHECK:STDOUT: %s.ref.loc14: %S = name_ref s, %s +// CHECK:STDOUT: %Cpp.ref.loc20_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesLValue.ref.loc20: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] +// CHECK:STDOUT: %s.ref.loc20: %S = name_ref s, %s +// CHECK:STDOUT: %Cpp.ref.loc20_30: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %S.ref.loc20: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: %const.loc20: type = const_type %S.ref.loc20 [concrete = constants.%const] +// CHECK:STDOUT: %.loc20_21.1: %const = as_compatible %s.ref.loc20 +// CHECK:STDOUT: %.loc20_21.2: %const = converted %s.ref.loc20, %.loc20_21.1 // CHECK:STDOUT: %t.var: ref %T.ed0 = var_storage %t.var_patt -// CHECK:STDOUT: %DefaultOrUnformed.facet.loc24: %DefaultOrUnformed.type = facet_value constants.%T.ed0, (constants.%DefaultOrUnformed.impl_witness.307) [concrete = constants.%DefaultOrUnformed.facet.d8b] -// CHECK:STDOUT: %.loc24_15.1: %DefaultOrUnformed.type = converted constants.%T.ed0, %DefaultOrUnformed.facet.loc24 [concrete = constants.%DefaultOrUnformed.facet.d8b] -// CHECK:STDOUT: %as_type.loc24: type = facet_access_type %.loc24_15.1 [concrete = constants.%T.ed0] -// CHECK:STDOUT: %.loc24_15.2: type = converted %.loc24_15.1, %as_type.loc24 [concrete = constants.%T.ed0] +// CHECK:STDOUT: %DefaultOrUnformed.facet.loc22: %DefaultOrUnformed.type = facet_value constants.%T.ed0, (constants.%DefaultOrUnformed.impl_witness.307) [concrete = constants.%DefaultOrUnformed.facet.d8b] +// CHECK:STDOUT: %.loc22_15.1: %DefaultOrUnformed.type = converted constants.%T.ed0, %DefaultOrUnformed.facet.loc22 [concrete = constants.%DefaultOrUnformed.facet.d8b] +// CHECK:STDOUT: %as_type.loc22: type = facet_access_type %.loc22_15.1 [concrete = constants.%T.ed0] +// CHECK:STDOUT: %.loc22_15.2: type = converted %.loc22_15.1, %as_type.loc22 [concrete = constants.%T.ed0] // CHECK:STDOUT: -// CHECK:STDOUT: %.loc24_3.1: ref %T.ed0 = splice_block %t.var {} -// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc24: init %T.ed0 to %.loc24_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.2() -// CHECK:STDOUT: assign %t.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc24 -// CHECK:STDOUT: %.loc24_13: type = splice_block %T.ref [concrete = constants.%T.ed0] { -// CHECK:STDOUT: %Cpp.ref.loc24: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %.loc22_3.1: ref %T.ed0 = splice_block %t.var {} +// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc22: init %T.ed0 to %.loc22_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.2() +// CHECK:STDOUT: assign %t.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc22 +// CHECK:STDOUT: %.loc22_13: type = splice_block %T.ref [concrete = constants.%T.ed0] { +// CHECK:STDOUT: %Cpp.ref.loc22: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%T.decl [concrete = constants.%T.ed0] // CHECK:STDOUT: } // CHECK:STDOUT: %t: ref %T.ed0 = wrapper_binding t, %t.var @@ -647,47 +636,47 @@ fn PassConstRef(ref x: const XByRef) { // CHECK:STDOUT: %t.patt: %pattern_type.5f6 = ref_binding_pattern t [concrete = constants.%t.patt.420] // CHECK:STDOUT: %t.var_patt: %pattern_type.5f6 = var_pattern %t.patt [concrete = constants.%t.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc30: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesLValue.ref.loc30: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc27: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesLValue.ref.loc27: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] // CHECK:STDOUT: %t.ref: ref %T.ed0 = name_ref t, %t // CHECK:STDOUT: %u.var: ref %S = var_storage %u.var_patt -// CHECK:STDOUT: %DefaultOrUnformed.facet.loc32: %DefaultOrUnformed.type = facet_value constants.%S, (constants.%DefaultOrUnformed.impl_witness.e4a) [concrete = constants.%DefaultOrUnformed.facet.cbb] -// CHECK:STDOUT: %.loc32_15.1: %DefaultOrUnformed.type = converted constants.%S, %DefaultOrUnformed.facet.loc32 [concrete = constants.%DefaultOrUnformed.facet.cbb] -// CHECK:STDOUT: %as_type.loc32: type = facet_access_type %.loc32_15.1 [concrete = constants.%S] -// CHECK:STDOUT: %.loc32_15.2: type = converted %.loc32_15.1, %as_type.loc32 [concrete = constants.%S] +// CHECK:STDOUT: %DefaultOrUnformed.facet.loc29: %DefaultOrUnformed.type = facet_value constants.%S, (constants.%DefaultOrUnformed.impl_witness.e4a) [concrete = constants.%DefaultOrUnformed.facet.cbb] +// CHECK:STDOUT: %.loc29_15.1: %DefaultOrUnformed.type = converted constants.%S, %DefaultOrUnformed.facet.loc29 [concrete = constants.%DefaultOrUnformed.facet.cbb] +// CHECK:STDOUT: %as_type.loc29: type = facet_access_type %.loc29_15.1 [concrete = constants.%S] +// CHECK:STDOUT: %.loc29_15.2: type = converted %.loc29_15.1, %as_type.loc29 [concrete = constants.%S] // CHECK:STDOUT: -// CHECK:STDOUT: %.loc32_3.1: ref %S = splice_block %u.var {} -// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc32: init %S to %.loc32_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.3() -// CHECK:STDOUT: assign %u.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc32 -// CHECK:STDOUT: %.loc32_13: type = splice_block %S.ref.loc32 [concrete = constants.%S] { -// CHECK:STDOUT: %Cpp.ref.loc32: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %S.ref.loc32: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: %.loc29_3.1: ref %S = splice_block %u.var {} +// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc29: init %S to %.loc29_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.3() +// CHECK:STDOUT: assign %u.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc29 +// CHECK:STDOUT: %.loc29_13: type = splice_block %S.ref.loc29 [concrete = constants.%S] { +// CHECK:STDOUT: %Cpp.ref.loc29: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %S.ref.loc29: type = name_ref S, imports.%S.decl [concrete = constants.%S] // CHECK:STDOUT: } // CHECK:STDOUT: %u: ref %S = wrapper_binding u, %u.var // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %u.patt: %pattern_type.0f5 = ref_binding_pattern u [concrete = constants.%u.patt] // CHECK:STDOUT: %u.var_patt: %pattern_type.0f5 = var_pattern %u.patt [concrete = constants.%u.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc38_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesLValue.ref.loc38: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc34_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesLValue.ref.loc34: %TakesLValue.cpp_overload_set.type = name_ref TakesLValue, imports.%TakesLValue.cpp_overload_set.value [concrete = constants.%TakesLValue.cpp_overload_set.value] // CHECK:STDOUT: %u.ref: ref %S = name_ref u, %u -// CHECK:STDOUT: %Cpp.ref.loc38_30: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %S.ref.loc38: type = name_ref S, imports.%S.decl [concrete = constants.%S] -// CHECK:STDOUT: %const.loc38: type = const_type %S.ref.loc38 [concrete = constants.%const] -// CHECK:STDOUT: %.loc38_21.1: ref %const = as_compatible %u.ref -// CHECK:STDOUT: %.loc38_21.2: ref %const = converted %u.ref, %.loc38_21.1 -// CHECK:STDOUT: %Destroy.facet.loc32_3.1: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.580] -// CHECK:STDOUT: %.loc32_3.2: %Destroy.type = converted constants.%S, %Destroy.facet.loc32_3.1 [concrete = constants.%Destroy.facet.580] -// CHECK:STDOUT: %Destroy.facet.loc32_3.2: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.580] -// CHECK:STDOUT: %.loc32_3.3: %Destroy.type = converted constants.%S, %Destroy.facet.loc32_3.2 [concrete = constants.%Destroy.facet.580] +// CHECK:STDOUT: %Cpp.ref.loc34_30: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %S.ref.loc34: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: %const.loc34: type = const_type %S.ref.loc34 [concrete = constants.%const] +// CHECK:STDOUT: %.loc34_21.1: ref %const = as_compatible %u.ref +// CHECK:STDOUT: %.loc34_21.2: ref %const = converted %u.ref, %.loc34_21.1 +// CHECK:STDOUT: %Destroy.facet.loc29_3.1: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.580] +// CHECK:STDOUT: %.loc29_3.2: %Destroy.type = converted constants.%S, %Destroy.facet.loc29_3.1 [concrete = constants.%Destroy.facet.580] +// CHECK:STDOUT: %Destroy.facet.loc29_3.2: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.580] +// CHECK:STDOUT: %.loc29_3.3: %Destroy.type = converted constants.%S, %Destroy.facet.loc29_3.2 [concrete = constants.%Destroy.facet.580] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call.loc32: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%u.var) -// CHECK:STDOUT: %Destroy.facet.loc24_3.1: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %.loc24_3.2: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc24_3.1 [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %Destroy.facet.loc24_3.2: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %.loc24_3.3: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc24_3.2 [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %SelfDestruct.call.loc29: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%u.var) +// CHECK:STDOUT: %Destroy.facet.loc22_3.1: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %.loc22_3.2: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc22_3.1 [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %Destroy.facet.loc22_3.2: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %.loc22_3.3: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc22_3.2 [concrete = constants.%Destroy.facet.8f8] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call.loc24: init %empty_tuple.type = call %SelfDestruct.specific_fn.2(%t.var) +// CHECK:STDOUT: %SelfDestruct.call.loc22: init %empty_tuple.type = call %SelfDestruct.specific_fn.2(%t.var) // CHECK:STDOUT: %Destroy.facet.loc8_3.1: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.580] // CHECK:STDOUT: %.loc8_3.2: %Destroy.type = converted constants.%S, %Destroy.facet.loc8_3.1 [concrete = constants.%Destroy.facet.580] // CHECK:STDOUT: %Destroy.facet.loc8_3.2: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.580] @@ -836,20 +825,20 @@ fn PassConstRef(ref x: const XByRef) { // CHECK:STDOUT: %s.patt: %pattern_type.0f5 = ref_binding_pattern s [concrete = constants.%s.patt] // CHECK:STDOUT: %s.var_patt: %pattern_type.0f5 = var_pattern %s.patt [concrete = constants.%s.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc14: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesRValue.ref.loc14: %TakesRValue.cpp_overload_set.type = name_ref TakesRValue, imports.%TakesRValue.cpp_overload_set.value [concrete = constants.%TakesRValue.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc13: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesRValue.ref.loc13: %TakesRValue.cpp_overload_set.type = name_ref TakesRValue, imports.%TakesRValue.cpp_overload_set.value [concrete = constants.%TakesRValue.cpp_overload_set.value] // CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s // CHECK:STDOUT: %t.var: ref %T.ed0 = var_storage %t.var_patt -// CHECK:STDOUT: %DefaultOrUnformed.facet.loc16: %DefaultOrUnformed.type = facet_value constants.%T.ed0, (constants.%DefaultOrUnformed.impl_witness.307) [concrete = constants.%DefaultOrUnformed.facet.d8b] -// CHECK:STDOUT: %.loc16_15.1: %DefaultOrUnformed.type = converted constants.%T.ed0, %DefaultOrUnformed.facet.loc16 [concrete = constants.%DefaultOrUnformed.facet.d8b] -// CHECK:STDOUT: %as_type.loc16: type = facet_access_type %.loc16_15.1 [concrete = constants.%T.ed0] -// CHECK:STDOUT: %.loc16_15.2: type = converted %.loc16_15.1, %as_type.loc16 [concrete = constants.%T.ed0] +// CHECK:STDOUT: %DefaultOrUnformed.facet.loc15: %DefaultOrUnformed.type = facet_value constants.%T.ed0, (constants.%DefaultOrUnformed.impl_witness.307) [concrete = constants.%DefaultOrUnformed.facet.d8b] +// CHECK:STDOUT: %.loc15_15.1: %DefaultOrUnformed.type = converted constants.%T.ed0, %DefaultOrUnformed.facet.loc15 [concrete = constants.%DefaultOrUnformed.facet.d8b] +// CHECK:STDOUT: %as_type.loc15: type = facet_access_type %.loc15_15.1 [concrete = constants.%T.ed0] +// CHECK:STDOUT: %.loc15_15.2: type = converted %.loc15_15.1, %as_type.loc15 [concrete = constants.%T.ed0] // CHECK:STDOUT: -// CHECK:STDOUT: %.loc16_3.1: ref %T.ed0 = splice_block %t.var {} -// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc16: init %T.ed0 to %.loc16_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.2() -// CHECK:STDOUT: assign %t.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc16 -// CHECK:STDOUT: %.loc16_13: type = splice_block %T.ref [concrete = constants.%T.ed0] { -// CHECK:STDOUT: %Cpp.ref.loc16: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %.loc15_3.1: ref %T.ed0 = splice_block %t.var {} +// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc15: init %T.ed0 to %.loc15_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.2() +// CHECK:STDOUT: assign %t.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc15 +// CHECK:STDOUT: %.loc15_13: type = splice_block %T.ref [concrete = constants.%T.ed0] { +// CHECK:STDOUT: %Cpp.ref.loc15: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%T.decl [concrete = constants.%T.ed0] // CHECK:STDOUT: } // CHECK:STDOUT: %t: ref %T.ed0 = wrapper_binding t, %t.var @@ -857,28 +846,28 @@ fn PassConstRef(ref x: const XByRef) { // CHECK:STDOUT: %t.patt: %pattern_type.5f6 = ref_binding_pattern t [concrete = constants.%t.patt.420] // CHECK:STDOUT: %t.var_patt: %pattern_type.5f6 = var_pattern %t.patt [concrete = constants.%t.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc22: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesRValue.ref.loc22: %TakesRValue.cpp_overload_set.type = name_ref TakesRValue, imports.%TakesRValue.cpp_overload_set.value [concrete = constants.%TakesRValue.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc20: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesRValue.ref.loc20: %TakesRValue.cpp_overload_set.type = name_ref TakesRValue, imports.%TakesRValue.cpp_overload_set.value [concrete = constants.%TakesRValue.cpp_overload_set.value] // CHECK:STDOUT: %t.ref: ref %T.ed0 = name_ref t, %t -// CHECK:STDOUT: %Cpp.ref.loc29_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesRValue.ref.loc29: %TakesRValue.cpp_overload_set.type = name_ref TakesRValue, imports.%TakesRValue.cpp_overload_set.value [concrete = constants.%TakesRValue.cpp_overload_set.value] -// CHECK:STDOUT: %.loc29_21.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct.a40] -// CHECK:STDOUT: %Cpp.ref.loc29_26: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %S.ref.loc29_29: type = name_ref S, imports.%S.decl [concrete = constants.%S] -// CHECK:STDOUT: %.loc29_21.2: ref %S = temporary_storage -// CHECK:STDOUT: %.loc29_21.3: init %S to %.loc29_21.2 = class_init () [concrete = constants.%S.val] -// CHECK:STDOUT: %.loc29_23: init %S = converted %.loc29_21.1, %.loc29_21.3 [concrete = constants.%S.val] -// CHECK:STDOUT: %Cpp.ref.loc29_42: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %S.ref.loc29_45: type = name_ref S, imports.%S.decl [concrete = constants.%S] -// CHECK:STDOUT: %const: type = const_type %S.ref.loc29_45 [concrete = constants.%const] -// CHECK:STDOUT: %.loc29_33.1: init %const = as_compatible %.loc29_23 [concrete = constants.%empty_struct.674] -// CHECK:STDOUT: %.loc29_33.2: init %const = converted %.loc29_23, %.loc29_33.1 [concrete = constants.%empty_struct.674] -// CHECK:STDOUT: %Destroy.facet.loc16_3.1: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %.loc16_3.2: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc16_3.1 [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %Destroy.facet.loc16_3.2: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %.loc16_3.3: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc16_3.2 [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %Cpp.ref.loc26_3: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesRValue.ref.loc26: %TakesRValue.cpp_overload_set.type = name_ref TakesRValue, imports.%TakesRValue.cpp_overload_set.value [concrete = constants.%TakesRValue.cpp_overload_set.value] +// CHECK:STDOUT: %.loc26_21.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct.a40] +// CHECK:STDOUT: %Cpp.ref.loc26_26: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %S.ref.loc26_29: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: %.loc26_21.2: ref %S = temporary_storage +// CHECK:STDOUT: %.loc26_21.3: init %S to %.loc26_21.2 = class_init () [concrete = constants.%S.val] +// CHECK:STDOUT: %.loc26_23: init %S = converted %.loc26_21.1, %.loc26_21.3 [concrete = constants.%S.val] +// CHECK:STDOUT: %Cpp.ref.loc26_42: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %S.ref.loc26_45: type = name_ref S, imports.%S.decl [concrete = constants.%S] +// CHECK:STDOUT: %const: type = const_type %S.ref.loc26_45 [concrete = constants.%const] +// CHECK:STDOUT: %.loc26_33.1: init %const = as_compatible %.loc26_23 [concrete = constants.%empty_struct.674] +// CHECK:STDOUT: %.loc26_33.2: init %const = converted %.loc26_23, %.loc26_33.1 [concrete = constants.%empty_struct.674] +// CHECK:STDOUT: %Destroy.facet.loc15_3.1: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %.loc15_3.2: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc15_3.1 [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %Destroy.facet.loc15_3.2: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %.loc15_3.3: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc15_3.2 [concrete = constants.%Destroy.facet.8f8] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call.loc16: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%t.var) +// CHECK:STDOUT: %SelfDestruct.call.loc15: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%t.var) // CHECK:STDOUT: %Destroy.facet.loc8_3.1: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.580] // CHECK:STDOUT: %.loc8_3.2: %Destroy.type = converted constants.%S, %Destroy.facet.loc8_3.1 [concrete = constants.%Destroy.facet.580] // CHECK:STDOUT: %Destroy.facet.loc8_3.2: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.580] @@ -1224,20 +1213,20 @@ fn PassConstRef(ref x: const XByRef) { // CHECK:STDOUT: %s.patt: %pattern_type.0f5 = ref_binding_pattern s [concrete = constants.%s.patt] // CHECK:STDOUT: %s.var_patt: %pattern_type.0f5 = var_pattern %s.patt [concrete = constants.%s.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc14: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesConstRValue.ref.loc14: %TakesConstRValue.cpp_overload_set.type = name_ref TakesConstRValue, imports.%TakesConstRValue.cpp_overload_set.value [concrete = constants.%TakesConstRValue.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc13: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesConstRValue.ref.loc13: %TakesConstRValue.cpp_overload_set.type = name_ref TakesConstRValue, imports.%TakesConstRValue.cpp_overload_set.value [concrete = constants.%TakesConstRValue.cpp_overload_set.value] // CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s // CHECK:STDOUT: %t.var: ref %T.ed0 = var_storage %t.var_patt -// CHECK:STDOUT: %DefaultOrUnformed.facet.loc16: %DefaultOrUnformed.type = facet_value constants.%T.ed0, (constants.%DefaultOrUnformed.impl_witness.307) [concrete = constants.%DefaultOrUnformed.facet.d8b] -// CHECK:STDOUT: %.loc16_15.1: %DefaultOrUnformed.type = converted constants.%T.ed0, %DefaultOrUnformed.facet.loc16 [concrete = constants.%DefaultOrUnformed.facet.d8b] -// CHECK:STDOUT: %as_type.loc16: type = facet_access_type %.loc16_15.1 [concrete = constants.%T.ed0] -// CHECK:STDOUT: %.loc16_15.2: type = converted %.loc16_15.1, %as_type.loc16 [concrete = constants.%T.ed0] +// CHECK:STDOUT: %DefaultOrUnformed.facet.loc15: %DefaultOrUnformed.type = facet_value constants.%T.ed0, (constants.%DefaultOrUnformed.impl_witness.307) [concrete = constants.%DefaultOrUnformed.facet.d8b] +// CHECK:STDOUT: %.loc15_15.1: %DefaultOrUnformed.type = converted constants.%T.ed0, %DefaultOrUnformed.facet.loc15 [concrete = constants.%DefaultOrUnformed.facet.d8b] +// CHECK:STDOUT: %as_type.loc15: type = facet_access_type %.loc15_15.1 [concrete = constants.%T.ed0] +// CHECK:STDOUT: %.loc15_15.2: type = converted %.loc15_15.1, %as_type.loc15 [concrete = constants.%T.ed0] // CHECK:STDOUT: -// CHECK:STDOUT: %.loc16_3.1: ref %T.ed0 = splice_block %t.var {} -// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc16: init %T.ed0 to %.loc16_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.2() -// CHECK:STDOUT: assign %t.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc16 -// CHECK:STDOUT: %.loc16_13: type = splice_block %T.ref [concrete = constants.%T.ed0] { -// CHECK:STDOUT: %Cpp.ref.loc16: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %.loc15_3.1: ref %T.ed0 = splice_block %t.var {} +// CHECK:STDOUT: %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc15: init %T.ed0 to %.loc15_3.1 = call %T.as_type.as.DefaultOrUnformed.impl.Op.specific_fn.2() +// CHECK:STDOUT: assign %t.var, %T.as_type.as.DefaultOrUnformed.impl.Op.call.loc15 +// CHECK:STDOUT: %.loc15_13: type = splice_block %T.ref [concrete = constants.%T.ed0] { +// CHECK:STDOUT: %Cpp.ref.loc15: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %T.ref: type = name_ref T, imports.%T.decl [concrete = constants.%T.ed0] // CHECK:STDOUT: } // CHECK:STDOUT: %t: ref %T.ed0 = wrapper_binding t, %t.var @@ -1245,15 +1234,15 @@ fn PassConstRef(ref x: const XByRef) { // CHECK:STDOUT: %t.patt: %pattern_type.5f6 = ref_binding_pattern t [concrete = constants.%t.patt.420] // CHECK:STDOUT: %t.var_patt: %pattern_type.5f6 = var_pattern %t.patt [concrete = constants.%t.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Cpp.ref.loc22: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] -// CHECK:STDOUT: %TakesConstRValue.ref.loc22: %TakesConstRValue.cpp_overload_set.type = name_ref TakesConstRValue, imports.%TakesConstRValue.cpp_overload_set.value [concrete = constants.%TakesConstRValue.cpp_overload_set.value] +// CHECK:STDOUT: %Cpp.ref.loc20: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %TakesConstRValue.ref.loc20: %TakesConstRValue.cpp_overload_set.type = name_ref TakesConstRValue, imports.%TakesConstRValue.cpp_overload_set.value [concrete = constants.%TakesConstRValue.cpp_overload_set.value] // CHECK:STDOUT: %t.ref: ref %T.ed0 = name_ref t, %t -// CHECK:STDOUT: %Destroy.facet.loc16_3.1: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %.loc16_3.2: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc16_3.1 [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %Destroy.facet.loc16_3.2: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] -// CHECK:STDOUT: %.loc16_3.3: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc16_3.2 [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %Destroy.facet.loc15_3.1: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %.loc15_3.2: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc15_3.1 [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %Destroy.facet.loc15_3.2: %Destroy.type = facet_value constants.%T.ed0, (constants.%DestroyImpl.impl_witness.68c, constants.%custom_witness.fe1878.1) [concrete = constants.%Destroy.facet.8f8] +// CHECK:STDOUT: %.loc15_3.3: %Destroy.type = converted constants.%T.ed0, %Destroy.facet.loc15_3.2 [concrete = constants.%Destroy.facet.8f8] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call.loc16: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%t.var) +// CHECK:STDOUT: %SelfDestruct.call.loc15: init %empty_tuple.type = call %SelfDestruct.specific_fn.1(%t.var) // CHECK:STDOUT: %Destroy.facet.loc8_3.1: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.580] // CHECK:STDOUT: %.loc8_3.2: %Destroy.type = converted constants.%S, %Destroy.facet.loc8_3.1 [concrete = constants.%Destroy.facet.580] // CHECK:STDOUT: %Destroy.facet.loc8_3.2: %Destroy.type = facet_value constants.%S, (constants.%DestroyImpl.impl_witness.b60, constants.%custom_witness.fe1878.2) [concrete = constants.%Destroy.facet.580] diff --git a/toolchain/check/testdata/interop/cpp/impls/copy.carbon b/toolchain/check/testdata/interop/cpp/impls/copy.carbon index 0d45c29eaead..ffbc527d3b0d 100644 --- a/toolchain/check/testdata/interop/cpp/impls/copy.carbon +++ b/toolchain/check/testdata/interop/cpp/impls/copy.carbon @@ -83,24 +83,21 @@ library "[[@TEST_NAME]]"; import Cpp library "types.h"; fn CopyDeletedCopy(c: Cpp.DeletedCopy) -> Cpp.DeletedCopy { - // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: error: attempt to use a deleted function [CppInteropParseError] - // CHECK:STDERR: included from: fail_copy_noncopyable.carbon:[[@LINE-4]]:10 [InCppInclude] + // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+3]]:10: error: attempt to use a deleted function [CppInteropParseError] // CHECK:STDERR: ./types.h:14:3: note: 'DeletedCopy' has been explicitly marked deleted here [CppInteropParseNote] // CHECK:STDERR: return c; } fn CopyMoveOnly(c: Cpp.MoveOnly) -> Cpp.MoveOnly { - // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: error: attempt to use a deleted function [CppInteropParseError] - // CHECK:STDERR: included from: fail_copy_noncopyable.carbon:[[@LINE-12]]:10 [InCppInclude] + // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+3]]:10: error: attempt to use a deleted function [CppInteropParseError] // CHECK:STDERR: ./types.h:19:3: note: copy constructor is implicitly deleted because 'MoveOnly' has a user-declared move constructor [CppInteropParseNote] // CHECK:STDERR: return c; } fn CopyDeletedMove(c: Cpp.DeletedMove) -> Cpp.DeletedMove { - // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: error: attempt to use a deleted function [CppInteropParseError] - // CHECK:STDERR: included from: fail_copy_noncopyable.carbon:[[@LINE-20]]:10 [InCppInclude] + // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+3]]:10: error: attempt to use a deleted function [CppInteropParseError] // CHECK:STDERR: ./types.h:24:3: note: copy constructor is implicitly deleted because 'DeletedMove' has a user-declared move constructor [CppInteropParseNote] // CHECK:STDERR: return c; @@ -124,8 +121,7 @@ fn CopyAmbiguousCopy(c: Cpp.AmbiguousCopy) -> Cpp.AmbiguousCopy { fn CopyPrivateCopy(c: Cpp.PrivateCopy) -> Cpp.PrivateCopy { // TODO: Note is missing location. - // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: error: cannot access private member `PrivateCopy` of type `Cpp.PrivateCopy` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_copy_noncopyable.carbon:[[@LINE-45]]:10 [InCppInclude] + // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+3]]:10: error: cannot access private member `PrivateCopy` of type `Cpp.PrivateCopy` [ClassInvalidMemberAccess] // CHECK:STDERR: ./types.h:40:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: return c; @@ -133,8 +129,7 @@ fn CopyPrivateCopy(c: Cpp.PrivateCopy) -> Cpp.PrivateCopy { fn CopyProtectedCopy(c: Cpp.ProtectedCopy) -> Cpp.ProtectedCopy { // TODO: Note is missing location. - // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: error: cannot access protected member `ProtectedCopy` of type `Cpp.ProtectedCopy` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_copy_noncopyable.carbon:[[@LINE-54]]:10 [InCppInclude] + // CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+3]]:10: error: cannot access protected member `ProtectedCopy` of type `Cpp.ProtectedCopy` [ClassInvalidMemberAccess] // CHECK:STDERR: ./types.h:45:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: return c; diff --git a/toolchain/check/testdata/interop/cpp/impls/destroy.carbon b/toolchain/check/testdata/interop/cpp/impls/destroy.carbon index 398c4e9f2f2f..272e5cbd62e3 100644 --- a/toolchain/check/testdata/interop/cpp/impls/destroy.carbon +++ b/toolchain/check/testdata/interop/cpp/impls/destroy.carbon @@ -77,8 +77,7 @@ class Derived { fn DestroyClassWithProtectedBaseDestructor() { //@dump-sem-ir-begin - // CHECK:STDERR: fail_todo_destroy_protected_base_destructor.carbon:[[@LINE+5]]:3-23: error: cannot access protected member `` of type `Cpp.ProtectedDestructor` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_todo_destroy_protected_base_destructor.carbon:[[@LINE-9]]:10 [InCppInclude] + // CHECK:STDERR: fail_todo_destroy_protected_base_destructor.carbon:[[@LINE+4]]:3-23: error: cannot access protected member `` of type `Cpp.ProtectedDestructor` [ClassInvalidMemberAccess] // CHECK:STDERR: ./types.h:33:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: @@ -99,8 +98,7 @@ class Derived { fn DestroyClassWithPrivateBaseDestructor() { //@dump-sem-ir-begin // TODO: We should not allow this, as the destructor of the base class is private. - // CHECK:STDERR: fail_destroy_private_base_destructor.carbon:[[@LINE+5]]:3-23: error: cannot access private member `` of type `Cpp.PrivateDestructor` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_destroy_private_base_destructor.carbon:[[@LINE-10]]:10 [InCppInclude] + // CHECK:STDERR: fail_destroy_private_base_destructor.carbon:[[@LINE+4]]:3-23: error: cannot access private member `` of type `Cpp.PrivateDestructor` [ClassInvalidMemberAccess] // CHECK:STDERR: ./types.h:28:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: @@ -126,8 +124,7 @@ fn AmbiguousDestroy() { } fn DeletedDestroy() { - // CHECK:STDERR: fail_destroy_nondestroyable.carbon:[[@LINE+8]]:3: error: attempt to use a deleted function [CppInteropParseError] - // CHECK:STDERR: included from: fail_destroy_nondestroyable.carbon:[[@LINE-15]]:10 [InCppInclude] + // CHECK:STDERR: fail_destroy_nondestroyable.carbon:[[@LINE+7]]:3: error: attempt to use a deleted function [CppInteropParseError] // CHECK:STDERR: ./types.h:23:3: note: '~DeletedDestructor' has been explicitly marked deleted here [CppInteropParseNote] // CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: @@ -138,8 +135,7 @@ fn DeletedDestroy() { } fn PrivateDestroy() { - // CHECK:STDERR: fail_destroy_nondestroyable.carbon:[[@LINE+5]]:3-37: error: cannot access private member `` of type `Cpp.PrivateDestructor` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_destroy_nondestroyable.carbon:[[@LINE-27]]:10 [InCppInclude] + // CHECK:STDERR: fail_destroy_nondestroyable.carbon:[[@LINE+4]]:3-37: error: cannot access private member `` of type `Cpp.PrivateDestructor` [ClassInvalidMemberAccess] // CHECK:STDERR: ./types.h:28:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: @@ -147,8 +143,7 @@ fn PrivateDestroy() { } fn ProtectedDestroy() { - // CHECK:STDERR: fail_destroy_nondestroyable.carbon:[[@LINE+5]]:3-39: error: cannot access protected member `` of type `Cpp.ProtectedDestructor` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_destroy_nondestroyable.carbon:[[@LINE-36]]:10 [InCppInclude] + // CHECK:STDERR: fail_destroy_nondestroyable.carbon:[[@LINE+4]]:3-39: error: cannot access protected member `` of type `Cpp.ProtectedDestructor` [ClassInvalidMemberAccess] // CHECK:STDERR: ./types.h:33:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: @@ -188,8 +183,7 @@ class AdaptNoDestroy { fn Make() -> AdaptNoDestroy; fn F() { - // CHECK:STDERR: fail_no_destroy.carbon:[[@LINE+5]]:3: error: attempt to use a deleted function [CppInteropParseError] - // CHECK:STDERR: included from: fail_no_destroy.carbon:[[@LINE-10]]:10 [InCppInclude] + // CHECK:STDERR: fail_no_destroy.carbon:[[@LINE+4]]:3: error: attempt to use a deleted function [CppInteropParseError] // CHECK:STDERR: ./types.h:23:3: note: '~DeletedDestructor' has been explicitly marked deleted here [CppInteropParseNote] // CHECK:STDERR: min_prelude/parts/destroy.carbon:32:1-39: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: @@ -402,7 +396,7 @@ fn F() { // CHECK:STDOUT: %SubobjectDestroy.facet.e5d: %SubobjectDestroy.type = facet_value %ProtectedDestructor, (%custom_witness.fe1) [concrete] // CHECK:STDOUT: %DestroyImpl.impl_witness.721: = impl_witness imports.%DestroyImpl.impl_witness_table, @T.as_type.as.DestroyImpl.impl(%SubobjectDestroy.facet.e5d) [concrete] // CHECK:STDOUT: %Destroy.facet.fe4: %Destroy.type = facet_value %ProtectedDestructor, (%DestroyImpl.impl_witness.721, %custom_witness.fe1) [concrete] -// CHECK:STDOUT: %SubobjectDestroy.WithSelf.Op.type.6870fd.2: type = fn_type @SubobjectDestroy.WithSelf.Op.loc17_3.2 [concrete] +// CHECK:STDOUT: %SubobjectDestroy.WithSelf.Op.type.6870fd.2: type = fn_type @SubobjectDestroy.WithSelf.Op.loc16_3.2 [concrete] // CHECK:STDOUT: %SubobjectDestroy.WithSelf.Op.30f1ee.2: %SubobjectDestroy.WithSelf.Op.type.6870fd.2 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.b80ef6.2: = custom_witness (%SubobjectDestroy.WithSelf.Op.30f1ee.2), @SubobjectDestroy [concrete] // CHECK:STDOUT: %SubobjectDestroy.facet.1fc: %SubobjectDestroy.type = facet_value %Derived, (%custom_witness.b80ef6.2) [concrete] @@ -418,52 +412,52 @@ fn F() { // CHECK:STDOUT: fn @DestroyClassWithProtectedBaseDestructor() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.var: ref %Derived = var_storage %a.var_patt -// CHECK:STDOUT: %.loc17_37.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct.a40] -// CHECK:STDOUT: %.loc17_38.1: %struct_type.base.f5e = struct_literal (%.loc17_37.1) [concrete = constants.%struct] -// CHECK:STDOUT: %.loc17_38.2: ref %.a6c = class_element_access %a.var, element0 -// CHECK:STDOUT: %.loc17_37.2: init %.a6c to %.loc17_38.2 = class_init () [concrete = constants.%empty_struct.ec1] -// CHECK:STDOUT: %.loc17_38.3: init %.a6c = converted %.loc17_37.1, %.loc17_37.2 [concrete = constants.%empty_struct.ec1] -// CHECK:STDOUT: %.loc17_38.4: init %ProtectedDestructor = as_compatible %.loc17_38.3 [concrete = constants.%ProtectedDestructor.val] -// CHECK:STDOUT: %.loc17_38.5: init %Derived to %a.var = class_init (%.loc17_38.4) [concrete = constants.%Derived.val] -// CHECK:STDOUT: %.loc17_3.1: init %Derived = converted %.loc17_38.1, %.loc17_38.5 [concrete = constants.%Derived.val] -// CHECK:STDOUT: assign %a.var, %.loc17_3.1 +// CHECK:STDOUT: %.loc16_37.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct.a40] +// CHECK:STDOUT: %.loc16_38.1: %struct_type.base.f5e = struct_literal (%.loc16_37.1) [concrete = constants.%struct] +// CHECK:STDOUT: %.loc16_38.2: ref %.a6c = class_element_access %a.var, element0 +// CHECK:STDOUT: %.loc16_37.2: init %.a6c to %.loc16_38.2 = class_init () [concrete = constants.%empty_struct.ec1] +// CHECK:STDOUT: %.loc16_38.3: init %.a6c = converted %.loc16_37.1, %.loc16_37.2 [concrete = constants.%empty_struct.ec1] +// CHECK:STDOUT: %.loc16_38.4: init %ProtectedDestructor = as_compatible %.loc16_38.3 [concrete = constants.%ProtectedDestructor.val] +// CHECK:STDOUT: %.loc16_38.5: init %Derived to %a.var = class_init (%.loc16_38.4) [concrete = constants.%Derived.val] +// CHECK:STDOUT: %.loc16_3.1: init %Derived = converted %.loc16_38.1, %.loc16_38.5 [concrete = constants.%Derived.val] +// CHECK:STDOUT: assign %a.var, %.loc16_3.1 // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived] // CHECK:STDOUT: %a: ref %Derived = wrapper_binding a, %a.var // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %a.patt: %pattern_type.746 = ref_binding_pattern a [concrete = constants.%a.patt] // CHECK:STDOUT: %a.var_patt: %pattern_type.746 = var_pattern %a.patt [concrete = constants.%a.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Destroy.facet.loc17_3.1: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] -// CHECK:STDOUT: %.loc17_3.2: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc17_3.1 [concrete = constants.%Destroy.facet.35d] -// CHECK:STDOUT: %Destroy.facet.loc17_3.2: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] -// CHECK:STDOUT: %.loc17_3.3: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc17_3.2 [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %Destroy.facet.loc16_3.1: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %.loc16_3.2: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc16_3.1 [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %Destroy.facet.loc16_3.2: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %.loc16_3.3: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc16_3.2 [concrete = constants.%Destroy.facet.35d] // CHECK:STDOUT: // CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%a.var) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc17_3.1(%self.param: ref %struct_type.base.454) { +// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc16_3.1(%self.param: ref %struct_type.base.454) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc17_3.1: ref %ProtectedDestructor = struct_access %self.param, element0 -// CHECK:STDOUT: %Destroy.facet.loc17_3.1: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] -// CHECK:STDOUT: %.loc17_3.2: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc17_3.1 [concrete = constants.%Destroy.facet.fe4] -// CHECK:STDOUT: %Destroy.facet.loc17_3.2: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] -// CHECK:STDOUT: %.loc17_3.3: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc17_3.2 [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %.loc16_3.1: ref %ProtectedDestructor = struct_access %self.param, element0 +// CHECK:STDOUT: %Destroy.facet.loc16_3.1: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %.loc16_3.2: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc16_3.1 [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %Destroy.facet.loc16_3.2: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %.loc16_3.3: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc16_3.2 [concrete = constants.%Destroy.facet.fe4] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc17_3.1) +// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc16_3.1) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc17_3.2(%self.param: ref %Derived) { +// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc16_3.2(%self.param: ref %Derived) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %base.ref: %Derived.elem = name_ref base, @Derived.%.loc7 [concrete = @Derived.%.loc7] -// CHECK:STDOUT: %.loc17_3.1: ref %ProtectedDestructor = class_element_access %self.param, element0 -// CHECK:STDOUT: %Destroy.facet.loc17_3.1: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] -// CHECK:STDOUT: %.loc17_3.2: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc17_3.1 [concrete = constants.%Destroy.facet.fe4] -// CHECK:STDOUT: %Destroy.facet.loc17_3.2: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] -// CHECK:STDOUT: %.loc17_3.3: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc17_3.2 [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %.loc16_3.1: ref %ProtectedDestructor = class_element_access %self.param, element0 +// CHECK:STDOUT: %Destroy.facet.loc16_3.1: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %.loc16_3.2: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc16_3.1 [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %Destroy.facet.loc16_3.2: %Destroy.type = facet_value constants.%ProtectedDestructor, (constants.%DestroyImpl.impl_witness.721, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.fe4] +// CHECK:STDOUT: %.loc16_3.3: %Destroy.type = converted constants.%ProtectedDestructor, %Destroy.facet.loc16_3.2 [concrete = constants.%Destroy.facet.fe4] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc17_3.1) +// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc16_3.1) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -498,7 +492,7 @@ fn F() { // CHECK:STDOUT: %SubobjectDestroy.facet.be1: %SubobjectDestroy.type = facet_value %PrivateDestructor, (%custom_witness.fe1) [concrete] // CHECK:STDOUT: %DestroyImpl.impl_witness.a8a: = impl_witness imports.%DestroyImpl.impl_witness_table, @T.as_type.as.DestroyImpl.impl(%SubobjectDestroy.facet.be1) [concrete] // CHECK:STDOUT: %Destroy.facet.75a: %Destroy.type = facet_value %PrivateDestructor, (%DestroyImpl.impl_witness.a8a, %custom_witness.fe1) [concrete] -// CHECK:STDOUT: %SubobjectDestroy.WithSelf.Op.type.6870fd.2: type = fn_type @SubobjectDestroy.WithSelf.Op.loc18_3.2 [concrete] +// CHECK:STDOUT: %SubobjectDestroy.WithSelf.Op.type.6870fd.2: type = fn_type @SubobjectDestroy.WithSelf.Op.loc17_3.2 [concrete] // CHECK:STDOUT: %SubobjectDestroy.WithSelf.Op.30f1ee.2: %SubobjectDestroy.WithSelf.Op.type.6870fd.2 = struct_value () [concrete] // CHECK:STDOUT: %custom_witness.b80ef6.2: = custom_witness (%SubobjectDestroy.WithSelf.Op.30f1ee.2), @SubobjectDestroy [concrete] // CHECK:STDOUT: %SubobjectDestroy.facet.1fc: %SubobjectDestroy.type = facet_value %Derived, (%custom_witness.b80ef6.2) [concrete] @@ -514,52 +508,52 @@ fn F() { // CHECK:STDOUT: fn @DestroyClassWithPrivateBaseDestructor() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.var: ref %Derived = var_storage %a.var_patt -// CHECK:STDOUT: %.loc18_37.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct.a40] -// CHECK:STDOUT: %.loc18_38.1: %struct_type.base.f5e = struct_literal (%.loc18_37.1) [concrete = constants.%struct] -// CHECK:STDOUT: %.loc18_38.2: ref %.c73 = class_element_access %a.var, element0 -// CHECK:STDOUT: %.loc18_37.2: init %.c73 to %.loc18_38.2 = class_init () [concrete = constants.%empty_struct.d8b] -// CHECK:STDOUT: %.loc18_38.3: init %.c73 = converted %.loc18_37.1, %.loc18_37.2 [concrete = constants.%empty_struct.d8b] -// CHECK:STDOUT: %.loc18_38.4: init %PrivateDestructor = as_compatible %.loc18_38.3 [concrete = constants.%PrivateDestructor.val] -// CHECK:STDOUT: %.loc18_38.5: init %Derived to %a.var = class_init (%.loc18_38.4) [concrete = constants.%Derived.val] -// CHECK:STDOUT: %.loc18_3.1: init %Derived = converted %.loc18_38.1, %.loc18_38.5 [concrete = constants.%Derived.val] -// CHECK:STDOUT: assign %a.var, %.loc18_3.1 +// CHECK:STDOUT: %.loc17_37.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct.a40] +// CHECK:STDOUT: %.loc17_38.1: %struct_type.base.f5e = struct_literal (%.loc17_37.1) [concrete = constants.%struct] +// CHECK:STDOUT: %.loc17_38.2: ref %.c73 = class_element_access %a.var, element0 +// CHECK:STDOUT: %.loc17_37.2: init %.c73 to %.loc17_38.2 = class_init () [concrete = constants.%empty_struct.d8b] +// CHECK:STDOUT: %.loc17_38.3: init %.c73 = converted %.loc17_37.1, %.loc17_37.2 [concrete = constants.%empty_struct.d8b] +// CHECK:STDOUT: %.loc17_38.4: init %PrivateDestructor = as_compatible %.loc17_38.3 [concrete = constants.%PrivateDestructor.val] +// CHECK:STDOUT: %.loc17_38.5: init %Derived to %a.var = class_init (%.loc17_38.4) [concrete = constants.%Derived.val] +// CHECK:STDOUT: %.loc17_3.1: init %Derived = converted %.loc17_38.1, %.loc17_38.5 [concrete = constants.%Derived.val] +// CHECK:STDOUT: assign %a.var, %.loc17_3.1 // CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived] // CHECK:STDOUT: %a: ref %Derived = wrapper_binding a, %a.var // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %a.patt: %pattern_type.746 = ref_binding_pattern a [concrete = constants.%a.patt] // CHECK:STDOUT: %a.var_patt: %pattern_type.746 = var_pattern %a.patt [concrete = constants.%a.var_patt] // CHECK:STDOUT: } -// CHECK:STDOUT: %Destroy.facet.loc18_3.1: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] -// CHECK:STDOUT: %.loc18_3.2: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc18_3.1 [concrete = constants.%Destroy.facet.35d] -// CHECK:STDOUT: %Destroy.facet.loc18_3.2: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] -// CHECK:STDOUT: %.loc18_3.3: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc18_3.2 [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %Destroy.facet.loc17_3.1: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %.loc17_3.2: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc17_3.1 [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %Destroy.facet.loc17_3.2: %Destroy.type = facet_value constants.%Derived, (constants.%DestroyImpl.impl_witness.660, constants.%custom_witness.b80ef6.2) [concrete = constants.%Destroy.facet.35d] +// CHECK:STDOUT: %.loc17_3.3: %Destroy.type = converted constants.%Derived, %Destroy.facet.loc17_3.2 [concrete = constants.%Destroy.facet.35d] // CHECK:STDOUT: // CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%a.var) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc18_3.1(%self.param: ref %struct_type.base.9aa) { +// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc17_3.1(%self.param: ref %struct_type.base.9aa) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc18_3.1: ref %PrivateDestructor = struct_access %self.param, element0 -// CHECK:STDOUT: %Destroy.facet.loc18_3.1: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] -// CHECK:STDOUT: %.loc18_3.2: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc18_3.1 [concrete = constants.%Destroy.facet.75a] -// CHECK:STDOUT: %Destroy.facet.loc18_3.2: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] -// CHECK:STDOUT: %.loc18_3.3: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc18_3.2 [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %.loc17_3.1: ref %PrivateDestructor = struct_access %self.param, element0 +// CHECK:STDOUT: %Destroy.facet.loc17_3.1: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %.loc17_3.2: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc17_3.1 [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %Destroy.facet.loc17_3.2: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %.loc17_3.3: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc17_3.2 [concrete = constants.%Destroy.facet.75a] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc18_3.1) +// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc17_3.1) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc18_3.2(%self.param: ref %Derived) { +// CHECK:STDOUT: fn @SubobjectDestroy.WithSelf.Op.loc17_3.2(%self.param: ref %Derived) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %base.ref: %Derived.elem = name_ref base, @Derived.%.loc7 [concrete = @Derived.%.loc7] -// CHECK:STDOUT: %.loc18_3.1: ref %PrivateDestructor = class_element_access %self.param, element0 -// CHECK:STDOUT: %Destroy.facet.loc18_3.1: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] -// CHECK:STDOUT: %.loc18_3.2: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc18_3.1 [concrete = constants.%Destroy.facet.75a] -// CHECK:STDOUT: %Destroy.facet.loc18_3.2: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] -// CHECK:STDOUT: %.loc18_3.3: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc18_3.2 [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %.loc17_3.1: ref %PrivateDestructor = class_element_access %self.param, element0 +// CHECK:STDOUT: %Destroy.facet.loc17_3.1: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %.loc17_3.2: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc17_3.1 [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %Destroy.facet.loc17_3.2: %Destroy.type = facet_value constants.%PrivateDestructor, (constants.%DestroyImpl.impl_witness.a8a, constants.%custom_witness.fe1) [concrete = constants.%Destroy.facet.75a] +// CHECK:STDOUT: %.loc17_3.3: %Destroy.type = converted constants.%PrivateDestructor, %Destroy.facet.loc17_3.2 [concrete = constants.%Destroy.facet.75a] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc18_3.1) +// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc17_3.1) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon b/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon index cadb3a4ab7d1..d589da97f037 100644 --- a/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon +++ b/toolchain/check/testdata/interop/cpp/impls/implicit_as.carbon @@ -107,8 +107,7 @@ import Cpp library "implicit_conversions.h"; fn InaccessibleConstructorTest(s: Cpp.Source) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_access.carbon:[[@LINE+4]]:40: error: cannot access private member `InaccessibleConstructor` of type `Cpp.InaccessibleConstructor` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_access.carbon:[[@LINE-5]]:10 [InCppInclude] + // CHECK:STDERR: fail_access.carbon:[[@LINE+3]]:40: error: cannot access private member `InaccessibleConstructor` of type `Cpp.InaccessibleConstructor` [ClassInvalidMemberAccess] // CHECK:STDERR: ./implicit_conversions.h:21:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: let _: Cpp.InaccessibleConstructor = s; @@ -117,8 +116,7 @@ fn InaccessibleConstructorTest(s: Cpp.Source) { fn InaccessibleConversionTest(s: Cpp.InaccessibleConversion) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_access.carbon:[[@LINE+4]]:21: error: cannot access private member `` of type `Cpp.InaccessibleConversion` [ClassInvalidMemberAccess] - // CHECK:STDERR: included from: fail_access.carbon:[[@LINE-15]]:10 [InCppInclude] + // CHECK:STDERR: fail_access.carbon:[[@LINE+3]]:21: error: cannot access private member `` of type `Cpp.InaccessibleConversion` [ClassInvalidMemberAccess] // CHECK:STDERR: ./implicit_conversions.h:26:3: note: declared here [ClassMemberDeclaration] // CHECK:STDERR: let _: Cpp.Dest = s; @@ -193,9 +191,8 @@ import Cpp library "implicit_conversions.h"; fn IntConstructorTest(u: u32) { //@dump-sem-ir-begin - // CHECK:STDERR: fail_no_u32_to_int_conversion_in_carbon.carbon:[[@LINE+5]]:31: error: cannot implicitly convert expression of type `u32` to `i32` [ConversionFailure] - // CHECK:STDERR: fail_no_u32_to_int_conversion_in_carbon.carbon:[[@LINE+4]]:31: note: type `u32` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] - // CHECK:STDERR: included from: fail_no_u32_to_int_conversion_in_carbon.carbon:[[@LINE-6]]:10 [InCppInclude] + // CHECK:STDERR: fail_no_u32_to_int_conversion_in_carbon.carbon:[[@LINE+4]]:31: error: cannot implicitly convert expression of type `u32` to `i32` [ConversionFailure] + // CHECK:STDERR: fail_no_u32_to_int_conversion_in_carbon.carbon:[[@LINE+3]]:31: note: type `u32` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: ./implicit_conversions.h:38:21: note: initializing function parameter [InCallToFunctionParam] // CHECK:STDERR: let _: Cpp.IntConstructor = u; @@ -602,56 +599,56 @@ fn InitFromStruct() { // CHECK:STDOUT: fn @InaccessibleConstructorTest(%s.param: %Source) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %s.ref: %Source = name_ref s, %s -// CHECK:STDOUT: %.loc12_40.1: ref %InaccessibleConstructor = temporary_storage -// CHECK:STDOUT: %.loc12_40.2: ref %Source = value_as_ref %s.ref -// CHECK:STDOUT: %addr.loc12_40.1: %ptr.5f6 = addr_of %.loc12_40.2 -// CHECK:STDOUT: %addr.loc12_40.2: %ptr.859 = addr_of %.loc12_40.1 -// CHECK:STDOUT: %InaccessibleConstructor__carbon_thunk.call: init %empty_tuple.type = call imports.%InaccessibleConstructor__carbon_thunk.decl(%addr.loc12_40.1, %addr.loc12_40.2) -// CHECK:STDOUT: %.loc12_40.3: init %InaccessibleConstructor to %.loc12_40.1 = mark_in_place_init %InaccessibleConstructor__carbon_thunk.call -// CHECK:STDOUT: %.loc12_40.4: init %InaccessibleConstructor = converted %s.ref, %.loc12_40.3 -// CHECK:STDOUT: %.loc12_40.5: ref %InaccessibleConstructor = temporary %.loc12_40.1, %.loc12_40.4 -// CHECK:STDOUT: %.loc12_40.6: %InaccessibleConstructor = acquire_value %.loc12_40.5 -// CHECK:STDOUT: %.loc12_13: type = splice_block %InaccessibleConstructor.ref [concrete = constants.%InaccessibleConstructor] { -// CHECK:STDOUT: %Cpp.ref.loc12: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %.loc11_40.1: ref %InaccessibleConstructor = temporary_storage +// CHECK:STDOUT: %.loc11_40.2: ref %Source = value_as_ref %s.ref +// CHECK:STDOUT: %addr.loc11_40.1: %ptr.5f6 = addr_of %.loc11_40.2 +// CHECK:STDOUT: %addr.loc11_40.2: %ptr.859 = addr_of %.loc11_40.1 +// CHECK:STDOUT: %InaccessibleConstructor__carbon_thunk.call: init %empty_tuple.type = call imports.%InaccessibleConstructor__carbon_thunk.decl(%addr.loc11_40.1, %addr.loc11_40.2) +// CHECK:STDOUT: %.loc11_40.3: init %InaccessibleConstructor to %.loc11_40.1 = mark_in_place_init %InaccessibleConstructor__carbon_thunk.call +// CHECK:STDOUT: %.loc11_40.4: init %InaccessibleConstructor = converted %s.ref, %.loc11_40.3 +// CHECK:STDOUT: %.loc11_40.5: ref %InaccessibleConstructor = temporary %.loc11_40.1, %.loc11_40.4 +// CHECK:STDOUT: %.loc11_40.6: %InaccessibleConstructor = acquire_value %.loc11_40.5 +// CHECK:STDOUT: %.loc11_13: type = splice_block %InaccessibleConstructor.ref [concrete = constants.%InaccessibleConstructor] { +// CHECK:STDOUT: %Cpp.ref.loc11: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %InaccessibleConstructor.ref: type = name_ref InaccessibleConstructor, imports.%InaccessibleConstructor.decl [concrete = constants.%InaccessibleConstructor] // CHECK:STDOUT: } -// CHECK:STDOUT: %_: %InaccessibleConstructor = wrapper_binding _, %.loc12_40.6 +// CHECK:STDOUT: %_: %InaccessibleConstructor = wrapper_binding _, %.loc11_40.6 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %_.patt: %pattern_type.824 = value_binding_pattern _ [concrete = constants.%_.patt.f1f] // CHECK:STDOUT: } -// CHECK:STDOUT: %Destroy.facet.loc12_40.1: %Destroy.type = facet_value constants.%InaccessibleConstructor, (constants.%DestroyImpl.impl_witness.8e4, constants.%custom_witness.5760f4.1) [concrete = constants.%Destroy.facet.8e3] -// CHECK:STDOUT: %.loc12_40.7: %Destroy.type = converted constants.%InaccessibleConstructor, %Destroy.facet.loc12_40.1 [concrete = constants.%Destroy.facet.8e3] -// CHECK:STDOUT: %Destroy.facet.loc12_40.2: %Destroy.type = facet_value constants.%InaccessibleConstructor, (constants.%DestroyImpl.impl_witness.8e4, constants.%custom_witness.5760f4.1) [concrete = constants.%Destroy.facet.8e3] -// CHECK:STDOUT: %.loc12_40.8: %Destroy.type = converted constants.%InaccessibleConstructor, %Destroy.facet.loc12_40.2 [concrete = constants.%Destroy.facet.8e3] +// CHECK:STDOUT: %Destroy.facet.loc11_40.1: %Destroy.type = facet_value constants.%InaccessibleConstructor, (constants.%DestroyImpl.impl_witness.8e4, constants.%custom_witness.5760f4.1) [concrete = constants.%Destroy.facet.8e3] +// CHECK:STDOUT: %.loc11_40.7: %Destroy.type = converted constants.%InaccessibleConstructor, %Destroy.facet.loc11_40.1 [concrete = constants.%Destroy.facet.8e3] +// CHECK:STDOUT: %Destroy.facet.loc11_40.2: %Destroy.type = facet_value constants.%InaccessibleConstructor, (constants.%DestroyImpl.impl_witness.8e4, constants.%custom_witness.5760f4.1) [concrete = constants.%Destroy.facet.8e3] +// CHECK:STDOUT: %.loc11_40.8: %Destroy.type = converted constants.%InaccessibleConstructor, %Destroy.facet.loc11_40.2 [concrete = constants.%Destroy.facet.8e3] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc12_40.5) +// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc11_40.5) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @InaccessibleConversionTest(%s.param: %InaccessibleConversion) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %s.ref: %InaccessibleConversion = name_ref s, %s -// CHECK:STDOUT: %.loc22_21.1: ref %Dest = temporary_storage -// CHECK:STDOUT: %addr: %ptr.ca8 = addr_of %.loc22_21.1 +// CHECK:STDOUT: %.loc20_21.1: ref %Dest = temporary_storage +// CHECK:STDOUT: %addr: %ptr.ca8 = addr_of %.loc20_21.1 // CHECK:STDOUT: %Dest__carbon_thunk.call: init %empty_tuple.type = call imports.%Dest__carbon_thunk.decl(%s.ref, %addr) -// CHECK:STDOUT: %.loc22_21.2: init %Dest to %.loc22_21.1 = mark_in_place_init %Dest__carbon_thunk.call -// CHECK:STDOUT: %.loc22_21.3: init %Dest = converted %s.ref, %.loc22_21.2 -// CHECK:STDOUT: %.loc22_21.4: ref %Dest = temporary %.loc22_21.1, %.loc22_21.3 -// CHECK:STDOUT: %.loc22_21.5: %Dest = acquire_value %.loc22_21.4 -// CHECK:STDOUT: %.loc22_13: type = splice_block %Dest.ref [concrete = constants.%Dest] { -// CHECK:STDOUT: %Cpp.ref.loc22: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %.loc20_21.2: init %Dest to %.loc20_21.1 = mark_in_place_init %Dest__carbon_thunk.call +// CHECK:STDOUT: %.loc20_21.3: init %Dest = converted %s.ref, %.loc20_21.2 +// CHECK:STDOUT: %.loc20_21.4: ref %Dest = temporary %.loc20_21.1, %.loc20_21.3 +// CHECK:STDOUT: %.loc20_21.5: %Dest = acquire_value %.loc20_21.4 +// CHECK:STDOUT: %.loc20_13: type = splice_block %Dest.ref [concrete = constants.%Dest] { +// CHECK:STDOUT: %Cpp.ref.loc20: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %Dest.ref: type = name_ref Dest, imports.%Dest.decl [concrete = constants.%Dest] // CHECK:STDOUT: } -// CHECK:STDOUT: %_: %Dest = wrapper_binding _, %.loc22_21.5 +// CHECK:STDOUT: %_: %Dest = wrapper_binding _, %.loc20_21.5 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %_.patt: %pattern_type.b72 = value_binding_pattern _ [concrete = constants.%_.patt.664] // CHECK:STDOUT: } -// CHECK:STDOUT: %Destroy.facet.loc22_21.1: %Destroy.type = facet_value constants.%Dest, (constants.%DestroyImpl.impl_witness.771, constants.%custom_witness.5760f4.2) [concrete = constants.%Destroy.facet.bbf] -// CHECK:STDOUT: %.loc22_21.6: %Destroy.type = converted constants.%Dest, %Destroy.facet.loc22_21.1 [concrete = constants.%Destroy.facet.bbf] -// CHECK:STDOUT: %Destroy.facet.loc22_21.2: %Destroy.type = facet_value constants.%Dest, (constants.%DestroyImpl.impl_witness.771, constants.%custom_witness.5760f4.2) [concrete = constants.%Destroy.facet.bbf] -// CHECK:STDOUT: %.loc22_21.7: %Destroy.type = converted constants.%Dest, %Destroy.facet.loc22_21.2 [concrete = constants.%Destroy.facet.bbf] +// CHECK:STDOUT: %Destroy.facet.loc20_21.1: %Destroy.type = facet_value constants.%Dest, (constants.%DestroyImpl.impl_witness.771, constants.%custom_witness.5760f4.2) [concrete = constants.%Destroy.facet.bbf] +// CHECK:STDOUT: %.loc20_21.6: %Destroy.type = converted constants.%Dest, %Destroy.facet.loc20_21.1 [concrete = constants.%Destroy.facet.bbf] +// CHECK:STDOUT: %Destroy.facet.loc20_21.2: %Destroy.type = facet_value constants.%Dest, (constants.%DestroyImpl.impl_witness.771, constants.%custom_witness.5760f4.2) [concrete = constants.%Destroy.facet.bbf] +// CHECK:STDOUT: %.loc20_21.7: %Destroy.type = converted constants.%Dest, %Destroy.facet.loc20_21.2 [concrete = constants.%Destroy.facet.bbf] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc22_21.4) +// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc20_21.4) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: @@ -884,28 +881,28 @@ fn InitFromStruct() { // CHECK:STDOUT: fn @IntConstructorTest(%u.param: %u32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %u.ref: %u32 = name_ref u, %u -// CHECK:STDOUT: %.loc13_31.1: ref %IntConstructor = temporary_storage -// CHECK:STDOUT: %.loc13_31.2: %i32 = converted %u.ref, [concrete = ] -// CHECK:STDOUT: %addr: %ptr.100 = addr_of %.loc13_31.1 +// CHECK:STDOUT: %.loc12_31.1: ref %IntConstructor = temporary_storage +// CHECK:STDOUT: %.loc12_31.2: %i32 = converted %u.ref, [concrete = ] +// CHECK:STDOUT: %addr: %ptr.100 = addr_of %.loc12_31.1 // CHECK:STDOUT: %IntConstructor__carbon_thunk.call: init %empty_tuple.type = call imports.%IntConstructor__carbon_thunk.decl(, %addr) -// CHECK:STDOUT: %.loc13_31.3: init %IntConstructor to %.loc13_31.1 = mark_in_place_init %IntConstructor__carbon_thunk.call -// CHECK:STDOUT: %.loc13_31.4: init %IntConstructor = converted %u.ref, %.loc13_31.3 -// CHECK:STDOUT: %.loc13_31.5: ref %IntConstructor = temporary %.loc13_31.1, %.loc13_31.4 -// CHECK:STDOUT: %.loc13_31.6: %IntConstructor = acquire_value %.loc13_31.5 -// CHECK:STDOUT: %.loc13_13: type = splice_block %IntConstructor.ref [concrete = constants.%IntConstructor] { +// CHECK:STDOUT: %.loc12_31.3: init %IntConstructor to %.loc12_31.1 = mark_in_place_init %IntConstructor__carbon_thunk.call +// CHECK:STDOUT: %.loc12_31.4: init %IntConstructor = converted %u.ref, %.loc12_31.3 +// CHECK:STDOUT: %.loc12_31.5: ref %IntConstructor = temporary %.loc12_31.1, %.loc12_31.4 +// CHECK:STDOUT: %.loc12_31.6: %IntConstructor = acquire_value %.loc12_31.5 +// CHECK:STDOUT: %.loc12_13: type = splice_block %IntConstructor.ref [concrete = constants.%IntConstructor] { // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %IntConstructor.ref: type = name_ref IntConstructor, imports.%IntConstructor.decl [concrete = constants.%IntConstructor] // CHECK:STDOUT: } -// CHECK:STDOUT: %_: %IntConstructor = wrapper_binding _, %.loc13_31.6 +// CHECK:STDOUT: %_: %IntConstructor = wrapper_binding _, %.loc12_31.6 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %_.patt: %pattern_type.c4e = value_binding_pattern _ [concrete = constants.%_.patt.151] // CHECK:STDOUT: } -// CHECK:STDOUT: %Destroy.facet.loc13_31.1: %Destroy.type = facet_value constants.%IntConstructor, (constants.%DestroyImpl.impl_witness.1d9, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %.loc13_31.7: %Destroy.type = converted constants.%IntConstructor, %Destroy.facet.loc13_31.1 [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %Destroy.facet.loc13_31.2: %Destroy.type = facet_value constants.%IntConstructor, (constants.%DestroyImpl.impl_witness.1d9, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] -// CHECK:STDOUT: %.loc13_31.8: %Destroy.type = converted constants.%IntConstructor, %Destroy.facet.loc13_31.2 [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %Destroy.facet.loc12_31.1: %Destroy.type = facet_value constants.%IntConstructor, (constants.%DestroyImpl.impl_witness.1d9, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %.loc12_31.7: %Destroy.type = converted constants.%IntConstructor, %Destroy.facet.loc12_31.1 [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %Destroy.facet.loc12_31.2: %Destroy.type = facet_value constants.%IntConstructor, (constants.%DestroyImpl.impl_witness.1d9, constants.%custom_witness.576) [concrete = constants.%Destroy.facet] +// CHECK:STDOUT: %.loc12_31.8: %Destroy.type = converted constants.%IntConstructor, %Destroy.facet.loc12_31.2 [concrete = constants.%Destroy.facet] // CHECK:STDOUT: -// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc13_31.5) +// CHECK:STDOUT: %SelfDestruct.call: init %empty_tuple.type = call %SelfDestruct.specific_fn(%.loc12_31.5) // CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/namespace/import.carbon b/toolchain/check/testdata/interop/cpp/namespace/import.carbon index 6549686ff468..afbf961cb896 100644 --- a/toolchain/check/testdata/interop/cpp/namespace/import.carbon +++ b/toolchain/check/testdata/interop/cpp/namespace/import.carbon @@ -128,10 +128,9 @@ fn MyF() { // file split. // TODO: Pass a location into Clang when performing C++ name lookup so that // its error has a location attached. - // CHECK:STDERR: fail_import_inline_ambiguity.carbon:[[@LINE+6]]:3-7: error: name `error` not found [NameNotFound] + // CHECK:STDERR: fail_import_inline_ambiguity.carbon:[[@LINE+5]]:3-7: error: name `error` not found [NameNotFound] // CHECK:STDERR: // CHECK:STDERR: error: reference to 'N' is ambiguous [CppInteropParseError] - // CHECK:STDERR: included from: fail_import_inline_ambiguity.carbon:[[@LINE-11]]:10 [InCppInclude] // CHECK:STDERR: ./inline_ambiguity.h:2:11: note: candidate found by name lookup is 'N' [CppInteropParseNote] // CHECK:STDERR: ./inline_ambiguity.h:3:30: note: candidate found by name lookup is '(anonymous namespace)::N' [CppInteropParseNote] error; diff --git a/toolchain/check/testdata/interop/cpp/template/argument_count.carbon b/toolchain/check/testdata/interop/cpp/template/argument_count.carbon index 2581b25727c7..8764af56583d 100644 --- a/toolchain/check/testdata/interop/cpp/template/argument_count.carbon +++ b/toolchain/check/testdata/interop/cpp/template/argument_count.carbon @@ -45,8 +45,7 @@ library "[[@TEST_NAME]]"; import Cpp library "templates.h"; -// CHECK:STDERR: fail_too_few_arguments.carbon:[[@LINE+4]]:26: error: too few template arguments for class template 'TwoTypes' [CppInteropParseError] -// CHECK:STDERR: included from: fail_too_few_arguments.carbon:[[@LINE-3]]:10 [InCppInclude] +// 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: var x: Cpp.TwoTypes(Cpp.A); @@ -57,8 +56,7 @@ library "[[@TEST_NAME]]"; import Cpp library "templates.h"; -// CHECK:STDERR: fail_too_many_arguments.carbon:[[@LINE+4]]:38-40: error: too many template arguments for class template 'TwoTypes' [CppInteropParseError] -// CHECK:STDERR: included from: fail_too_many_arguments.carbon:[[@LINE-3]]:10 [InCppInclude] +// 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: var x: Cpp.TwoTypes(Cpp.A, Cpp.A, Cpp.A); @@ -90,14 +88,12 @@ library "[[@TEST_NAME]]"; import Cpp library "templates.h"; -// CHECK:STDERR: fail_fixed_size_pack_wrong_size.carbon:[[@LINE+4]]:57: error: too few template arguments for class template 'Inner' [CppInteropParseError] -// CHECK:STDERR: included from: fail_fixed_size_pack_wrong_size.carbon:[[@LINE-3]]:10 [InCppInclude] +// 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: var too_few: Cpp.FixedSizePack(Cpp.A, Cpp.A).Inner(Cpp.B); -// CHECK:STDERR: fail_fixed_size_pack_wrong_size.carbon:[[@LINE+4]]:70-72: error: too many template arguments for class template 'Inner' [CppInteropParseError] -// CHECK:STDERR: included from: fail_fixed_size_pack_wrong_size.carbon:[[@LINE-9]]:10 [InCppInclude] +// 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: var too_many: Cpp.FixedSizePack(Cpp.A, Cpp.A).Inner(Cpp.B, Cpp.B, Cpp.B); diff --git a/toolchain/check/testdata/interop/cpp/template/template_template_param.carbon b/toolchain/check/testdata/interop/cpp/template/template_template_param.carbon index 38c2a90c9e07..43b2f60ff793 100644 --- a/toolchain/check/testdata/interop/cpp/template/template_template_param.carbon +++ b/toolchain/check/testdata/interop/cpp/template/template_template_param.carbon @@ -36,9 +36,8 @@ library "[[@TEST_NAME]]"; import Cpp library "templates.h"; //@dump-sem-ir-begin -// CHECK:STDERR: fail_template_mismatch.carbon:[[@LINE+6]]:35: error: too few template arguments for class template 'C' [CppInteropParseError] -// CHECK:STDERR: fail_template_mismatch.carbon:[[@LINE+5]]:35: note: template template argument has different template parameters than its corresponding template template parameter [CppInteropParseNote] -// CHECK:STDERR: included from: fail_template_mismatch.carbon:[[@LINE-5]]:10 [InCppInclude] +// 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: diff --git a/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon b/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon index 19a2cf8b3dbd..903071ae688b 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_after_merge.carbon @@ -28,8 +28,7 @@ import library "namespace"; // imported declaration. namespace NS; -// CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:4-5: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE-7]]:1 [InImport] +// CHECK:STDERR: fail_conflict.carbon:[[@LINE+3]]:4-5: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: namespace.carbon:4:1-13: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: fn NS(); @@ -38,8 +37,7 @@ fn NS(); // we don't move it. namespace NS; -// CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:4-5: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE-17]]:1 [InImport] +// CHECK:STDERR: fail_conflict.carbon:[[@LINE+3]]:4-5: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: namespace.carbon:4:1-13: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: fn NS(); @@ -66,9 +64,9 @@ fn NS(); // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: type: type = facet_type [concrete] -// CHECK:STDOUT: %NS.type.20a02b.1: type = fn_type @NS.loc14 [concrete] +// CHECK:STDOUT: %NS.type.20a02b.1: type = fn_type @NS.loc13 [concrete] // CHECK:STDOUT: %NS.bab1af.1: %NS.type.20a02b.1 = struct_value () [concrete] -// CHECK:STDOUT: %NS.type.20a02b.2: type = fn_type @NS.loc24 [concrete] +// CHECK:STDOUT: %NS.type.20a02b.2: type = fn_type @NS.loc22 [concrete] // CHECK:STDOUT: %NS.bab1af.2: %NS.type.20a02b.2 = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -89,12 +87,12 @@ fn NS(); // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %NS.loc8: = namespace imports.%Example.NS, [concrete] {} -// CHECK:STDOUT: %NS.decl.loc14: %NS.type.20a02b.1 = fn_decl @NS.loc14 [concrete = constants.%NS.bab1af.1] {} {} -// CHECK:STDOUT: %NS.loc18: = namespace imports.%Example.NS, [concrete] {} -// CHECK:STDOUT: %NS.decl.loc24: %NS.type.20a02b.2 = fn_decl @NS.loc24 [concrete = constants.%NS.bab1af.2] {} {} +// CHECK:STDOUT: %NS.decl.loc13: %NS.type.20a02b.1 = fn_decl @NS.loc13 [concrete = constants.%NS.bab1af.1] {} {} +// CHECK:STDOUT: %NS.loc17: = namespace imports.%Example.NS, [concrete] {} +// CHECK:STDOUT: %NS.decl.loc22: %NS.type.20a02b.2 = fn_decl @NS.loc22 [concrete = constants.%NS.bab1af.2] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @NS.loc14(); +// CHECK:STDOUT: fn @NS.loc13(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @NS.loc24(); +// CHECK:STDOUT: fn @NS.loc22(); // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon index f95c20b8dc42..cfe000ea66e6 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_first.carbon @@ -24,8 +24,7 @@ package Example; import library "namespace"; -// CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:4-5: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_conflict.carbon:[[@LINE+3]]:4-5: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: namespace.carbon:4:1-13: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: fn NS(); diff --git a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_nested.carbon b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_nested.carbon index 17bd0fab2b2d..5ac902ca020d 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_nested.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_nested.carbon @@ -24,8 +24,7 @@ import Other; // CHECK:STDERR: fail_conflict.carbon:[[@LINE-2]]:1-13: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: namespace Other; -// CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:10-15: error: imported packages cannot be used for declarations [QualifiedDeclOutsidePackage] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE-6]]:1 [InImport] +// CHECK:STDERR: fail_conflict.carbon:[[@LINE+3]]:10-15: error: imported packages cannot be used for declarations [QualifiedDeclOutsidePackage] // CHECK:STDERR: fn.carbon:3:1-17: note: package imported here [QualifiedDeclOutsidePackageSource] // CHECK:STDERR: fn Other.Nested.F(); diff --git a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon index a26bfb6c82f6..4189d472837a 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_imported_namespace_second.carbon @@ -24,14 +24,12 @@ package Example; import library "fn"; -// CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:11-12: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_conflict.carbon:[[@LINE+3]]:11-12: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: fn.carbon:4:1-8: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: namespace NS; -// CHECK:STDERR: fail_conflict.carbon:[[@LINE+4]]:4-5: error: name qualifiers are only allowed for entities that provide a scope [QualifiedNameInNonScope] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE-9]]:1 [InImport] +// CHECK:STDERR: fail_conflict.carbon:[[@LINE+3]]:4-5: error: name qualifiers are only allowed for entities that provide a scope [QualifiedNameInNonScope] // CHECK:STDERR: fn.carbon:4:1-8: note: referenced non-scope entity declared here [QualifiedNameNonScopeEntity] // CHECK:STDERR: fn NS.Foo(); @@ -87,7 +85,7 @@ fn NS.Foo(); // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import -// CHECK:STDOUT: %.loc10: = namespace [concrete] {} +// CHECK:STDOUT: %.loc9: = namespace [concrete] {} // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [concrete = constants.%Foo] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon index 7ba126ba458d..386cdb960aa6 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_first.carbon @@ -29,9 +29,8 @@ fn NS() {} package Example library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: fn.carbon:4:1-9: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: namespace.carbon:4:1-13: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "namespace"; diff --git a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon index 1770b090879f..6ecdac04924b 100644 --- a/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon +++ b/toolchain/check/testdata/namespace/fail_conflict_in_imports_namespace_second.carbon @@ -29,9 +29,8 @@ fn NS.Foo() {} package Example library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: namespace.carbon:4:1-13: error: duplicate name `NS` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: fn.carbon:4:1-9: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "fn"; diff --git a/toolchain/check/testdata/namespace/imported_indirect.carbon b/toolchain/check/testdata/namespace/imported_indirect.carbon index f5733a471f7d..97a4ca43549f 100644 --- a/toolchain/check/testdata/namespace/imported_indirect.carbon +++ b/toolchain/check/testdata/namespace/imported_indirect.carbon @@ -56,11 +56,10 @@ package Same library "[[@TEST_NAME]]"; import library "b"; -// CHECK:STDERR: fail_named_indirectly_same_package.carbon:[[@LINE+7]]:10-12: error: function returns incomplete type `A.C` [IncompleteTypeInFunctionReturnType] +// CHECK:STDERR: fail_named_indirectly_same_package.carbon:[[@LINE+6]]:10-12: error: function returns incomplete type `A.C` [IncompleteTypeInFunctionReturnType] // CHECK:STDERR: imported from: fail_named_indirectly_same_package.carbon:[[@LINE-3]]:1 [InImport] // CHECK:STDERR: imported from: b.carbon:3:1 [InImport] // CHECK:STDERR: a.carbon:6:1-10: note: class was forward declared here [ClassForwardDeclaredHere] -// CHECK:STDERR: imported from: fail_named_indirectly_same_package.carbon:[[@LINE-6]]:1 [InImport] // CHECK:STDERR: b.carbon:7:8-13: note: return type declared here [IncompleteReturnTypeHere] // CHECK:STDERR: fn G() { F(); } @@ -71,11 +70,10 @@ package Other library "[[@TEST_NAME]]"; import Same library "b"; -// CHECK:STDERR: fail_named_indirectly_different_package.carbon:[[@LINE+7]]:10-17: error: function returns incomplete type `Same.A.C` [IncompleteTypeInFunctionReturnType] +// CHECK:STDERR: fail_named_indirectly_different_package.carbon:[[@LINE+6]]:10-17: error: function returns incomplete type `Same.A.C` [IncompleteTypeInFunctionReturnType] // CHECK:STDERR: imported from: fail_named_indirectly_different_package.carbon:[[@LINE-3]]:1 [InImport] // CHECK:STDERR: imported from: b.carbon:3:1 [InImport] // CHECK:STDERR: a.carbon:6:1-10: note: class was forward declared here [ClassForwardDeclaredHere] -// CHECK:STDERR: imported from: fail_named_indirectly_different_package.carbon:[[@LINE-6]]:1 [InImport] // CHECK:STDERR: b.carbon:7:8-13: note: return type declared here [IncompleteReturnTypeHere] // CHECK:STDERR: fn G() { Same.F(); } diff --git a/toolchain/check/testdata/packages/cross_package_export.carbon b/toolchain/check/testdata/packages/cross_package_export.carbon index e13d824a804b..3ce1b438e024 100644 --- a/toolchain/check/testdata/packages/cross_package_export.carbon +++ b/toolchain/check/testdata/packages/cross_package_export.carbon @@ -157,9 +157,8 @@ import Other library "conflict"; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_conflict_on_export_import.carbon:[[@LINE+4]]:1 [InImport] +// CHECK:STDERR: imported from: fail_conflict_on_export_import.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: base.carbon:4:1-9: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict_on_export_import.carbon:[[@LINE+2]]:1 [InImport] // CHECK:STDERR: conflict.carbon:4:1-8: note: name is previously declared here [NameDeclPrevious] import Other library "export_import"; import Other library "conflict"; @@ -172,10 +171,8 @@ alias C = Other.C; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_conflict_on_export_name.carbon:[[@LINE+5]]:1 [InImport] -// CHECK:STDERR: conflict.carbon:4:1-8: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: imported from: fail_conflict_on_export_name.carbon:[[@LINE+3]]:1 [InImport] -// CHECK:STDERR: imported from: export_name.carbon:4:1 [InImport] +// CHECK:STDERR: conflict.carbon:4:1-8: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: base.carbon:4:1-9: note: name is previously declared here [NameDeclPrevious] import Other library "export_name"; import Other library "conflict"; diff --git a/toolchain/check/testdata/packages/cross_package_import.carbon b/toolchain/check/testdata/packages/cross_package_import.carbon index d6e440763f0e..2e8795edee27 100644 --- a/toolchain/check/testdata/packages/cross_package_import.carbon +++ b/toolchain/check/testdata/packages/cross_package_import.carbon @@ -74,9 +74,8 @@ fn Run() { library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_todo_main_use_other_extern.carbon:[[@LINE+4]]:1 [InImport] +// CHECK:STDERR: imported from: fail_todo_main_use_other_extern.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: other_fn_extern.carbon:4:1-14: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_todo_main_use_other_extern.carbon:[[@LINE+2]]:1 [InImport] // CHECK:STDERR: other_fn.carbon:4:1-8: note: name is previously declared here [NameDeclPrevious] import Other library "other_fn"; import Other library "other_fn_extern"; @@ -98,9 +97,8 @@ import Other library "other_fn_conflict"; library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_main_use_other_ambiguous.carbon:[[@LINE+4]]:1 [InImport] +// CHECK:STDERR: imported from: fail_main_use_other_ambiguous.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: other_fn_conflict.carbon:4:1-20: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_main_use_other_ambiguous.carbon:[[@LINE+2]]:1 [InImport] // CHECK:STDERR: other_fn.carbon:4:1-8: note: name is previously declared here [NameDeclPrevious] import Other library "other_fn"; import Other library "other_fn_conflict"; @@ -116,14 +114,12 @@ fn Run() { library "[[@TEST_NAME]]"; import library "main_other_ns"; -// CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+4]]:1-32: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_main_namespace_conflict.carbon:[[@LINE-2]]:1 [InImport] +// CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+3]]:1-32: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: main_other_ns.carbon:4:1-16: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import Other library "other_fn"; -// CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+4]]:1-14: error: redeclaration of `fn F` is redundant [RedeclRedundant] -// CHECK:STDERR: imported from: fail_main_namespace_conflict.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+3]]:1-14: error: redeclaration of `fn F` is redundant [RedeclRedundant] // CHECK:STDERR: other_fn.carbon:4:1-8: note: previously declared here [RedeclPrevDecl] // CHECK:STDERR: fn Other.F() {} @@ -459,7 +455,7 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: type: type = facet_type [concrete] // CHECK:STDOUT: %F.type.2a8c71.1: type = fn_type @F.1 [concrete] // CHECK:STDOUT: %F.1be9f8.1: %F.type.2a8c71.1 = struct_value () [concrete] -// CHECK:STDOUT: %F.type.2a8c71.2: type = fn_type @F.loc15 [concrete] +// CHECK:STDOUT: %F.type.2a8c71.2: type = fn_type @F.loc13 [concrete] // CHECK:STDOUT: %F.1be9f8.2: %F.type.2a8c71.2 = struct_value () [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -478,12 +474,12 @@ fn UseF() { Other.F(); } // CHECK:STDOUT: } // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Other.import = import Other -// CHECK:STDOUT: %F.decl: %F.type.2a8c71.2 = fn_decl @F.loc15 [concrete = constants.%F.1be9f8.2] {} {} +// CHECK:STDOUT: %F.decl: %F.type.2a8c71.2 = fn_decl @F.loc13 [concrete = constants.%F.1be9f8.2] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.1 [from "other_fn.carbon"]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.loc15() { +// CHECK:STDOUT: fn @F.loc13() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/packages/export_name.carbon b/toolchain/check/testdata/packages/export_name.carbon index d9cdf9038bcb..cc36d91b71ac 100644 --- a/toolchain/check/testdata/packages/export_name.carbon +++ b/toolchain/check/testdata/packages/export_name.carbon @@ -91,8 +91,7 @@ library "[[@TEST_NAME]]"; import library "base"; -// CHECK:STDERR: fail_export_ns.carbon:[[@LINE+4]]:1-10: error: only imported entities are valid for `export` [ExportNotImportedEntity] -// CHECK:STDERR: imported from: fail_export_ns.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_export_ns.carbon:[[@LINE+3]]:1-10: error: only imported entities are valid for `export` [ExportNotImportedEntity] // CHECK:STDERR: base.carbon:8:1-13: note: name is declared here [ExportNotImportedEntitySource] // CHECK:STDERR: export NS; @@ -114,8 +113,7 @@ library "[[@TEST_NAME]]"; import library "base"; -// CHECK:STDERR: fail_export_member.carbon:[[@LINE+4]]:8: error: name qualifiers are only allowed for entities that provide a scope [QualifiedNameInNonScope] -// CHECK:STDERR: imported from: fail_export_member.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_export_member.carbon:[[@LINE+3]]:8: error: name qualifiers are only allowed for entities that provide a scope [QualifiedNameInNonScope] // CHECK:STDERR: base.carbon:4:1-9: note: referenced non-scope entity declared here [QualifiedNameNonScopeEntity] // CHECK:STDERR: export C.x; diff --git a/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon b/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon index 75b03e6b4570..b962eebb5988 100644 --- a/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon +++ b/toolchain/check/testdata/packages/fail_conflict_no_namespaces.carbon @@ -28,9 +28,8 @@ var Foo: i32; package Example library "[[@TEST_NAME]]"; -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: var.carbon:4:5-12: error: duplicate name `Foo` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_conflict.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: fn.carbon:4:1-9: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import library "fn"; diff --git a/toolchain/check/testdata/packages/fail_export_name_member.carbon b/toolchain/check/testdata/packages/fail_export_name_member.carbon index c48a73893b07..50d2b18aa311 100644 --- a/toolchain/check/testdata/packages/fail_export_name_member.carbon +++ b/toolchain/check/testdata/packages/fail_export_name_member.carbon @@ -28,8 +28,7 @@ import library "a"; // TODO: This diagnostic doesn't clearly explain the problem. We should instead // say something like: Only namespace-scope names can be exported. -// CHECK:STDERR: fail_b.carbon:[[@LINE+4]]:8: error: name qualifiers are only allowed for entities that provide a scope [QualifiedNameInNonScope] -// CHECK:STDERR: imported from: fail_b.carbon:[[@LINE-5]]:1 [InImport] +// CHECK:STDERR: fail_b.carbon:[[@LINE+3]]:8: error: name qualifiers are only allowed for entities that provide a scope [QualifiedNameInNonScope] // CHECK:STDERR: a.carbon:4:1-9: note: referenced non-scope entity declared here [QualifiedNameNonScopeEntity] // CHECK:STDERR: export C.n; diff --git a/toolchain/check/testdata/packages/implicit_imports_entities.carbon b/toolchain/check/testdata/packages/implicit_imports_entities.carbon index cdd54564efef..5b95123172b7 100644 --- a/toolchain/check/testdata/packages/implicit_imports_entities.carbon +++ b/toolchain/check/testdata/packages/implicit_imports_entities.carbon @@ -135,9 +135,8 @@ import Other library "o1"; // --- fail_import_conflict.impl.carbon -// CHECK:STDERR: imported from: fail_import_conflict.impl.carbon:[[@LINE+5]]:1 [InImport] +// CHECK:STDERR: imported from: fail_import_conflict.impl.carbon:[[@LINE+4]]:1 [InImport] // CHECK:STDERR: import_conflict.carbon:4:1-26: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_import_conflict.impl.carbon:[[@LINE+3]]:1 [InImport] // CHECK:STDERR: local_other.carbon:4:1-13: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: impl library "[[@TEST_NAME]]"; @@ -154,9 +153,7 @@ import library "local_other"; impl library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_import_conflict_reverse.impl.carbon:[[@LINE+5]]:1-26: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate] -// CHECK:STDERR: imported from: fail_import_conflict_reverse.impl.carbon:[[@LINE-3]]:1 [InImport] -// CHECK:STDERR: imported from: import_conflict_reverse.carbon:4:1 [InImport] +// CHECK:STDERR: fail_import_conflict_reverse.impl.carbon:[[@LINE+3]]:1-26: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate] // CHECK:STDERR: local_other.carbon:4:1-13: note: name is previously declared here [NameDeclPrevious] // CHECK:STDERR: import Other library "o1"; @@ -751,8 +748,8 @@ import Other library "o1"; // CHECK:STDOUT: package: = namespace [concrete] { // CHECK:STDOUT: .Other = imports.%Other // CHECK:STDOUT: } -// CHECK:STDOUT: %default.import.loc7_31.1 = import -// CHECK:STDOUT: %default.import.loc7_31.2 = import +// CHECK:STDOUT: %default.import.loc6_31.1 = import +// CHECK:STDOUT: %default.import.loc6_31.2 = import // CHECK:STDOUT: %Other.import = import Other // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/import.carbon b/toolchain/check/testdata/struct/import.carbon index fb3fa6949c80..635dec98503f 100644 --- a/toolchain/check/testdata/struct/import.carbon +++ b/toolchain/check/testdata/struct/import.carbon @@ -34,8 +34,7 @@ var c: C({.a = 1, .b = 2}) = F(); // --- fail_bad_type.impl.carbon impl package Implicit; -// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+4]]:14-29: error: struct `{.a: i32, .b: i32}` has no field named `c` [StructInitUnexpectedFieldInLiteral] -// CHECK:STDERR: imported from: fail_bad_type.impl.carbon:[[@LINE-2]]:1 [InImport] +// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+3]]:14-29: error: struct `{.a: i32, .b: i32}` has no field named `c` [StructInitUnexpectedFieldInLiteral] // CHECK:STDERR: implicit.carbon:8:9-29: note: initializing generic parameter `S` declared here [InitializingGenericParam] // CHECK:STDERR: var c_bad: C({.c = 1, .d = 2}) = F(); diff --git a/toolchain/check/testdata/tuple/import.carbon b/toolchain/check/testdata/tuple/import.carbon index a087a39086e6..d34b91479285 100644 --- a/toolchain/check/testdata/tuple/import.carbon +++ b/toolchain/check/testdata/tuple/import.carbon @@ -35,8 +35,7 @@ var c: C((1, 2)) = F(); impl package Implicit; -// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+4]]:14-22: error: cannot initialize tuple of 2 elements from tuple with 3 elements [TupleInitElementCountMismatch] -// CHECK:STDERR: imported from: fail_bad_type.impl.carbon:[[@LINE-3]]:1 [InImport] +// CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+3]]:14-22: error: cannot initialize tuple of 2 elements from tuple with 3 elements [TupleInitElementCountMismatch] // CHECK:STDERR: implicit.carbon:7:9-21: note: initializing generic parameter `X` declared here [InitializingGenericParam] // CHECK:STDERR: var c_bad: C((1, 2, 3)) = F(); diff --git a/toolchain/check/testdata/where_expr/constraints.carbon b/toolchain/check/testdata/where_expr/constraints.carbon index 074d8fc980bf..1231881f2be3 100644 --- a/toolchain/check/testdata/where_expr/constraints.carbon +++ b/toolchain/check/testdata/where_expr/constraints.carbon @@ -120,8 +120,7 @@ class C {} impl C as J {} fn DoesNotImplI() { - // CHECK:STDERR: fail_enforce_impls_constraint.carbon:[[@LINE+4]]:3-10: error: cannot convert type `C` into type implementing `J where .Self impls I` [ConversionFailureTypeToFacet] - // CHECK:STDERR: imported from: fail_enforce_impls_constraint.carbon:[[@LINE-8]]:1 [InImport] + // CHECK:STDERR: fail_enforce_impls_constraint.carbon:[[@LINE+3]]:3-10: error: cannot convert type `C` into type implementing `J where .Self impls I` [ConversionFailureTypeToFacet] // CHECK:STDERR: state_constraints.carbon:14:18-41: note: initializing generic parameter `V` declared here [InitializingGenericParam] // CHECK:STDERR: Impls(C); diff --git a/toolchain/check/testdata/where_expr/equal_rewrite.carbon b/toolchain/check/testdata/where_expr/equal_rewrite.carbon index a88c522c696f..c3a7c07fb190 100644 --- a/toolchain/check/testdata/where_expr/equal_rewrite.carbon +++ b/toolchain/check/testdata/where_expr/equal_rewrite.carbon @@ -115,14 +115,12 @@ import library "equal_constraint"; import library "nested_rewrites"; fn Calls() { - // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE+4]]:3-13: error: cannot convert type `bool` into type implementing `N where .(N.P) = {}` [ConversionFailureTypeToFacet] - // CHECK:STDERR: imported from: fail_import_rewrites.carbon:[[@LINE-5]]:1 [InImport] + // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE+3]]:3-13: error: cannot convert type `bool` into type implementing `N where .(N.P) = {}` [ConversionFailureTypeToFacet] // CHECK:STDERR: equal_constraint.carbon:9:18-35: note: initializing generic parameter `T` declared here [InitializingGenericParam] // CHECK:STDERR: Equal(bool); - // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE+4]]:3-20: error: cannot convert type `i32` into type implementing `A where .(A.C) = () and .(A.B) = bool` [ConversionFailureTypeToFacet] - // CHECK:STDERR: imported from: fail_import_rewrites.carbon:[[@LINE-11]]:1 [InImport] + // CHECK:STDERR: fail_import_rewrites.carbon:[[@LINE+3]]:3-20: error: cannot convert type `i32` into type implementing `A where .(A.C) = () and .(A.B) = bool` [ConversionFailureTypeToFacet] // CHECK:STDERR: nested_rewrites.carbon:10:26-61: note: initializing generic parameter `D` declared here [InitializingGenericParam] // CHECK:STDERR: NestedRewrite(i32); diff --git a/toolchain/diagnostics/diagnostic.h b/toolchain/diagnostics/diagnostic.h index 2089c51c05d8..1ace7da36dc8 100644 --- a/toolchain/diagnostics/diagnostic.h +++ b/toolchain/diagnostics/diagnostic.h @@ -362,8 +362,8 @@ struct Diagnostic { // A context names the operation that failed, and when a diagnostic has one that // is what the reader is told about; the message is then read against the code // like anything else explaining it. Anything presenting a diagnostic as a -// single sentence -- the headline of the rendering, an editor's hover text -- -// wants this rather than the message. +// single sentence, such as an editor's hover text, uses this instead of the +// message. inline auto LeadingContext(const Diagnostic& diagnostic) -> const Context* { return diagnostic.contexts.empty() ? nullptr : &diagnostic.contexts.front(); } diff --git a/toolchain/diagnostics/renderer.cpp b/toolchain/diagnostics/renderer.cpp index 58ce49969cc2..f3fa8c1e090a 100644 --- a/toolchain/diagnostics/renderer.cpp +++ b/toolchain/diagnostics/renderer.cpp @@ -32,13 +32,13 @@ using Terminal::Metrics; using Terminal::Style; // The columns from the frame to the content beside it: the frame itself, and -// the stub next to it that a source row leaves blank. +// the column next to it that a source row leaves blank. static constexpr int FrameToContentWidth = 2; -// Points at the lines the problem is on -- every line holding a range that is -// part of it -- from the margin outside the line numbers. A merged snippet can -// open on some other line, so without this there is nothing saying which lines -// the problem is actually on. +// Points, from the margin outside the line numbers, to the one row to begin +// reading at: the source row the leading part's text is placed under, or that +// part's location row when it has no source. A merged snippet can start on +// another line, so this shows which row the problem is on. // // Two ASCII characters rather than one of the arrows, which all read better and // none of which measure reliably: they are East Asian Ambiguous, so a font may @@ -47,34 +47,40 @@ static constexpr int FrameToContentWidth = 2; // glyph. This is two columns because it is two characters, so nothing can // disagree about it, and a font with programming ligatures draws it as an arrow // anyway. -static constexpr llvm::StringLiteral LineMark = "->"; +static constexpr llvm::StringLiteral LineArrow = "->"; -// The columns the mark spends before the line numbers. No space after it: the +// The columns the arrow spends before the line numbers. No space after it: the // numbers are right-aligned in a field of their own, so a number shorter than // that field already leaves a gap, and a number filling it is the widest there -// is to keep the mark off. -static constexpr int MarginWidth = LineMark.size(); +// is to keep the arrow off. +static constexpr int MarginWidth = LineArrow.size(); -// The columns an anchor spends before the location it names: `╭─┤ `. -static constexpr int AnchorPrefixWidth = 4; +// The columns a location row spends before the location it names: `╭─┤ `. +static constexpr int LocationPrefixWidth = 4; -// The columns a connector spends before what it reaches: three of line, and -// then either a space or, where it reaches a label, the bar framing it. -static constexpr int ConnectorWidth = 4; +// The columns a label line or a path row's line spends reaching its text: three +// of line, and then either a space or, where it reaches a label, the bar +// framing it. +static constexpr int LineToTextWidth = 4; // The columns the bar framing a label's left side spends before its text: // `┤ `. The bar runs down every row the label takes, so that what belongs to // the label is bounded rather than left to be inferred from indentation. static constexpr int LabelFrameWidth = 2; -// The columns between a label's anchor and its text: the connector reaching -// the bar that frames it, and the bar's own space before the words. -static constexpr int LabelIndentWidth = ConnectorWidth - 1 + LabelFrameWidth; +// The columns between a label line and its label's text: the label line +// reaching the bar that frames the text, and the bar's own space before the +// words. +static constexpr int LabelIndentWidth = LineToTextWidth - 1 + LabelFrameWidth; -// The columns a rule bracketing a snippet reaches across, starting at the -// frame. Long enough to read as a divider rather than as another branch off the -// frame, which is what the connector on a context row looks like. -static constexpr int SnippetRuleWidth = 13; +// The columns each label's text starts right of where the text above it +// starts, so the indentation steps with the order the rows are read in. +static constexpr int LabelStepWidth = 2; + +// The columns of the close, `╰────`, starting at the frame. The blank line +// after a diagnostic separates it from the next, so the close only needs to +// turn the frame's corner. +static constexpr int CloseRuleWidth = 5; // The columns of source a diagnostic aims to show: the width code is formatted // to, so a formatted line is shown whole and nothing wider is asked for than @@ -102,17 +108,26 @@ static constexpr size_t MaxDrawnBytes = 1 << 16; // Columns between tab stops, matching what a terminal does with a tab. static constexpr int SourceTabWidth = 8; -// What marks each end of a source line that windowing elided. -static constexpr llvm::StringLiteral WindowMarker = "..."; +// What is drawn at each end of a source line that windowing elided. +static constexpr llvm::StringLiteral WindowEllipsis = "..."; // The fewest columns of source a window shows, however narrow the terminal // is. static constexpr int MinWindowColumns = 16; +// Diagnostics quote code between backticks, and a quoted run is one word to +// wrapping, so a type written with spaces in it, or a snippet of syntax, is +// never split across rows. +static constexpr bool BackticksAreQuotes = true; + // The most lines shown rather than elided between two spans in one file. One // line of context is worth as much as the row saying it was skipped. static constexpr int MaxShownGap = 1; +// What a location row names for a part with no location at all, whose text is +// still placed under a location row. +static constexpr llvm::StringLiteral NoLocationText = ""; + // The fewest columns a framed diagnostic is drawn in, below which the compact // form is used instead. A frame, its gutter, and a label hanging off a span // need room before any of them say anything, and past some point there isn't @@ -134,16 +149,22 @@ static auto LevelText(Level level) -> llvm::StringRef { } } -// Returns the style the marks under the source take, which is the color of +// Returns the style the underlines under the source take, which is the color of // whatever they belong to without its weight. Bold reaches the line-drawing // glyphs unevenly -- several terminals leave them alone and others only // brighten them -- so the weight says nothing reliable there while it still // says something on words. -static auto MarkStyle(const Style& style) -> Style { return style.Bold(false); } +// +// `RotateUnderlineStyles` makes one exception: the heavy underline keeps its +// bold. A terminal that ignores bold on line art loses nothing there, and one +// that renders it matches the underline to the bold text placed under it. +static auto UnderlineStyle(const Style& style) -> Style { + return style.Bold(false); +} // The colors one theme is drawn in: what a diagnostic of that level, or the -// notes explaining one, take for their words and for the marks under the source -// that belong to them. +// notes explaining one, take for their words and for the underlines under the +// source that belong to them. // // The second is the theme's own color, which a range alone on its line takes. // Where several share a line, the whole ramp is handed out left to right @@ -166,7 +187,7 @@ using Theme = llvm::ArrayRef; // See /toolchain/docs/diagnostics_rendering.md#the-palette for where these // values came from and the distances and contrast ratios they satisfy. Changing // one means checking it against those, not against how it looks on a swatch: -// these are drawn as marks a pixel tall. +// these are drawn as underlines a pixel tall. static constexpr Terminal::Color DarkBgErrorTheme[] = { {0xb5, 0x56, 0x00}, {0xff, 0x72, 0x61}, {0xff, 0xbc, 0xc8}}; static constexpr Terminal::Color DarkBgWarningTheme[] = { @@ -256,8 +277,8 @@ static auto ExplanationTheme(const Terminal::Capabilities& capabilities) static constexpr int ThemeCenter = 1; // Returns the style a theme's words are drawn in. Also the color of the -// underline beneath the source that belongs to it, so that a mark and the -// sentence explaining it look like one thing. +// underline beneath the source that belongs to it, so that the underline and +// the sentence explaining it look like one thing. static auto ThemeStyle(Theme theme) -> Style { return Style().Bold().Foreground(theme[ThemeCenter]); } @@ -279,7 +300,7 @@ static auto KindStyle() -> Style { return Style().Dim(); } // reached rather than anything about the code itself. Dim so that a reader who // already knows the path can skip it, and unlike the frame nothing is lost on a // terminal that ignores dim. It covers the whole row, quoted code included. -static auto ContextStyle() -> Style { return Style().Dim(); } +static auto PathStyle() -> Style { return Style().Dim(); } namespace { @@ -289,20 +310,20 @@ namespace { // drawing, which picks its own glyphs and forms the corners and tees where // lines meet. struct Glyphs { - // Marks a row that annotates source rather than being source, so that which - // rows are the reader's code is visible at a glance. - char32_t annotation; - // Marks where lines of source were skipped. + // The frame's glyph on underline rows and label rows, so that which rows are + // the reader's code is visible at a glance. + char32_t dotted_frame; + // Drawn where lines of source were skipped. char32_t elision; static auto For(Charset charset) -> Glyphs { if (charset == Charset::Utf8) { - return {.annotation = U'·', .elision = U'┆'}; + return {.dotted_frame = U'·', .elision = U'┆'}; } - // An ASCII terminal has one broken bar to spend on both the annotation and - // the elision. A row holding nothing but the bar is an elision; one with an - // underline after it is not. - return {.annotation = U':', .elision = U':'}; + // ASCII has one broken bar for both the underline rows and the elision. A + // row holding nothing but the bar is an elision; one with an underline + // after it is not. + return {.dotted_frame = U':', .elision = U':'}; } }; @@ -330,8 +351,8 @@ namespace { // everything drawn is placed by column. The two count the same line and // neither follows from the other, so this keeps them from being taken for each // other in the one place both are in scope. Columns stay `int`, which is what -// `Terminal::Buffer` addresses its grid with, so what this marks is the count -// that is not a coordinate. +// `Terminal::Buffer` addresses its grid with, so the count that is not a +// coordinate is the one given this type. // // TODO: Move this out of this file, and use it for the byte counts elsewhere // that are called columns, starting with `Loc::column_number`. @@ -384,22 +405,30 @@ struct PreparedSource { return std::max(metrics.Width(text), span_start + span_length); } - // The column a label's connector runs down, which layout sets to whichever - // end of the span the label attaches to. Until then it is the middle, which - // is what a span with no label of its own is measured from. - int anchor = 0; + // The column the label line runs down, which layout slides between where the + // span starts and its middle. Until it is set it is the middle, which is what + // a span with no label of its own is measured from. + int line_column = 0; + + // The column the label's text starts in. Layout sets it right of every + // label line on the line, and `LabelStepWidth` right of where the text of the + // nearest label above that is not out-dented starts. + int label_x = 0; // Where the underline stops at each end. Layout sets an end to `Center` when - // another range begins or ends in the next column, so that the two marks + // another range begins or ends in the next column, so that the two underlines // don't run together; an end with nothing beside it covers its whole column. LineEnd left_end = LineEnd::Edge; LineEnd right_end = LineEnd::Edge; - // Whether the label's connector is drawn in place of the underline rather - // than hanging off it. A mark of one column with an end pulled in has no - // junction to offer, and the line down its column says the column is marked - // without saying the mark carries on anywhere. - bool connector_stands_in = false; + // Whether the label line is drawn in place of the underline rather than + // hanging off it. An underline of one column with an end pulled in has no + // junction to offer, and the line down its column says the column is + // underlined without saying the underline carries on anywhere. + bool label_line_stands_in = false; + + // Returns the column in the middle of the span. + auto Middle() const -> int { return span_start + span_length / 2; } // Returns whether the underline covers `column` at all. auto Covers(int column) const -> bool { @@ -408,7 +437,8 @@ struct PreparedSource { // Returns whether the underline runs out through the left or the right side // of `column`. An end pulled in to clear the range beside it gives up the - // side it was pulled in on, which is the side a connector could not tee into. + // side it was pulled in on, which is the side a label line could not tee + // into. auto ReachesLeftOf(int column) const -> bool { return Covers(column) && (column > span_start || left_end == LineEnd::Edge); } @@ -418,7 +448,7 @@ struct PreparedSource { } // Returns whether any column of the underline runs out through both of its - // sides, which is what a connector needs one to do to tee into it. + // sides, which is what a label line needs one to do to tee into it. auto Joinable() const -> bool { if (span_length == 1) { return left_end == LineEnd::Edge && right_end == LineEnd::Edge; @@ -447,14 +477,26 @@ struct PreparedPart { // What this is to the reader. Part role = Part::Explanation; + // Whether this part states the problem: the message, or the context that + // `LeadingContext` returns. Its text begins with the level word and is + // bold, and its underline is the heavy one. + // + // TODO: The design has a context scope attach a label instead of leading the + // diagnostic. Make the message always lead once contexts are labels. + bool is_leading = false; + + // Whether this part's range is drawn as the heavy underline: the range the + // leading part's text is placed under, or a problem range identical to it. + // It keeps the level's center color and is left out of the ramp. Set + // during layout. + bool is_heavy_underline = false; + // Whether this part's range came from the message's own location rather than // from a range attached to the diagnostic. Only the message has one. // - // Every diagnostic marks at least one range as part of the problem. Where one - // was attached, it says where the problem is better than the message's - // location does, and this range gives way to it: a range containing the - // location hosts the message's words, and one that doesn't leaves the message - // marking nothing of its own. + // An attached problem range containing the location takes its place: the + // message's text is placed under that range, and the location has no + // underline of its own. See `FindMessageHost`. bool from_message_loc = false; // The word leading this part's text, including its separator, and empty for @@ -464,12 +506,12 @@ struct PreparedPart { // The style of that word and of this part's text. Style style; - // The style of the underline under this part's source, and of the connector + // The style of the underline under this part's source, and of the label line // and bar of the label hanging off it. The rotation moves this along the - // theme's ramp, which is why it is not `style`: the level word, the mark - // in the margin, and the line number beside the reported line all say what - // the diagnostic is, so where a range sits on a line must not recolor them. - Style mark_style; + // theme's ramp, which is why it is not `style`: the level word, the arrow in + // the margin, and the line number beside the reported line all say what the + // diagnostic is, so where a range sits on a line must not recolor them. + Style underline_style; // `file:line:column`, with unknown parts left off, and empty for a part // with no location at all. @@ -481,12 +523,12 @@ struct PreparedPart { // framed form says it with the underline instead. int32_t location_end_column = 0; - // The part's words when they go on a row of their own: the headline, and any - // part with no source to hang them against. Empty when they hang as a label. + // The part's text when it is placed under the part's location row, which is + // for any part with no source. Empty when the text is a label. std::string text; - // The part's words when they hang against the source it marks, which is any - // part that has source and isn't the headline. Empty otherwise. + // The part's text when it is placed under the underline on its source, which + // is for any part that has source. Empty otherwise. std::string label; // ` [Kind]`, or empty when kinds aren't being included. It goes at the end @@ -495,8 +537,9 @@ struct PreparedPart { // twice. std::string kind_suffix; - // Returns the suffix for a row, which is empty unless that row is the last - // one carrying this part's words. + // Returns the suffix for a row drawing this part's text. The text goes on + // exactly one kind of row -- a label row when the part has source, a location + // label row otherwise -- so a row of the other kind gets no suffix. auto KindSuffixOn(bool is_label_row) const -> llvm::StringRef { return is_label_row == label.empty() ? llvm::StringRef() : kind_suffix; } @@ -535,65 +578,65 @@ static auto RotatedStyle(const Style& style, Theme theme, int index, int count) namespace { -// How a label's connector meets the underline it hangs from. +// How a label line meets the underline it hangs from. enum class Attachment : int8_t { // Tees into the underline where it hangs from. Line drawing forms the // junction the same way it forms the frame's own. Tee, - // Stands in for the mark, in the one column it had, because the underline - // offers no column to tee into: a mark that stops at a cell's center to - // clear the range beside it would form a corner there, and a corner reads as - // a mark turning rather than as one a connector leaves. + // Stands in for the underline, in the one column it had, because the + // underline offers no column to tee into: an underline that stops at a cell's + // center to clear the range beside it would form a corner there, and a corner + // reads as an underline turning rather than as one a label line leaves. Through, }; -// Where a label's connector meets its underline, and the column it runs down. +// Where a label line meets its underline, and the column it runs down. struct Placement { Attachment attachment; - int anchor; + int line_column; }; // A row of the rendering, laid out before anything is measured or drawn. struct Row { enum class Kind : int8_t { - // A message on a row of its own, inside the frame. - Message, - // The location the snippet below it comes from. - Anchor, + // `╭─┤ location`: the location of the snippet below it, or of a part with + // no source whose text is placed under it. + Location, // A line of source, with its number beside the frame. Source, - // The underline marking a span in the source above. - Annotation, - // The text hanging off that underline, framed by a bar the underline's - // connector reaches. + // The underlines under the source above, one for every span on it. + Underline, + // The text hanging off that underline, framed by a bar the label line + // reaches. Label, // A label that wouldn't fit hanging off its span, out-dented to the column // the source starts in with its own frame reaching back to the span. RoutedLabel, - // A stand-in for lines of source that were skipped. + // The text of a part with no source, placed under its location row the way + // a label is placed under its underline. + LocationLabel, + // `┆`, continuing the frame across whatever isn't contiguous: skipped + // lines of source, or the step to the next location row. Elision, - // Nothing but the frame, setting a snippet off from the anchor above it. - Gap, - // The rule closing off one snippet before the next begins. - Separator, - // How the location in the anchor below it was reached. - Context, + // How the location in the location row below it was reached. + Path, }; Kind kind; // The part this row belongs to, or null for a row that draws only frame and // for a source line shown between two spans. const PreparedPart* part = nullptr; - // `Annotation` rows: every span underlined, widest first, which is the order - // they are drawn in so that the narrowest mark on a column is what shows. + // `Underline` rows: every span underlined, in the order they are drawn: + // widest first, so that the narrowest underline on a column is what shows, + // with the heavy underline last so that nothing repaints it. llvm::SmallVector spans; - // `Source` rows: the part whose style the margin mark and line number - // take, set on every line holding a range that is part of the problem, and - // null on every other line. + // `Source` rows: the part whose style the margin arrow and line number take, + // set on the one line the leading part's text is placed under, and null on + // every other line. const PreparedPart* points_here = nullptr; // `Source` rows: the number to draw, or -1 when there is none to show. int line_number = -1; - // `Source` rows: the text. + // The row's text: a line of source, or the text of a label or location label. std::string text; }; @@ -699,12 +742,12 @@ static auto PrepareSource(Metrics metrics, llvm::StringRef line, result.span_start = start_column; result.span_length = std::max(end_column - start_column, 1); - result.anchor = result.span_start + result.span_length / 2; + result.line_column = result.Middle(); return result; } -// Narrows `source` to `columns` around `focus`, marking each end that was -// elided. +// Narrows `source` to `columns` around `focus`, with `WindowEllipsis` at each +// end that was elided. // // A source line and its underline that wrap onto different rows lose the // alignment between them, which is the whole point of a snippet, so a line too @@ -717,16 +760,16 @@ static auto WindowSource(Metrics metrics, PreparedSource& source, int columns, int focus) -> void { // The width includes the column past the text that a span starting at the // end of the line is drawn in, so a line that exactly fills the columns is - // still windowed to bring that mark inside them. + // still windowed to bring that underline inside them. int width = source.Width(metrics); if (width <= columns) { return; } - // Both markers are accounted for whether or not both are needed, so that how + // Both ellipses are accounted for whether or not both are needed, so that how // much source a window shows doesn't depend on where in the line it lands. - auto marker_width = static_cast(WindowMarker.size()); - int inner = std::max(columns - 2 * marker_width, MinWindowColumns); + auto ellipsis_width = static_cast(WindowEllipsis.size()); + int inner = std::max(columns - 2 * ellipsis_width, MinWindowColumns); int begin = std::clamp(focus - inner / 4, 0, std::max(width - inner, 0)); // The text is walked rather than indexed, so no byte offset into it is ever @@ -743,12 +786,12 @@ static auto WindowSource(Metrics metrics, PreparedSource& source, int columns, std::string text; int shift = 0; if (!before.empty()) { - text.append(WindowMarker.begin(), WindowMarker.end()); - shift = marker_width; + text.append(WindowEllipsis.begin(), WindowEllipsis.end()); + shift = ellipsis_width; } text.append(window.begin(), window.end()); if (!rest.empty()) { - text.append(WindowMarker.begin(), WindowMarker.end()); + text.append(WindowEllipsis.begin(), WindowEllipsis.end()); } // Both ends of the span move by what was really dropped from in front of it, @@ -756,8 +799,8 @@ static auto WindowSource(Metrics metrics, PreparedSource& source, int columns, // than carrying the length is what keeps a span the window clipped short -- // one windowed around another span on its row, off one edge -- from // underlining the source that took its place: what was clipped away is not - // marked. Every column is drawable and none is past the last cell, so the - // mark stays a mark and never reaches past the grid. + // underlined. Every column is drawable and none is past the last cell, so the + // underline stays an underline and never reaches past the grid. int visible = metrics.Width(text); int offset = shift - dropped; int old_end = source.span_start + source.span_length; @@ -765,7 +808,7 @@ static auto WindowSource(Metrics metrics, PreparedSource& source, int columns, std::clamp(source.span_start + offset, 0, std::min(visible, columns - 1)); int span_end = std::clamp(old_end + offset, source.span_start + 1, columns); source.span_length = span_end - source.span_start; - source.anchor = source.span_start + source.span_length / 2; + source.line_column = source.Middle(); source.text = std::move(text); } @@ -800,12 +843,12 @@ static auto LineFromFile(const PreparedPart& part, int number) // Returns a part of a diagnostic prepared for drawing: `text` said at `loc`, // drawn as `role` says and named `name` where kinds are being included. // -// `is_headline` says that the words lead the diagnostic, so they go on the -// headline row rather than against the source they point at. +// `is_leading` is set for the part that states the problem; see +// `PreparedPart::is_leading`. static auto PreparePart(Metrics metrics, Part role, bool from_message_loc, llvm::StringRef level_text, Style style, const Loc& loc, - std::string text, llvm::StringRef name, - bool is_headline, bool include_kind) -> PreparedPart { + std::string text, llvm::StringRef name, bool is_leading, + bool include_kind) -> PreparedPart { // Text past any legitimate size is truncated rather than handed to the // buffer, whose own limit on a single draw is a CHECK; nothing a diagnostic // says comes near either bound. @@ -815,10 +858,11 @@ static auto PreparePart(Metrics metrics, Part role, bool from_message_loc, PreparedPart result = { .role = role, + .is_leading = is_leading, .from_message_loc = from_message_loc, .level_text = level_text, .style = style, - .mark_style = MarkStyle(style), + .underline_style = UnderlineStyle(style), .location = FormatLocation(loc), .location_end_column = loc.column_number > 0 && loc.length > 1 ? loc.column_number + loc.length - 1 @@ -836,10 +880,10 @@ static auto PreparePart(Metrics metrics, Part role, bool from_message_loc, Bytes(loc.length)); } - // Words that lead the diagnostic go on its headline, and words with no source - // to point at have nowhere to go but a row of their own. Everything else is - // read against the code it marks. - if (is_headline || !result.has_source) { + // Text with no source to underline is placed under the part's location row. + // Everything else, the message included, is a label placed under its + // underline. + if (!result.has_source) { result.text = std::move(text); } else { result.label = std::move(text); @@ -855,8 +899,8 @@ static auto PreparePart(Metrics metrics, Part role, bool from_message_loc, } } // A label that scrubbed away to spaces has nothing to hang, and hanging it - // would spend rows and a connector on drawing nothing. It becomes what a - // label with no words is: a mark and nothing else. + // would spend rows and a label line on drawing nothing. It becomes what a + // label with no words is: an underline and nothing else. if (result.label.find_first_not_of(' ') == std::string::npos) { result.label.clear(); } @@ -870,7 +914,7 @@ static auto PreparePart(Metrics metrics, Part role, bool from_message_loc, // Returns how `part`, which is location information, is spelled: what it says // and then where, so that the words read as leading to the location. A part // missing either half is just the other. -static auto ContextText(const PreparedPart& part) -> std::string { +static auto PathText(const PreparedPart& part) -> std::string { if (part.location.empty()) { return part.text; } @@ -880,114 +924,108 @@ static auto ContextText(const PreparedPart& part) -> std::string { return part.text + ": " + part.location; } -// Returns what a part drawn on a row of its own says. Location information -// that never found an anchor to lead into says where it is here instead. -static auto MessageRowText(const PreparedPart& part) -> std::string { - return part.role == Part::LocationInfo ? ContextText(part) : part.text; +// Returns whether `part` gets a location row: every part with a snippet to show +// or text to place under one, and the leading part, whose level word is +// always drawn. A range with no source and no text draws nothing. +static auto HasLocationRow(const PreparedPart& part) -> bool { + return part.role != Part::LocationInfo && + (part.has_source || !part.text.empty() || part.is_leading); } -// Returns where `label`'s connector meets the underline it hangs from, and the -// column it runs down from there. +// Returns whether a label line running down `column` can tee into the underline +// of `against` there. // -// The connector tees into the middle of the underline, which reads as pointing -// into the range rather than as running off an end of it, and slides left when -// the words don't fit -- but only as far as it has to, and never past where the -// range starts. Moving the connector is what a label gives up before it starts -// wrapping. +// Whether a column offers a junction is asked of every underline on the row +// rather than of `against` alone, since a cell holds all of them together: a +// range drawn over this one covers what its own end gave up, and a label line +// meeting that reads as the tee it is drawn as. Asking only `against` would +// leave a label line running through a column another underline had filled, +// crossing it. +static auto TeesAt(const PreparedSource& against, + llvm::ArrayRef spans, int column) -> bool { + return against.Covers(column) && + llvm::any_of(spans, + [&](const PreparedPart* span) { + return span->source.ReachesLeftOf(column); + }) && + llvm::any_of(spans, [&](const PreparedPart* span) { + return span->source.ReachesRightOf(column); + }); +} + +// Returns where a label line asked to run down `desired` meets the underline of +// `against`, and the column it runs down. // -// An end pulled in to clear the range beside it has no junction to offer -// either, and a connector meeting one would form a corner, which reads as the -// underline turning down rather than as a line leaving it. So the connector -// steps a column away from that range, where the marks run out through both -// sides again. Where no column of its range does -- a single column, or two -// with a range on either side -- it takes a column instead of teeing into one, -// and the underline gives that column up to it. +// An end pulled in to clear the range beside it has no junction to offer, and +// a label line meeting one would form a corner, which looks like the underline +// turning down. So the label line steps a column away from that range, where +// the underlines run out through both sides again. Where no column of its range +// does -- an underline of one column that gave up an end -- the label line is +// drawn down that column in place of the underline. A wider underline never +// reaches this: an end gives way only where the range keeps a column a label +// line can tee into. // -// Whether a column offers a junction is asked of every mark on the row rather -// than of `against` alone, since a cell holds all of them together: a range -// drawn over this one covers what its own end gave up, and a connector meeting -// that reads as the tee it is drawn as. Asking only `against` would leave a -// connector running through a column another mark had filled, crossing it. -// -// `against` is what the connector leaves, which is the label's own range except -// for the message's: where a range drawn on the same row contains the message's -// location, the words belong to that range. -static auto PlaceLabel(Metrics metrics, const PreparedPart& label, - const PreparedSource& against, - llvm::ArrayRef spans, int content_x, - int columns) -> Placement { - int width = metrics.Width(label.label); - int middle = against.span_start + against.span_length / 2; - int anchor = middle; - if (content_x + anchor + LabelIndentWidth + width > columns) { - anchor = std::clamp(columns - content_x - LabelIndentWidth - width, - against.span_start, anchor); +// `against` is the range the label line leaves: the label's own, or for the +// message, a range on the same row that contains the message's location. +static auto PlaceLabel(const PreparedSource& against, + llvm::ArrayRef spans, int desired) + -> Placement { + if (TeesAt(against, spans, desired)) { + return {Attachment::Tee, desired}; } - auto tees_at = [&](int column) { - return against.Covers(column) && - llvm::any_of(spans, - [&](const PreparedPart* span) { - return span->source.ReachesLeftOf(column); - }) && - llvm::any_of(spans, [&](const PreparedPart* span) { - return span->source.ReachesRightOf(column); - }); - }; - if (tees_at(anchor)) { - return {Attachment::Tee, anchor}; - } - // Only an end fails to offer a junction, so the step is inward, away from the - // range that pulled that end in. - int step = anchor == against.span_start ? 1 : -1; - if (tees_at(anchor + step)) { - return {Attachment::Tee, anchor + step}; + // Only an end fails to offer a junction, so the step is inward, away from + // the range that pulled that end in. + int step = desired == against.span_start ? 1 : -1; + if (TeesAt(against, spans, desired + step)) { + return {Attachment::Tee, desired + step}; } // Nothing to tee into, so every label on this range takes the same column, // which is the one the underline is measured from rather than wherever the // words happened to have to start. - return {Attachment::Through, middle}; + return {Attachment::Through, against.Middle()}; } -// Draws the mark under `span`, in source drawn from column `x`, on row `y`. +// Draws the underline under `span`, in source drawn from column `x`, on row +// `y`. +// +// The heavy underline is drawn heavy in both character sets. ASCII draws a +// heavy line as `^`, so that underline stays distinct without color. static auto DrawUnderline(Buffer& buffer, int x, int y, const PreparedPart& span, const Style& style) -> void { - // A connector with no column to tee into is drawn down the mark's own column - // in place of it. Only a mark of one column is ever left with none, so there - // is nothing of it to draw beside the line: an end gives up its half column - // only where the range can still carry its label without it. - if (span.source.connector_stands_in) { + // A label line with no column to tee into is drawn down the underline's own + // column in place of it. Only an underline of one column is ever left with + // none, so there is nothing of it to draw beside the line: an end gives up + // its half column only where the range can still carry its label without it. + if (span.source.label_line_stands_in) { return; } - buffer.DrawHorizontalLine(x + span.source.span_start, y, - span.source.span_length, style, - span.source.left_end, span.source.right_end); + buffer.DrawHorizontalLine( + x + span.source.span_start, y, span.source.span_length, style, + span.source.left_end, span.source.right_end, + span.is_heavy_underline ? Terminal::LineWeight::Heavy + : Terminal::LineWeight::Light); } // Returns the part whose range stands in for `message_part`'s own, or null when -// nothing does and the message marks where it points. +// nothing does and the message's own location is underlined. // // A range attached as part of the problem says where the problem is in terms // the reader can see, which the message's location -- a point, and often one // chosen for an editor to put a cursor on rather than for anyone to look at -- -// does not. So a range marking the line that location names stands in for it -// entirely: the message marks nothing of its own, and whatever words it has -// left once a context leads the diagnostic hang from that range instead. +// does not. So a range containing that location is underlined in its place: the +// message underlines nothing of its own, and its text is placed under that +// range. // -// It has to be that line. A range elsewhere says nothing about the code the -// location names, and taking its place would point the message's words at code -// they aren't about while dropping the line they are. -// -// The range containing the location is the one that takes it, since that is the -// one drawn over the column the location names. Failing that it is the first -// attached to the line, which is the one whose author put it first. +// It has to contain the location. A range elsewhere, even on the same line, is +// not about the code the location names, and placing the message under it +// would drop the underline on the code the message is about. // // `candidates` are the ranges drawn alongside the message's, which is what a -// range has to be to take its place: one drawn under an anchor of its own is -// read against the code below that one instead. +// range has to be to take its place: one drawn under a location row of its own +// is read against the code below that one instead. static auto FindMessageHost(llvm::ArrayRef candidates, const PreparedPart& message_part) -> PreparedPart* { - PreparedPart* host = nullptr; int column = message_part.source.span_start; for (PreparedPart* candidate : candidates) { if (candidate == &message_part || candidate->role != Part::Problem || @@ -1000,34 +1038,56 @@ static auto FindMessageHost(llvm::ArrayRef candidates, column < source.span_start + source.span_length) { return candidate; } - if (!host) { - host = candidate; - } } - return host; + return nullptr; } -// Recolors the marks of `spans`, which share one line, along their themes' +// Recolors the underlines of `spans`, which share one line, along their themes' // ramps. Each theme counts its own way through its colors, left to right, so -// they run in the order the code they mark is read. -static auto RotateMarkStyles(llvm::ArrayRef spans, - Theme problem_theme, Theme explanation_theme) +// they run in the order the code they underline is read. +// +// The heavy underline is left out of the ramp: it keeps the level's center +// color and its bold, matching the level word. The other problem ranges on its +// line take successive colors from the ramp with the center left out, so that +// only the heavy underline has the center color. +static auto RotateUnderlineStyles(llvm::ArrayRef spans, + Theme problem_theme, Theme explanation_theme) -> void { llvm::SmallVector across(spans); llvm::stable_sort(across, [](const PreparedPart* lhs, const PreparedPart* rhs) { return lhs->source.span_start < rhs->source.span_start; }); + bool leading_on_line = llvm::any_of(across, [](const PreparedPart* span) { + return span->is_heavy_underline; + }); + llvm::SmallVector around_center; + if (leading_on_line) { + for (auto [index, color] : llvm::enumerate(problem_theme)) { + if (static_cast(index) != ThemeCenter) { + around_center.push_back(color); + } + } + } int totals[2] = {0, 0}; for (const PreparedPart* span : across) { - ++totals[span->role == Part::Problem]; + totals[span->role == Part::Problem] += !span->is_heavy_underline; } int counts[2] = {0, 0}; for (PreparedPart* span : across) { + if (span->is_heavy_underline) { + span->underline_style = span->style; + continue; + } bool is_problem = span->role == Part::Problem; int& count = counts[is_problem]; - span->mark_style = RotatedStyle( - span->mark_style, is_problem ? problem_theme : explanation_theme, + if (is_problem && leading_on_line) { + span->underline_style = span->underline_style.Foreground( + around_center[count++ % around_center.size()]); + continue; + } + span->underline_style = RotatedStyle( + span->underline_style, is_problem ? problem_theme : explanation_theme, count++, totals[is_problem]); } } @@ -1041,12 +1101,12 @@ static auto RotateMarkStyles(llvm::ArrayRef spans, // // The gap is worth having but not worth paying for. An end gives way only // where the range can still carry its label without it: two columns can spare -// one end but not both, since a connector needs a column the mark runs out -// through on both sides and after the left end gave way only the right one is -// left. Left is considered first, so the range that begins at a boundary is +// one end but not both, since a label line needs a column the underline runs +// out through on both sides and after the left end gave way only the right one +// is left. Left is considered first, so the range that begins at a boundary is // always the one that gives way there, and every boundary ends up with a gap. -// One column can spare neither end, and the accepted answer there is the line -// the connector leaves or a point where it has no connector. +// One column can spare neither end, and the accepted answer there is the label +// line drawn down that column, or a point where it has no label line. static auto SeparateTouchingEnds( llvm::ArrayRef spans, const llvm::SmallPtrSetImpl& carries_label) -> void { @@ -1075,33 +1135,107 @@ static auto SeparateTouchingEnds( } } -// Sets each label's anchor to where its connector runs down, asked of the -// underline it hangs from against everything else marked on the line. +// Returns the range `label` is placed under: the message host's for the +// message's own part when a host has taken its place, and otherwise its own. +static auto LabelSource(const PreparedPart* label, + const PreparedPart* message_part, + const PreparedPart* message_host) + -> const PreparedSource& { + return label == message_part && message_host ? message_host->source + : label->source; +} + +// Sets the column each label line runs down, choosing for the whole line at +// once. `labels` are in reading order, which the loop assigning each label its +// step relies on. // -// `message_part` and `message_host` are as in `add_line` below: the message's -// words hang from the host's range when one has taken its place. -static auto PlaceLabels(Metrics metrics, llvm::ArrayRef labels, +// Each label line starts at the middle of its underline, so that it points into +// the range. Every label's text starts right of every label line's column, so +// when the text on the line needs more room than the rightmost label lines +// leave, each label line right of where the text has to start slides left, +// whichever label it belongs to: only as far as the text needs to fit on one +// row, and never past where its own range starts. Label lines slide before any +// text wraps, and the label line of a label that will be out-dented still +// slides for the others. +// +// `message_part` and `message_host` are as in `RowLayout::AddLine`: the +// message's text is placed under the host's range when one has taken its +// place. +static auto PlaceLabels(const Buffer& buffer, + llvm::ArrayRef labels, const PreparedPart* message_part, const PreparedPart* message_host, llvm::ArrayRef spans, int content_x, int columns) -> void { + Metrics metrics = buffer.metrics(); + auto against = [&](const PreparedPart* label) -> const PreparedSource& { + return LabelSource(label, message_part, message_host); + }; + // The leftmost column each label line can run down: where its range starts, + // or the next column when the start has no junction, and the middle when + // neither has one. + auto floor_of = [&](const PreparedSource& source) { + for (int column : {source.span_start, source.span_start + 1}) { + if (TeesAt(source, spans, column)) { + return column; + } + } + return source.Middle(); + }; + + // The base is the column the first label's text starts in. These are the + // base with every label line at its middle, and the lowest base, with every + // label line at its floor. + int natural_base = 0; + int lowest_base = 0; + for (const PreparedPart* label : labels) { + natural_base = + std::max(natural_base, against(label).Middle() + LabelIndentWidth); + lowest_base = + std::max(lowest_base, floor_of(against(label)) + LabelIndentWidth); + } + + // The most columns right of the base that any label needs: its step, level + // word, and text on one row. A label whose widest word does not fit even + // from the lowest base will be out-dented, so its text needs nothing of the + // base, though its label line still slides with the rest. + int width_limit = columns - content_x; + int worst = 0; + bool any_fits = false; + int step = 0; + for (const PreparedPart* label : labels) { + int prefix_width = label->is_leading ? metrics.Width(label->level_text) : 0; + if (lowest_base + step + prefix_width + + buffer.MeasureWrapWidth(label->label, BackticksAreQuotes) > + width_limit) { + continue; + } + worst = std::max(worst, step + prefix_width + metrics.Width(label->label)); + any_fits = true; + step += LabelStepWidth; + } + int target_base = natural_base; + if (any_fits) { + target_base = + std::max(lowest_base, std::min(width_limit - worst, natural_base)); + } + for (PreparedPart* label : labels) { - const PreparedSource& against = label == message_part && message_host - ? message_host->source - : label->source; - Placement placement = - PlaceLabel(metrics, *label, against, spans, content_x, columns); - label->source.anchor = placement.anchor; - // A connector drawn in place of a mark is recorded on the range it stands - // in for, not on the label that asked for it -- and on every range drawn - // over exactly the same column, since a second mark there would be a half - // mark beside the connector rather than a stroke through it, which is the - // one thing that would leave a corner in the cell. + const PreparedSource& source = against(label); + int desired = std::clamp(target_base - LabelIndentWidth, floor_of(source), + source.Middle()); + Placement placement = PlaceLabel(source, spans, desired); + label->source.line_column = placement.line_column; + // A label line drawn in place of an underline is recorded on the range it + // stands in for, not on the label that asked for it -- and on every range + // drawn over exactly the same column, since a second underline there would + // be a half-cell line beside the label line rather than a line through it, + // which is the one thing that would leave a corner in the cell. if (placement.attachment == Attachment::Through) { for (PreparedPart* span : spans) { - if (span->source.span_start == against.span_start && - span->source.span_length == against.span_length) { - span->source.connector_stands_in = true; + if (span->source.span_start == source.span_start && + span->source.span_length == source.span_length) { + span->source.label_line_stands_in = true; } } } @@ -1111,16 +1245,17 @@ static auto PlaceLabels(Metrics metrics, llvm::ArrayRef labels, // Returns the spans on `line` that draw an underline: all of them, except // `message_part` once `message_host` has taken its place. // -// Everything marking the line goes on the one row below it, so that the marks -// read as marking that line rather than as a stack of rows each of which has to -// be traced back up to it. Ranges that overlap are drawn widest first, so the -// narrowest mark covering a column is the one that shows: a range containing -// another says less about the columns they share than the range inside it does, -// and a mark that is part of the problem says more than one that only explains -// it. +// Every underline for the line goes on the one row below it, so that the +// underlines read as underlining that line rather than as a stack of rows each +// of which has to be traced back up to it. Ranges that overlap are drawn widest +// first, so the narrowest underline covering a column is the one that shows: a +// range containing another says less about the columns they share than the +// range inside it does, and an underline that is part of the problem says more +// than one that only explains it. The heavy underline is the exception; see +// `MoveHeavyUnderlinesLast`. // // Ranges shouldn't overlap in the first place -- one covering another means two -// parts of the diagnostic marking the same code -- but they are attached by +// parts of the diagnostic attached to the same code -- but they are attached by // layers that never see each other, so this repairs what it is given rather // than checking a rule nothing is in a position to enforce. static auto SpansWidestFirst(llvm::ArrayRef line, @@ -1143,6 +1278,45 @@ static auto SpansWidestFirst(llvm::ArrayRef line, return spans; } +// Sets `is_heavy_underline` on the spans drawn as the heavy underline and moves +// them to the end of `spans`. Returns the span the leading part's text is +// placed under, or null when that text is not placed on this line. +static auto MoveHeavyUnderlinesLast(llvm::MutableArrayRef spans, + const PreparedPart* message_part, + const PreparedPart* message_host) + -> const PreparedPart* { + // The leading part's text is placed under its own range, or under the host + // of the message's location when the message leads. + const PreparedPart* leading_host = + message_part && message_part->is_leading ? message_host : nullptr; + const PreparedPart* heavy_underline = nullptr; + for (PreparedPart* span : spans) { + span->is_heavy_underline = span->is_leading || span == leading_host; + if (span->is_heavy_underline) { + heavy_underline = span; + } + } + // A problem range identical to the leading one underlines the same source. + // Identical ranges are drawn over each other, so it takes the heavy + // underline's weight and color; otherwise it would repaint that stretch + // light, in a rotated color. + if (heavy_underline) { + for (PreparedPart* span : spans) { + span->is_heavy_underline |= + span->role == Part::Problem && + span->source.span_start == heavy_underline->source.span_start && + span->source.span_length == heavy_underline->source.span_length; + } + } + // The heavy underline is drawn last, over every other range on the row, so + // that no narrower range redraws a cell of it light. A range inside it shows + // as the tee where its label line leaves the heavy underline. + std::stable_partition( + spans.begin(), spans.end(), + [](const PreparedPart* span) { return !span->is_heavy_underline; }); + return heavy_underline; +} + // Returns the parts whose words hang off `spans`, in the order of `spans`. static auto LabelsHangingFrom(llvm::ArrayRef spans, PreparedPart* message_part, @@ -1150,18 +1324,42 @@ static auto LabelsHangingFrom(llvm::ArrayRef spans, -> llvm::SmallVector { llvm::SmallVector labels; for (PreparedPart* span : spans) { - if (!span->label.empty()) { - labels.push_back(span); - } - // A range standing in for the part's location hangs the part's own words - // from its underline alongside whatever it has to say itself. + // The host of the part's location has the part's text placed under it as + // well as its own, and the part's text comes first, so the sentence + // stating the problem is next to the underline with the range's own text + // below. if (span == message_host && !message_part->label.empty()) { labels.push_back(message_part); } + if (!span->label.empty()) { + labels.push_back(span); + } } return labels; } +// Sorts `labels` into the order their rows are drawn in. +// +// The rows read top to bottom the way the code reads left to right: the +// leading part first, then each label in the order of the middle of its +// range. Ordering by the range, not the label line, keeps a sliding label line +// from reordering the rows. A label line that descends through rows drawn above +// it breaks around what they drew. +static auto SortLabelsForReading(llvm::MutableArrayRef labels, + const PreparedPart* message_part, + const PreparedPart* message_host) -> void { + auto order_key = [&](const PreparedPart* label) { + return LabelSource(label, message_part, message_host).Middle(); + }; + llvm::stable_sort(labels, + [&](const PreparedPart* lhs, const PreparedPart* rhs) { + if (lhs->is_leading != rhs->is_leading) { + return lhs->is_leading; + } + return order_key(lhs) < order_key(rhs); + }); +} + namespace { // Lays out the rows a diagnostic's frame holds, in the order they are drawn. @@ -1174,24 +1372,27 @@ namespace { class RowLayout { public: RowLayout(const Buffer& buffer, llvm::MutableArrayRef parts, - int headline, Theme problem_theme, Theme explanation_theme, + int leading, Theme problem_theme, Theme explanation_theme, int source_columns, int content_x, int columns); // Returns the rows, in the order they are drawn. auto LayOut() && -> llvm::SmallVector; private: - // Adds the rows for `parts_[index]`: its own text, the anchor naming its - // location, and the snippet below that, which also shows the spans of the - // parts `TakeGroup` gathers with it. + // Adds the rows for `parts_[index]`: the path to its location, the location + // row naming it, its text when it has no source, and the snippet below that, + // which also shows the spans of the parts `TakeGroup` gathers with it. auto AddBlock(size_t index) -> void; - // Returns the spans shown under the anchor of `parts_[index]`: its own and - // every later span in the same file, shown as one view of it in source order - // with the lines between them elided. Each is marked as drawn. + // Returns the spans shown under the location row of `parts_[index]`: its own + // and every later span in the same file, shown as one view of it in source + // order with the lines between them elided. A part that names only a file has + // no span of its own, but its location row is still the one the file's spans + // are shown under, so that the file doesn't get a second location row for the + // first of them. Records the later spans as drawn. auto TakeGroup(size_t index) -> llvm::SmallVector; - // Adds the rows showing `group`'s source below its anchor, one line of + // Adds the rows showing `group`'s source below its location row, one line of // source at a time. auto AddSnippet(llvm::ArrayRef group, PreparedPart* message_part, PreparedPart* message_host) @@ -1202,7 +1403,7 @@ class RowLayout { auto AddLinesBetween(const PreparedPart& previous, int next) -> void; // Adds the rows drawing the spans that fall on one source line: the line - // itself, the underlines beneath it, and the labels hanging off those. + // itself, the underline row beneath it, and the label rows under that. // // `message_part` is the range standing in for the part's own location, and // `message_host` the attached range that has taken its place, in which case @@ -1210,26 +1411,18 @@ class RowLayout { auto AddLine(llvm::ArrayRef line, PreparedPart* message_part, PreparedPart* message_host) -> void; - // Adds a row for each of `labels`, below the underlines they hang off. + // Adds a row for each of `labels`, in order, below their underline row, and + // sets where each label's text starts. auto AddLabelRows(llvm::ArrayRef labels) -> void; - // Adds `part`'s own text on a row of its own, which the drawing wraps into - // the column after the level word. - // - // TODO: No toolchain diagnostic should reach this: the goal is every part - // attached to a location that reaches source, with one genuinely about a - // file as a whole anchored at the file's start or end and drawn in a form of - // its own. That restructuring starts with the emitting diagnostics. - auto AddMessageRows(const PreparedPart& part) -> void; - - // Returns whether the last row added was part of a snippet, and so wants - // closing off before the next one starts. + // Returns whether the last row added was below a location row, so that the + // step to the next location row gets an elision. auto InSnippet() const -> bool; const Buffer* buffer_; Metrics metrics_; llvm::MutableArrayRef parts_; - int headline_; + int leading_; Theme problem_theme_; Theme explanation_theme_; int source_columns_; @@ -1237,15 +1430,16 @@ class RowLayout { int columns_; // Whether a part has to open a block of its own rather than being merged - // into an earlier one: it has something to say on a row of its own, or there - // is location information above it that needs its anchor to lead into. + // into an earlier one: its text is placed under a location row of its own, or + // there is location information above it that needs its location row to lead + // into. llvm::SmallVector opens_block_; // Whether each part's rows have been added. llvm::SmallVector drawn_; - // Location information waiting for the anchor it describes. - llvm::SmallVector context_; + // Location information waiting for the location row it describes. + llvm::SmallVector path_; llvm::SmallVector rows_; }; @@ -1253,13 +1447,13 @@ class RowLayout { } // namespace RowLayout::RowLayout(const Buffer& buffer, - llvm::MutableArrayRef parts, int headline, + llvm::MutableArrayRef parts, int leading, Theme problem_theme, Theme explanation_theme, int source_columns, int content_x, int columns) : buffer_(&buffer), metrics_(buffer.metrics()), parts_(parts), - headline_(headline), + leading_(leading), problem_theme_(problem_theme), explanation_theme_(explanation_theme), source_columns_(source_columns), @@ -1267,16 +1461,14 @@ RowLayout::RowLayout(const Buffer& buffer, columns_(columns), opens_block_(parts.size(), false), drawn_(parts.size(), false) { - bool context_pending = false; + bool path_pending = false; for (auto [index, part] : llvm::enumerate(parts)) { if (part.role == Part::LocationInfo) { - context_pending = true; + path_pending = true; continue; } - opens_block_[index] = - context_pending || - (static_cast(index) != headline && !part.text.empty()); - context_pending = false; + opens_block_[index] = path_pending || !part.text.empty(); + path_pending = false; } } @@ -1286,56 +1478,59 @@ auto RowLayout::LayOut() && -> llvm::SmallVector { AddBlock(index); } } - for (const PreparedPart* reached_from : context_) { - AddMessageRows(*reached_from); - } + CARBON_CHECK(path_.empty(), "Location information precedes its part."); return std::move(rows_); } auto RowLayout::AddBlock(size_t index) -> void { drawn_[index] = true; PreparedPart& part = parts_[index]; - bool is_headline = static_cast(index) == headline_; // Location information says how the location after it was reached, so it - // waits and is then drawn above that location's anchor. + // waits and is then drawn above the location row for that location. if (part.role == Part::LocationInfo) { - context_.push_back(&part); + path_.push_back(&part); + return; + } + + // A part with no source and no text draws nothing, so the path waiting for + // its location row is dropped. + if (!HasLocationRow(part)) { + path_.clear(); return; } if (InSnippet()) { - rows_.push_back({.kind = Row::Kind::Separator}); + rows_.push_back({.kind = Row::Kind::Elision}); } - if (!is_headline && !part.text.empty()) { - AddMessageRows(part); + for (const PreparedPart* reached_from : path_) { + rows_.push_back({.kind = Row::Kind::Path, .part = reached_from}); } - // An anchor is drawn where a snippet follows it, so a part with no source - // to show gets none: its words go on a row of their own, and an anchor - // above them would lead nowhere. The headline is the exception -- its - // location is the diagnostic's, worth saying even when it names only a - // file, as for a diagnostic about a file rather than about code in one. - bool anchored = !part.location.empty() && (part.has_source || is_headline); - // Without an anchor below them there is nothing for the steps to lead into, - // so they say where they are on rows of their own instead. - for (const PreparedPart* reached_from : context_) { - if (anchored) { - rows_.push_back({.kind = Row::Kind::Context, .part = reached_from}); - } else { - AddMessageRows(*reached_from); - } - } - context_.clear(); + path_.clear(); llvm::SmallVector group = TakeGroup(index); - if (anchored) { - rows_.push_back({.kind = Row::Kind::Anchor, .part = &part}); + rows_.push_back({.kind = Row::Kind::Location, .part = &part}); + + // A part with no source has its text placed under its location row. The + // file's spans, if any, follow below an elision, since they are elsewhere in + // the file. + // + // TODO: No toolchain diagnostic should reach this: the goal is every part + // attached to a location that reaches source, with one about a file as a + // whole located at the file's start or end and drawn in a form of its own. + // That restructuring starts with the emitting diagnostics. + if (!part.has_source) { + rows_.push_back( + {.kind = Row::Kind::LocationLabel, .part = &part, .text = part.text}); + if (!group.empty()) { + rows_.push_back({.kind = Row::Kind::Elision}); + } } - // The spans shown under one anchor are the ones drawn alongside each other - // here, so the group is what a range has to be in to stand in for the - // part's location: a range under an anchor of its own is read against + // The spans shown under one location row are the ones drawn alongside each + // other here, so the group is what a range has to be in to stand in for the + // part's location: a range under a location row of its own is read against // the code below that one instead. PreparedPart* message_part = nullptr; for (PreparedPart* member : group) { @@ -1347,11 +1542,11 @@ auto RowLayout::AddBlock(size_t index) -> void { PreparedPart* message_host = message_part ? FindMessageHost(group, *message_part) : nullptr; if (message_host) { - // The part marks nothing of its own once something else has taken its + // The part underlines nothing of its own once something else has taken its // place, so the line it named is not part of the snippet either -- unless - // an attached range is on it too. Leaving it in shows a line of source - // with nothing marking it, which reads as a line the reader is meant to - // find something in. + // an attached range is on it too. Leaving it in shows a line of source with + // nothing underlined, which reads as a line the reader is meant to find + // something in. llvm::erase(group, message_part); } @@ -1361,10 +1556,11 @@ auto RowLayout::AddBlock(size_t index) -> void { auto RowLayout::TakeGroup(size_t index) -> llvm::SmallVector { const PreparedPart& part = parts_[index]; llvm::SmallVector group; - if (!part.has_source) { + if (part.has_source) { + group.push_back(&parts_[index]); + } else if (part.file.empty()) { return group; } - group.push_back(&parts_[index]); for (size_t other : llvm::seq(index + 1, parts_.size())) { if (!drawn_[other] && !opens_block_[other] && parts_[other].has_source && parts_[other].file == part.file) { @@ -1382,17 +1578,6 @@ auto RowLayout::TakeGroup(size_t index) -> llvm::SmallVector { auto RowLayout::AddSnippet(llvm::ArrayRef group, PreparedPart* message_part, PreparedPart* message_host) -> void { - if (group.empty()) { - return; - } - - // A snippet always starts a row below its anchor, so that the code doesn't - // read as running on from the file name. Where the file goes on above the - // first line shown, that row says so instead. - int first_line = group.front()->line_number; - rows_.push_back( - {.kind = first_line > 1 ? Row::Kind::Elision : Row::Kind::Gap}); - // Spans on one line are drawn together, against the one row that shows it. const PreparedPart* previous = nullptr; for (size_t begin = 0; begin < group.size();) { @@ -1447,29 +1632,30 @@ auto RowLayout::AddLine(llvm::ArrayRef line, llvm::SmallVector spans = SpansWidestFirst(line, message_part, message_host); - RotateMarkStyles(spans, problem_theme_, explanation_theme_); - // The part's connector and bar follow the range hosting its words, so - // the rotation's choice for the host is copied after it is made. + const PreparedPart* heavy_underline = + MoveHeavyUnderlinesLast(spans, message_part, message_host); + RotateUnderlineStyles(spans, problem_theme_, explanation_theme_); + // The part's label line and bar follow the range hosting its words, so the + // rotation's choice for the host is copied after it is made. if (message_host && llvm::is_contained(spans, message_host)) { - message_part->mark_style = message_host->mark_style; + message_part->underline_style = message_host->underline_style; } - // The mark in the margin picks out the lines the problem is on, which is - // every line holding a range that is part of it. It is drawn in what the - // headline is drawn in, so that it reads as part of the same sentence. - bool marks_problem = llvm::any_of(spans, [](const PreparedPart* span) { - return span->role == Part::Problem; - }); + // The `->` in the margin points to the one line to begin reading at: the line + // the leading part's text is placed under, wherever it is in the frame. A + // problem range on any other line keeps its color and nothing more. The + // `->` and line number take the leading part's style, matching its level + // word. rows_.push_back({.kind = Row::Kind::Source, .part = line.front(), - .points_here = marks_problem ? &parts_[headline_] : nullptr, + .points_here = heavy_underline ? &parts_[leading_] : nullptr, .line_number = line.front()->line_number, .text = line.front()->source.text}); llvm::SmallVector labels = LabelsHangingFrom(spans, message_part, message_host); - // The ranges a connector will hang from, which is what decides whether a + // The ranges a label line will hang from, which is what decides whether a // range can afford to give up half a column at an end. llvm::SmallPtrSet carries_label; for (PreparedPart* label : labels) { @@ -1478,101 +1664,115 @@ auto RowLayout::AddLine(llvm::ArrayRef line, } SeparateTouchingEnds(spans, carries_label); - PlaceLabels(metrics_, labels, message_part, message_host, spans, content_x_, + SortLabelsForReading(labels, message_part, message_host); + PlaceLabels(*buffer_, labels, message_part, message_host, spans, content_x_, columns_); - // Right to left, so that each label's connector reaches across the ones - // already hanging rather than descending through them. - llvm::stable_sort(labels, - [](const PreparedPart* lhs, const PreparedPart* rhs) { - return lhs->source.anchor > rhs->source.anchor; - }); - rows_.push_back( - {.kind = Row::Kind::Annotation, .spans = {spans.begin(), spans.end()}}); + {.kind = Row::Kind::Underline, .spans = {spans.begin(), spans.end()}}); AddLabelRows(labels); } auto RowLayout::AddLabelRows(llvm::ArrayRef labels) -> void { + // The leftmost column the next label's text may start in, stepping right + // with each label so the indentation follows the row order. It starts right + // of every label line's column, so a label line descending to a later label + // runs beside the text above it, crossing each row in a single cell of a + // run and never at a junction. + int next_label_x = 0; + for (const PreparedPart* label : labels) { + next_label_x = + std::max(next_label_x, label->source.line_column + LabelIndentWidth); + } for (PreparedPart* label : labels) { + label->source.label_x = + std::max(next_label_x, label->source.line_column + LabelIndentWidth); // A single unbreakable word can be wider than what is left to the right // of where the label hangs, and hanging it there would push it out of the // frame. Wrapping never breaks a word, so the widest one is the least // width the label can be drawn in. Below that the label is out-dented to // the column the source starts in, where the whole width is available, - // and the line reaching back to the connector is what says which range it + // and the line reaching back to the label line is what says which range it // belongs to. - bool routed = content_x_ + label->source.anchor + LabelIndentWidth + - buffer_->MeasureWrapWidth(label->label) > - columns_; + int prefix_width = + label->is_leading ? metrics_.Width(label->level_text) : 0; + bool routed = + content_x_ + label->source.label_x + prefix_width + + buffer_->MeasureWrapWidth(label->label, BackticksAreQuotes) > + columns_; + // An out-dented label's text starts at the source's column, so it does + // not move where the next label's text starts. + if (!routed) { + next_label_x = label->source.label_x + LabelStepWidth; + } rows_.push_back({.kind = routed ? Row::Kind::RoutedLabel : Row::Kind::Label, .part = label, .text = label->label}); } } -auto RowLayout::AddMessageRows(const PreparedPart& part) -> void { - rows_.push_back({.kind = Row::Kind::Message, - .part = &part, - .text = MessageRowText(part)}); -} - auto RowLayout::InSnippet() const -> bool { if (rows_.empty()) { return false; } switch (rows_.back().kind) { case Row::Kind::Source: - case Row::Kind::Annotation: + case Row::Kind::Underline: case Row::Kind::Label: case Row::Kind::RoutedLabel: + case Row::Kind::LocationLabel: case Row::Kind::Elision: - case Row::Kind::Gap: return true; - case Row::Kind::Message: - case Row::Kind::Anchor: - case Row::Kind::Separator: - case Row::Kind::Context: + case Row::Kind::Location: + case Row::Kind::Path: return false; } } -// Draws the line running from an underline at `annotation_y` down to `meet_y`, -// in the column a label hangs from. +// Draws the leading part's label line, from the underline at `underline_y` down +// to `meet_y`. // // It stops at the center of the cell the underline drew rather than redrawing // it, so where the underline runs out through both sides of that cell the two -// form a junction. Where it stands in for a mark of one column instead, -// stopping at the center is what keeps the mark to the lower half of its cell, -// so that two of them in neighboring columns read as two marks rather than as -// one line drawn down both. -static auto DrawConnector(Buffer& buffer, int x, int annotation_y, int meet_y, - const Style& style) -> void { - buffer.DrawVerticalLine(x, annotation_y, meet_y - annotation_y + 1, style, - LineEnd::Center, LineEnd::Center); +// form a junction. Where it stands in for an underline of one column instead, +// stopping at the center is what keeps the underline to the lower half of its +// cell, so that two of them in neighboring columns read as two underlines +// rather than as one line drawn down both. +// +// The cell on the underline row is drawn heavy whatever `weight` is, since it +// is part of the heavy underline. Under ASCII, where `weight` is light, that +// cell keeps the tee inside the `^` run, or is the `^` itself when the label +// line is drawn in place of a one-column underline. +static auto DrawLeadingLabelLine(Buffer& buffer, int x, int underline_y, + int meet_y, const Style& style, + Terminal::LineWeight weight) -> void { + buffer.DrawVerticalLine(x, underline_y, 1, style, LineEnd::Center, + LineEnd::Edge, Terminal::LineWeight::Heavy); + buffer.DrawVerticalLine(x, underline_y + 1, meet_y - underline_y, style, + LineEnd::Edge, LineEnd::Center, weight); } // Draws `number` in the columns before the frame, or nothing when there is no // line to name. // -// `points_here` is the message whose location is on this line, which takes the -// margin outside the numbers and colors the number to match what the headline -// says. Everything else keeps the frame's own color, so the one line the -// message is about is the one that isn't part of the frame. +// `points_here` is the leading part when its text is placed under this line. +// It draws `->` in the margin and colors the number to match the level word. +// Every other number keeps the frame's color, so the line to begin reading at +// is the one that stands out from the frame. static auto DrawLineNumber(Buffer& buffer, int frame_x, int y, int number, const PreparedPart* points_here) -> void { if (number <= 0) { return; } std::string text = std::to_string(number); - // The line the problem is on takes the headline's color and its weight, and + // The line the problem is on takes the leading part's color and weight, and // every other line number is left as light as the frame it belongs to, so // that the one being reported is the one that stands out rather than every // number competing with it. Style style = points_here ? points_here->style : FrameStyle().Bold(false); buffer.DrawText(frame_x - 1 - text.size(), y, text, style); if (points_here) { - buffer.DrawText(0, y, LineMark, style); + buffer.DrawText(0, y, LineArrow, style); } } @@ -1587,22 +1787,11 @@ static auto WrappedSharesRow(const Buffer& buffer, int x, int y, int columns, -> bool { return buffer .MeasureWrappedText(x, y, /*margin=*/x, columns, - (llvm::Twine(text) + suffix).str()) + (llvm::Twine(text) + suffix).str(), + BackticksAreQuotes) .y == y; } -// Returns the row after what `DrawWrapped` below draws, without drawing it. -static auto MeasureWrapped(const Buffer& buffer, int x, int y, int columns, - llvm::StringRef text, llvm::StringRef suffix) - -> int { - Buffer::DrawEnd end = - buffer.MeasureWrappedText(x, y, /*margin=*/x, columns, text); - if (suffix.empty() || WrappedSharesRow(buffer, x, y, columns, text, suffix)) { - return end.y + 1; - } - return end.y + 2; -} - // Draws `text` wrapped into `columns` at (x, y), with `suffix` after it, and // returns the row after what it drew. // @@ -1613,11 +1802,14 @@ static auto DrawWrapped(Buffer& buffer, int x, int y, int columns, llvm::StringRef text, llvm::StringRef suffix, Style style = Style()) -> int { if (suffix.empty()) { - return buffer.DrawWrappedText(x, y, /*margin=*/x, columns, text, style).y + + return buffer + .DrawWrappedText(x, y, /*margin=*/x, columns, text, style, + BackticksAreQuotes) + .y + 1; } - Buffer::DrawEnd end = - buffer.DrawWrappedText(x, y, /*margin=*/x, columns, text, style); + Buffer::DrawEnd end = buffer.DrawWrappedText(x, y, /*margin=*/x, columns, + text, style, BackticksAreQuotes); if (WrappedSharesRow(buffer, x, y, columns, text, suffix)) { buffer.DrawText(end.x, end.y, suffix, KindStyle()); return end.y + 1; @@ -1641,7 +1833,7 @@ auto Renderer::Render(Terminal::OutputBufferRef out, // A `PreparedPart` is undesirably large for inline storage by // SmallVector, so we specify 0. llvm::SmallVector parts; - int headline = -1; + int leading = -1; // Which colors this terminal gets, decided once: everything drawn takes one // of them. @@ -1651,22 +1843,22 @@ auto Renderer::Render(Terminal::OutputBufferRef out, // What leads the diagnostic is drawn at its level and everything else as // something explaining it, except that a primary range is part of the problem // and so keeps the level's color wherever down the frame it sits. - auto add_part = [&](bool is_headline, bool is_problem, bool from_message_loc, + auto add_part = [&](bool is_leading, bool is_problem, bool from_message_loc, const Loc& loc, std::string text, llvm::StringRef name) { - if (is_headline) { - headline = parts.size(); + if (is_leading) { + leading = parts.size(); } parts.push_back( PreparePart(metrics, is_problem ? Part::Problem : Part::Explanation, from_message_loc, - is_headline ? LevelText(diagnostic.level) : ExplanationText, + is_leading ? LevelText(diagnostic.level) : ExplanationText, ThemeStyle(is_problem ? problem_theme : explanation_theme), - loc, std::move(text), name, is_headline, include_kind_)); + loc, std::move(text), name, is_leading, include_kind_)); }; // The same file reached the same way is a path drawn once. A path says how a - // file was got to, so every range marked in that file has the same one, and - // repeating it under each of them says nothing the first didn't. + // file was got to, so every range underlined in that file has the same one, + // and repeating it under each of them says nothing the first didn't. std::string last_place; auto add_location_info = [&](llvm::ArrayRef steps, const Loc& reaches) { @@ -1681,8 +1873,8 @@ auto Renderer::Render(Terminal::OutputBufferRef out, for (const LocationInfo& step : steps) { parts.push_back(PreparePart( metrics, Part::LocationInfo, /*from_message_loc=*/false, - /*level_text=*/"", ContextStyle(), step.loc, step.Format(), step.name, - /*is_headline=*/false, include_kind_)); + /*level_text=*/"", PathStyle(), step.loc, step.Format(), step.name, + /*is_leading=*/false, include_kind_)); } }; @@ -1692,25 +1884,28 @@ auto Renderer::Render(Terminal::OutputBufferRef out, add_location_info(context.location_info, context.loc); // Only the leading context is the failure being reported; the rest name // operations it happened inside, which explain it. - bool is_headline = &context == leading_context; - add_part(is_headline, is_headline, /*from_message_loc=*/false, context.loc, + bool is_leading = &context == leading_context; + add_part(is_leading, is_leading, /*from_message_loc=*/false, context.loc, context.Format(), context.name); } const Message& message = diagnostic.message; add_location_info(message.location_info, message.loc); // The message states the problem whether or not a context leads it: a // context gives it a sentence to sit under, and doesn't demote what it says - // to an explanation of something else. Marking it otherwise puts an - // informational connector on a range that is marked as part of the problem. + // to an explanation of something else. Doing otherwise puts an informational + // label line on a range that is underlined as part of the problem. bool message_leads = leading_context == nullptr; add_part(message_leads, /*is_problem=*/true, /*from_message_loc=*/true, message.loc, message.Format(), message.kind.name()); + // A label's location information is not drawn: how the file holding a + // declaration was reached is rarely useful, and Clang and GCC omit note + // include stacks for the same reason. Only the path to the problem itself, + // the message's own location and a context's, is shown. for (const Label& label : diagnostic.labels) { - add_location_info(label.location_info, label.loc); - add_part(/*is_headline=*/false, label.category == LabelCategory::Primary, + add_part(/*is_leading=*/false, label.category == LabelCategory::Primary, /*from_message_loc=*/false, label.loc, label.Format(), label.name); } - CARBON_CHECK(headline >= 0, "Either the context or the message leads."); + CARBON_CHECK(leading >= 0, "Either the context or the message leads."); // With snippets off, every diagnostic takes the compact form: nothing below // is drawn, so none of its geometry needs deciding. @@ -1765,17 +1960,355 @@ auto Renderer::Render(Terminal::OutputBufferRef out, return; } - RenderFramed(out, parts, headline, diagnostic.level, frame_x, content_x, + RenderFramed(out, parts, leading, diagnostic.level, frame_x, content_x, source_columns, columns); } -// Draws the framed form: the headline, and under it one frame holding every -// anchor, snippet, and label. The geometry arrives from `Render`, which chose -// it; the spans are windowed in `LayOutRows`, which knows which of them share -// a view of a line. +namespace { + +// Draws the rows `RowLayout` lays out, with the frame beside them. +class FrameRenderer { + public: + FrameRenderer(Buffer& buffer, Charset charset, int frame_x, int content_x, + int columns, Style dotted_frame_style) + : buffer_(&buffer), + glyphs_(Glyphs::For(charset)), + charset_(charset), + frame_x_(frame_x), + content_x_(content_x), + columns_(columns), + dotted_frame_style_(dotted_frame_style) {} + + // Draws `rows` from the buffer's first row, followed by the closing rule. + auto Draw(llvm::ArrayRef rows) -> void; + + private: + // Each of these draws one kind of row starting at row `y`, and returns the + // row after what it drew, which is further down when text wraps. + auto DrawLocationRow(const PreparedPart& part, int y) -> int; + auto DrawPath(const PreparedPart& part, int y) -> int; + auto DrawSource(const Row& row, int y) -> int; + auto DrawUnderlineRow(const Row& row, int y) -> int; + auto DrawLabel(const Row& row, int y) -> int; + auto DrawRoutedLabel(const Row& row, int y) -> int; + auto DrawLocationLabel(const Row& row, int y) -> int; + + // Draws the frame beside rows `[y, next_y)`, which hold a row of `kind`. + auto DrawFrame(Row::Kind kind, int y, int next_y) -> void; + + // Returns the stroke weight of the label line and bar of `part`'s label: + // heavy for the leading part under Unicode, matching its heavy underline. + // ASCII draws a heavy line as `^`, which belongs on the underline row alone, + // so there the leading part's label line and bar are light like every other + // label's. + auto LabelWeight(const PreparedPart& part) const -> Terminal::LineWeight; + + // Draws `text` for `part` from (x, y), after its level word and in bold when + // it leads, and returns the row after the text. + auto DrawLabelText(const PreparedPart& part, llvm::StringRef text, int x, + int y, bool is_label_row) -> int; + + // Draws a label's bar in column `x` as a separate line on each of rows + // `[y, next_y)` instead of one line through them, so that each cell is drawn + // as a bar: the one the label line meets is a tee instead of the corner an + // end would be, and a label of one row is framed the same as a label of ten. + auto DrawBar(int x, int y, int next_y, const Style& style, + Terminal::LineWeight weight) -> void; + + // Draws a label line from the underline row down to row `y` in column `x`, + // ending in the upper half of the corner that turns toward the label. The + // leading part's label row is the first under its underline, so its label + // line runs down a clear column and joins what it meets. Every other label + // line crosses the label rows drawn above it without joining them, so what + // they drew stays whole, and the upper half of its corner is drawn + // separately. + auto DrawLabelLine(const PreparedPart& part, int x, int y, const Style& style, + Terminal::LineWeight weight) -> void; + + // Draws a label line from the underline row down to the row above `to_y` in + // column `x`. It breaks around every line drawn earlier and skips the rows of + // out-dented blocks, resuming below each one. + auto DrawCrossing(int x, int to_y, const Style& style) -> void; + + Buffer* buffer_; + Glyphs glyphs_; + Charset charset_; + int frame_x_; + int content_x_; + int columns_; + + // The frame's glyph on underline and label rows is in the frame's column, so + // it takes one color for the whole diagnostic instead of the color of the + // range on that row: the leading part's, which the `->` and the reported + // line's number also take. + Style dotted_frame_style_; + + // The row the underlines were drawn on, which every label below it connects + // back up to. A label can be several rows down from it, since the labels on + // one underline row stack. + int underline_y_ = -1; + + // The rows below the underline row that out-dented labels' text occupies, as + // `[first, past-the-last)` pairs in drawing order. A label line descending + // past them skips these rows. + llvm::SmallVector> outdented_rows_; +}; + +} // namespace + +auto FrameRenderer::Draw(llvm::ArrayRef rows) -> void { + // A row that wraps pushes the ones below it down, so `y` follows what was + // drawn instead of counting rows. + int y = 0; + for (const Row& row : rows) { + int next_y = y + 1; + switch (row.kind) { + case Row::Kind::Location: + next_y = DrawLocationRow(*row.part, y); + break; + case Row::Kind::Path: + next_y = DrawPath(*row.part, y); + break; + case Row::Kind::Source: + next_y = DrawSource(row, y); + break; + case Row::Kind::Underline: + next_y = DrawUnderlineRow(row, y); + break; + case Row::Kind::Label: + next_y = DrawLabel(row, y); + break; + case Row::Kind::RoutedLabel: + next_y = DrawRoutedLabel(row, y); + break; + case Row::Kind::LocationLabel: + next_y = DrawLocationLabel(row, y); + break; + case Row::Kind::Elision: + break; + } + DrawFrame(row.kind, y, next_y); + y = next_y; + } + + // The closing rule turns the corner the frame's last row left for it. + buffer_->DrawVerticalLine(frame_x_, y, 1, FrameStyle(), LineEnd::Edge, + LineEnd::Center); + buffer_->DrawHorizontalLine(frame_x_, y, CloseRuleWidth, FrameStyle(), + LineEnd::Center, LineEnd::Edge); +} + +// Draws `╭─┤ location`. The bracket is drawn as lines so that the character set +// decides how it looks, and so that a path row above can connect down into it. +auto FrameRenderer::DrawLocationRow(const PreparedPart& part, int y) -> int { + buffer_->DrawHorizontalLine(frame_x_, y, 3, FrameStyle()); + buffer_->DrawVerticalLine(frame_x_ + 2, y, 1, FrameStyle(), LineEnd::Edge, + LineEnd::Edge); + buffer_->DrawText(frame_x_ + LocationPrefixWidth, y, + part.location.empty() ? llvm::StringRef(NoLocationText) + : llvm::StringRef(part.location), + Style()); + // The `->` points to where the leading part's text is placed. With no source + // row for it, that is this location row. + if (part.is_leading && !part.has_source) { + buffer_->DrawText(0, y, LineArrow, part.style); + } + return y + 1; +} + +// Draws a step of a path. Its line descends into the bracket before the file +// name in the location row below, so the row shows that it leads there. It is +// drawn downwards so that several steps stack into one line. +auto FrameRenderer::DrawPath(const PreparedPart& part, int y) -> int { + int bracket_x = frame_x_ + 2; + buffer_->DrawVerticalLine(bracket_x, y, 2, FrameStyle()); + buffer_->DrawHorizontalLine(bracket_x, y, LineToTextWidth - 1, FrameStyle(), + LineEnd::Center, LineEnd::Edge); + std::string text = PathText(part); + int text_x = bracket_x + LineToTextWidth; + Buffer::DrawEnd end = buffer_->DrawText(text_x, y, text, PathStyle()); + buffer_->DrawText(end.x, end.y, part.kind_suffix, KindStyle()); + return y + 1; +} + +auto FrameRenderer::DrawSource(const Row& row, int y) -> int { + DrawLineNumber(*buffer_, frame_x_, y, row.line_number, row.points_here); + buffer_->DrawText(content_x_, y, row.text, Style()); + return y + 1; +} + +auto FrameRenderer::DrawUnderlineRow(const Row& row, int y) -> int { + underline_y_ = y; + outdented_rows_.clear(); + for (const PreparedPart* span : row.spans) { + DrawUnderline(*buffer_, content_x_, y, *span, span->underline_style); + } + return y + 1; +} + +// Draws a label to the right of its label line, which meets the bar framing it +// on its first row, where the text and any level word begin, so that following +// the line from the underline arrives at the start of the sentence. The bar +// continues down every row the text wraps onto. +auto FrameRenderer::DrawLabel(const Row& row, int y) -> int { + const PreparedPart& part = *row.part; + int line_x = content_x_ + part.source.line_column; + int text_x = content_x_ + part.source.label_x; + int bar_x = text_x - LabelFrameWidth; + const Style& style = part.underline_style; + Terminal::LineWeight weight = LabelWeight(part); + int next_y = DrawLabelText(part, row.text, text_x, y, /*is_label_row=*/true); + DrawBar(bar_x, y, next_y, style, weight); + DrawLabelLine(part, line_x, y, style, weight); + buffer_->DrawHorizontalLine(line_x, y, bar_x - line_x + 1, style, + LineEnd::Center, LineEnd::Center, weight); + return next_y; +} + +// Draws a label out-dented past its label line, where there is no room to meet +// it from the left. The bar framing it connects instead: its top turns right +// along the row under the underline row and runs to the label line. Meeting the +// label at its top lets the bar be directly against the text, which is the +// width out-denting is for. +auto FrameRenderer::DrawRoutedLabel(const Row& row, int y) -> int { + const PreparedPart& part = *row.part; + int line_x = content_x_ + part.source.line_column; + int bar_x = content_x_; + int text_x = bar_x + LabelFrameWidth; + const Style& style = part.underline_style; + Terminal::LineWeight weight = LabelWeight(part); + DrawLabelLine(part, line_x, y, style, weight); + buffer_->DrawHorizontalLine(bar_x, y, line_x - bar_x + 1, style, + LineEnd::Center, LineEnd::Center, weight); + int next_y = + DrawLabelText(part, row.text, text_x, y + 1, /*is_label_row=*/true); + buffer_->DrawVerticalLine(bar_x, y, next_y - y, style, LineEnd::Center, + LineEnd::Edge, weight); + // The block occupies its rows from the bar to the right edge, blank cells + // included, so a later label line skips those rows instead of showing through + // the gaps between words. + outdented_rows_.push_back({y + 1, next_y}); + return next_y; +} + +// Draws the text of a part with no source under its location row, the way a +// label is placed under its underline, with the label line's corner in the +// source's first column. There is no underline above it, so the line starts at +// the corner. +auto FrameRenderer::DrawLocationLabel(const Row& row, int y) -> int { + const PreparedPart& part = *row.part; + int line_x = content_x_; + int text_x = content_x_ + LabelIndentWidth; + int bar_x = text_x - LabelFrameWidth; + const Style& style = part.underline_style; + Terminal::LineWeight weight = LabelWeight(part); + int next_y = DrawLabelText(part, row.text, text_x, y, /*is_label_row=*/false); + DrawBar(bar_x, y, next_y, style, weight); + buffer_->DrawVerticalLine(line_x, y, 1, style, LineEnd::Edge, LineEnd::Center, + weight); + buffer_->DrawHorizontalLine(line_x, y, bar_x - line_x + 1, style, + LineEnd::Center, LineEnd::Center, weight); + return next_y; +} + +auto FrameRenderer::DrawFrame(Row::Kind kind, int y, int next_y) -> void { + // The frame's line runs the whole height of the row, edge to edge, so that + // consecutive rows' lines join without either reaching into the other's + // cells. Only the first row's line starts at a center, which leaves that + // cell a corner for the location row to turn. The line is drawn a row at a + // time: drawing it first would need its full height, which isn't known until + // the rows that wrap are drawn, and drawing it last would cover the glyphs + // drawn over it below. + buffer_->DrawVerticalLine(frame_x_, y, next_y - y, FrameStyle(), + y == 0 ? LineEnd::Center : LineEnd::Edge, + LineEnd::Edge); + char32_t glyph = glyphs_.dotted_frame; + Style style = dotted_frame_style_; + switch (kind) { + case Row::Kind::Underline: + case Row::Kind::Label: + case Row::Kind::RoutedLabel: + case Row::Kind::LocationLabel: + break; + case Row::Kind::Elision: + glyph = glyphs_.elision; + style = FrameStyle(); + break; + case Row::Kind::Location: + case Row::Kind::Path: + case Row::Kind::Source: + return; + } + for (int row_y : llvm::seq(y, next_y)) { + buffer_->DrawCodePoint(frame_x_, row_y, glyph, style); + } +} + +auto FrameRenderer::LabelWeight(const PreparedPart& part) const + -> Terminal::LineWeight { + return part.is_leading && charset_ == Charset::Utf8 + ? Terminal::LineWeight::Heavy + : Terminal::LineWeight::Light; +} + +auto FrameRenderer::DrawLabelText(const PreparedPart& part, + llvm::StringRef text, int x, int y, + bool is_label_row) -> int { + Style style; + if (part.is_leading) { + x = buffer_->DrawText(x, y, part.level_text, part.style).x; + style = Style().Bold(); + } + return DrawWrapped(*buffer_, x, y, columns_ - x, text, + part.KindSuffixOn(is_label_row), style); +} + +auto FrameRenderer::DrawBar(int x, int y, int next_y, const Style& style, + Terminal::LineWeight weight) -> void { + for (int bar_y : llvm::seq(y, next_y)) { + buffer_->DrawVerticalLine(x, bar_y, 1, style, LineEnd::Edge, LineEnd::Edge, + weight); + } +} + +auto FrameRenderer::DrawLabelLine(const PreparedPart& part, int x, int y, + const Style& style, + Terminal::LineWeight weight) -> void { + CARBON_CHECK(underline_y_ >= 0, + "A label row follows the underline row it is placed under."); + if (part.is_leading) { + DrawLeadingLabelLine(*buffer_, x, underline_y_, y, style, weight); + } else { + DrawCrossing(x, y, style); + buffer_->DrawVerticalLine(x, y, 1, style, LineEnd::Edge, LineEnd::Center); + } +} + +auto FrameRenderer::DrawCrossing(int x, int to_y, const Style& style) -> void { + int from_y = underline_y_; + LineEnd start = LineEnd::Center; + for (auto [top, bottom] : outdented_rows_) { + if (bottom <= from_y || top >= to_y) { + continue; + } + if (top > from_y) { + buffer_->DrawCrossingVerticalLine(x, from_y, top - from_y, style, start); + } + from_y = bottom; + start = LineEnd::Edge; + } + if (from_y < to_y) { + buffer_->DrawCrossingVerticalLine(x, from_y, to_y - from_y, style, start); + } +} + +// Draws the framed form: one frame holding every location row, snippet, and +// label, with the leading part's text placed under the range that is wrong. +// `Render` chose the geometry; `RowLayout::AddLine` windows the spans, since it +// knows which of them share a view of a line. auto Renderer::RenderFramed(Terminal::OutputBufferRef out, llvm::MutableArrayRef parts, - int headline, Level level, int frame_x, + int leading, Level level, int frame_x, int content_x, int source_columns, int columns) const -> void { Theme problem_theme = LevelTheme(level, capabilities_); @@ -1789,233 +2322,30 @@ auto Renderer::RenderFramed(Terminal::OutputBufferRef out, Buffer buffer(layout_capabilities); llvm::SmallVector rows = - RowLayout(buffer, parts, headline, problem_theme, explanation_theme, + RowLayout(buffer, parts, leading, problem_theme, explanation_theme, source_columns, content_x, columns) .LayOut(); - Glyphs glyphs = Glyphs::For(capabilities_.charset); - - // The headline, wrapped under itself so that a continuation of it can't read - // as the start of another diagnostic. - const PreparedPart& head = parts[headline]; - // The separator beside an annotation runs down the frame's own column and - // reads as part of it, so it takes one color for the whole diagnostic rather - // than the color of whichever range happens to be on that row. That color is - // the headline's, which is what the mark in the margin and the line number - // beside the reported line take. - const Style annotation_style = MarkStyle(head.style); - Buffer::DrawEnd end = buffer.DrawText(0, 0, head.level_text, head.style); - int head_x = end.x; - int head_bottom = DrawWrapped(buffer, head_x, 0, columns - head_x, head.text, - head.kind_suffix, Style().Bold()); - - // Then everything else, hanging off one vertical line down the frame's - // column. Its corners and tees come out of the junctions the buffer forms - // where the stubs meet it, and rows that mark themselves draw their glyph - // over it. A row that wraps pushes the ones below it down, so the cursor - // follows what was drawn rather than counting rows. - int frame_top = head_bottom; - int y = frame_top; - // The row the underlines were drawn on, which is where every label below it - // reaches back up to. A label can be several rows down from it, since the - // labels on one underline stack. - int annotation_y = -1; - // A routed label's words, held back until every connector is drawn; see the - // `RoutedLabel` case below. - struct DeferredText { - int x; - int y; - int columns; - const Row* row; - }; - llvm::SmallVector deferred_text; - for (const Row& row : rows) { - CARBON_CHECK(annotation_y >= 0 || (row.kind != Row::Kind::Label && - row.kind != Row::Kind::RoutedLabel), - "A label hangs off the underline laid out above it."); - int next_y = y + 1; - const PreparedPart* part = row.part; - // What this row draws over the frame, from `mark_from` down, or nothing to - // leave the frame's own line showing through. - std::optional mark; - Style mark_style = FrameStyle(); - int mark_from = y; - switch (row.kind) { - case Row::Kind::Message: { - buffer.DrawHorizontalLine(frame_x, y, 2, FrameStyle(), LineEnd::Center, - LineEnd::Edge); - Buffer::DrawEnd end = - buffer.DrawText(content_x + 1, y, part->level_text, part->style); - next_y = DrawWrapped( - buffer, end.x, y, columns - end.x, row.text, - part->KindSuffixOn(/*is_label_row=*/false), - part->role == Part::LocationInfo ? ContextStyle() : Style()); - mark = glyphs.annotation; - mark_from = y + 1; - break; - } - case Row::Kind::Anchor: - // `╭─┤ location`. The bracket is drawn as lines so that the character - // set decides how it looks, and so that the context above can reach - // down into it. - buffer.DrawHorizontalLine(frame_x, y, 3, FrameStyle()); - buffer.DrawVerticalLine(frame_x + 2, y, 1, FrameStyle(), LineEnd::Edge, - LineEnd::Edge); - buffer.DrawText(frame_x + AnchorPrefixWidth, y, part->location, - Style()); - break; - case Row::Kind::Context: { - // The connector descends into the bracket before the file name in the - // anchor below, so the row reads as leading to it. Drawn downwards so - // that several of these stack into one line. - int bracket_x = frame_x + 2; - buffer.DrawVerticalLine(bracket_x, y, 2, FrameStyle()); - buffer.DrawHorizontalLine(bracket_x, y, ConnectorWidth - 1, - FrameStyle(), LineEnd::Center, LineEnd::Edge); - std::string text = ContextText(*part); - int text_x = bracket_x + ConnectorWidth; - Buffer::DrawEnd end = buffer.DrawText(text_x, y, text, ContextStyle()); - buffer.DrawText(end.x, end.y, part->kind_suffix, KindStyle()); - break; - } - case Row::Kind::Source: - DrawLineNumber(buffer, frame_x, y, row.line_number, row.points_here); - buffer.DrawText(content_x, y, row.text, Style()); - break; - case Row::Kind::Annotation: { - annotation_y = y; - for (const PreparedPart* span : row.spans) { - DrawUnderline(buffer, content_x, y, *span, span->mark_style); - } - mark = glyphs.annotation; - mark_style = annotation_style; - break; - } - case Row::Kind::Label: { - // The label hangs to the right of the connector, which comes in from - // the left to meet the bar framing it, at its middle row -- the row - // above the middle when it has an even number of them. - int anchor_x = content_x + part->source.anchor; - int text_x = anchor_x + LabelIndentWidth; - int bar_x = text_x - LabelFrameWidth; - const Style& style = part->mark_style; - next_y = DrawWrapped(buffer, text_x, y, columns - text_x, row.text, - part->KindSuffixOn(/*is_label_row=*/true)); - - // The bar is a stroke on each of the label's rows rather than one line - // running between them, so every cell of it reads as a bar: the one the - // connector arrives at is a tee rather than the corner an end would be, - // and a label of one row is framed the same as a label of ten. - for (int bar_y : llvm::seq(y, next_y)) { - buffer.DrawVerticalLine(bar_x, bar_y, 1, style, LineEnd::Edge, - LineEnd::Edge); - } - // The connector runs from the underline down past whatever labels are - // already hanging to the right of this one, all of which leave the - // column it descends in clear -- except a routed label, whose words - // are drawn last so that they win the cell; see below. - int meet_y = y + (next_y - y - 1) / 2; - DrawConnector(buffer, anchor_x, annotation_y, meet_y, style); - buffer.DrawHorizontalLine(anchor_x, meet_y, ConnectorWidth, style); - mark = glyphs.annotation; - mark_style = annotation_style; - break; - } - case Row::Kind::RoutedLabel: { - // The label is out-dented past its anchor, so there is no room to reach - // it from the left and the bar framing it is what reaches back instead: - // its top turns right along the row under the underline and runs to the - // anchor. Meeting the label at its top rather than its middle is what - // lets the bar sit directly against the text, which is where the width - // this form exists to find comes from. - int anchor_x = content_x + part->source.anchor; - int bar_x = content_x; - int text_x = bar_x + LabelFrameWidth; - const Style& style = part->mark_style; - DrawConnector(buffer, anchor_x, annotation_y, y, style); - buffer.DrawHorizontalLine(bar_x, y, anchor_x - bar_x + 1, style); - - // The words reach across the full width, so a label drawn after this - // one -- to its left, and so below it -- runs its connector through - // their rows. The words win the cells they share: they are measured - // now, so the rows below land where they will, and drawn once every - // connector is down, so a connector crossing this label is interrupted - // by its words rather than striking through them. - next_y = - MeasureWrapped(buffer, text_x, y + 1, columns - text_x, row.text, - part->KindSuffixOn(/*is_label_row=*/true)); - deferred_text.push_back({.x = text_x, - .y = y + 1, - .columns = columns - text_x, - .row = &row}); - buffer.DrawVerticalLine(bar_x, y, next_y - y, style, LineEnd::Center, - LineEnd::Edge); - mark = glyphs.annotation; - mark_style = annotation_style; - break; - } - case Row::Kind::Elision: - mark = glyphs.elision; - break; - case Row::Kind::Gap: - // The frame's own line running through is all this row is. - break; - case Row::Kind::Separator: - // The same rule that closes the diagnostic, tee'd because the frame - // carries on past it. - buffer.DrawHorizontalLine(frame_x, y, SnippetRuleWidth, FrameStyle(), - LineEnd::Center, LineEnd::Edge); - break; - } - - // The frame's line runs the whole height of the row, edge to edge, so that - // consecutive rows carry on into each other without either reaching into - // the other's cells. Only the topmost row starts at a center, which is what - // leaves that cell a corner for the anchor to turn. It can't be drawn in - // one pass afterwards because a row that wraps pushes the ones below it - // down, so how far it reaches isn't known until every row is drawn -- and - // it can't be drawn in one pass beforehand because it would cover the - // glyphs. - buffer.DrawVerticalLine(frame_x, y, next_y - y, FrameStyle(), - y == frame_top ? LineEnd::Center : LineEnd::Edge, - LineEnd::Edge); - if (mark) { - for (int row_y : llvm::seq(mark_from, next_y)) { - buffer.DrawCodePoint(frame_x, row_y, *mark, mark_style); - } - } - y = next_y; - } - - // The routed labels' words, drawn over whatever connectors crossed them. - for (const DeferredText& text : deferred_text) { - DrawWrapped(buffer, text.x, text.y, text.columns, text.row->text, - text.row->part->KindSuffixOn(/*is_label_row=*/true)); - } - - // The closing rule turns the corner the frame's last row left for it. - buffer.DrawVerticalLine(frame_x, y, 1, FrameStyle(), LineEnd::Edge, - LineEnd::Center); - buffer.DrawHorizontalLine(frame_x, y, SnippetRuleWidth, FrameStyle(), - LineEnd::Center, LineEnd::Edge); + FrameRenderer(buffer, capabilities_.charset, frame_x, content_x, columns, + UnderlineStyle(parts[leading].style)) + .Draw(rows); buffer.Render(out, capabilities_.color_mode); } // Draws the row `part` takes in the compact form -- its location with the // extent of its range, level word, words, and kind -- and returns whether one -// was drawn: a part that only marks a range has nothing to say on a row of its -// own. +// was drawn: a part that only underlines a range has nothing to say on a row of +// its own. // // Location information reads words first, leading to its own location, as it // does in the frame. Reading it the other way around would make the words say // the wrong thing. -static auto DrawMessageRow(Buffer& buffer, int y, const PreparedPart& part) +static auto DrawCompactRow(Buffer& buffer, int y, const PreparedPart& part) -> bool { // With no frame for a label to hang off, its words serve as the part's own. const std::string& words = part.text.empty() ? part.label : part.text; if (part.role == Part::LocationInfo) { - Buffer::DrawEnd end = - buffer.DrawText(0, y, ContextText(part), ContextStyle()); + Buffer::DrawEnd end = buffer.DrawText(0, y, PathText(part), PathStyle()); buffer.DrawText(end.x, end.y, part.kind_suffix, KindStyle()); return true; } @@ -2049,7 +2379,7 @@ auto Renderer::RenderCompact(Terminal::OutputBufferRef out, Buffer buffer(capabilities_); int y = 0; for (const PreparedPart& part : parts) { - if (DrawMessageRow(buffer, y, part)) { + if (DrawCompactRow(buffer, y, part)) { ++y; } } @@ -2101,7 +2431,7 @@ auto PrintSnippet(llvm::raw_ostream& out, const Loc& loc, int indent) -> void { buffer.DrawVerticalLine(frame_x, /*y=*/0, /*length=*/2, FrameStyle()); buffer.DrawText(frame_x - 1 - number.size(), 0, number, FrameStyle()); buffer.DrawText(content_x, 0, source.text, Style()); - buffer.DrawCodePoint(frame_x, 1, glyphs.annotation, FrameStyle()); + buffer.DrawCodePoint(frame_x, 1, glyphs.dotted_frame, FrameStyle()); buffer.DrawHorizontalLine(content_x + source.span_start, 1, source.span_length, Style(), LineEnd::Edge, LineEnd::Edge); diff --git a/toolchain/diagnostics/renderer.h b/toolchain/diagnostics/renderer.h index b2a4620aacda..ec9e99ef5e67 100644 --- a/toolchain/diagnostics/renderer.h +++ b/toolchain/diagnostics/renderer.h @@ -5,7 +5,6 @@ #ifndef CARBON_TOOLCHAIN_DIAGNOSTICS_RENDERER_H_ #define CARBON_TOOLCHAIN_DIAGNOSTICS_RENDERER_H_ -#include #include #include "common/ostream.h" @@ -22,26 +21,25 @@ struct PreparedPart; // Draws diagnostics for a terminal. // -// A diagnostic renders as its headline, and then a frame holding everything -// that explains it: which file, the source there, and the text of each label -// against the code it marks. +// A diagnostic renders as one frame holding a snippet of each file it points +// into. The message's text is placed under the range that is wrong, which has a +// heavy underline, and begins with the level word. Every label is placed under +// the range it is attached to. // -// error: 1 argument passed to function expecting 0 arguments // ╭─┤ foo.carbon:19:3 -// │ // 1 │ fn Run0() {} // · ──────┬───── // · ╰──┤ calling function declared here // ┆ // -> 19 │ Run0(1); -// · ───┬─── -// · ╰──┤ 1 argument passed here -// ╰──────────── +// · ━━━┳━━━ +// · ┗━━┫ error: invalid arguments in function call +// ╰──── // // With snippets off, each part of the diagnostic is one line, led by its // location and the extent of its range: // -// foo.carbon:19:3-9: error: 1 argument passed to function expecting 0 +// foo.carbon:19:3-9: error: invalid arguments in function call // foo.carbon:1:1-12: note: calling function declared here // // See /toolchain/docs/diagnostics_rendering.md for the full form, the palette, @@ -91,7 +89,7 @@ class Renderer { // Renders the framed form into the geometry `Render` chose. auto RenderFramed(Terminal::OutputBufferRef out, llvm::MutableArrayRef parts, - int headline, Level level, int frame_x, int content_x, + int leading, Level level, int frame_x, int content_x, int source_columns, int columns) const -> void; Terminal::Capabilities capabilities_; diff --git a/toolchain/diagnostics/renderer_test.cpp b/toolchain/diagnostics/renderer_test.cpp index 36cd10c86234..e765fe249de8 100644 --- a/toolchain/diagnostics/renderer_test.cpp +++ b/toolchain/diagnostics/renderer_test.cpp @@ -49,8 +49,8 @@ static auto MakeMessage(Loc loc, llvm::StringRef text, .format_fn = Says(text)}; } -// Builds a label marking `loc` and saying `text`, reached by `origin`. An empty -// `text` marks the range and says nothing. +// Builds a label attached to `loc` and saying `text`, reached by `origin`. An +// empty `text` underlines the range and says nothing. static auto MakeLabel(LabelCategory category, Loc loc, llvm::StringRef text, llvm::SmallVector origin = {}) -> Label { return {.category = category, @@ -141,23 +141,22 @@ static auto At(int line_number, int column, int length) -> Loc { } TEST(RendererTest, ErrorWithSnippet) { - // The row below the anchor is an elision, because the file goes on above the - // line the snippet starts at. + // The common case: the location row starts the frame, the message's text is + // placed under its own range after the level word, and the close ends it. EXPECT_THAT(RenderOne(Plain(), Level::Error, At(4, 3, 7), "bad call"), - Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" + Eq(" .-| foo.carbon:4:3\n" "-> 4 | Run0(1);\n" - " : -------\n" - " '------------\n" + " : ^^^^^^^\n" + " : '--| error: bad call\n" + " '----\n" "")); } TEST(RendererTest, ASpanStartingWhereTheLineEndsIsStillDrawn) { // A location can name the column after the last character on a line: a // fix-it inserting there, or a token synthesized past the end of the line by - // error recovery. The mark reaches one column further than the source rather - // than the renderer refusing to draw it. + // error recovery. The underline reaches one column further than the source + // rather than the renderer refusing to draw it. Loc loc = {.filename = "foo.carbon", .line = "var x: i32", .file_text = "var x: i32", @@ -169,25 +168,21 @@ TEST(RendererTest, ASpanStartingWhereTheLineEndsIsStillDrawn) { // to walk back through. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; EXPECT_THAT(RenderOne(capabilities, Level::Error, loc, "missing `;`"), - Eq("error: missing `;`\n" - " ╭─┤ foo.carbon:1:11\n" - " │\n" + Eq(" ╭─┤ foo.carbon:1:11\n" "-> 1 │ var x: i32\n" - " · ─\n" - " ╰────────────\n" + " · ┳\n" + " · ┗━━┫ error: missing `;`\n" + " ╰────\n" "")); } TEST(RendererTest, WarningLevelWord) { - // The snippet starts at the top of the file, so nothing was skipped and the - // row below the anchor is just the frame. EXPECT_THAT(RenderOne(Plain(), Level::Warning, At(1, 4, 4), "unused"), - Eq("warning: unused\n" - " .-| foo.carbon:1:4\n" - " |\n" + Eq(" .-| foo.carbon:1:4\n" "-> 1 | fn Run0() {}\n" - " : ----\n" - " '------------\n" + " : ^^^^\n" + " : '--| warning: unused\n" + " '----\n" "")); } @@ -198,16 +193,15 @@ TEST(RendererTest, FrameMovesRightForLongLineNumbers) { .column_number = 1, .length = 3}; EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "bad"), - Eq("error: bad\n" - " .-| foo.carbon:123456:1\n" - " :\n" + Eq(" .-| foo.carbon:123456:1\n" "->123456 | var x: i32;\n" - " : ---\n" - " '------------\n" + " : ^^^\n" + " : '--| error: bad\n" + " '----\n" "")); } -TEST(RendererTest, NoLocationIsJustTheHeadline) { +TEST(RendererTest, NoLocationIsOneCompactRow) { EXPECT_THAT(RenderOne(Plain(), Level::Error, {}, "no file here"), Eq("error: no file here\n")); } @@ -229,12 +223,11 @@ TEST(RendererTest, TabsExpandToStops) { .length = 1}; // The tabs reach columns 8 and 16, so `x` lands in column 17. EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "bad"), - Eq("error: bad\n" - " .-| foo.carbon:1:6\n" - " |\n" + Eq(" .-| foo.carbon:1:6\n" "-> 1 | var x;\n" - " : -\n" - " '------------\n" + " : ^\n" + " : '--| error: bad\n" + " '----\n" "")); } @@ -245,12 +238,11 @@ TEST(RendererTest, UnprintableBytesAreEscaped) { .column_number = 4, .length = 1}; EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "bad"), - Eq("error: bad\n" - " .-| foo.carbon:1:4\n" - " |\n" + Eq(" .-| foo.carbon:1:4\n" "-> 1 | a<01>=b\n" - " : -\n" - " '------------\n" + " : ^\n" + " : '--| error: bad\n" + " '----\n" "")); } @@ -261,12 +253,11 @@ TEST(RendererTest, NonAsciiIsEscapedUnderAscii) { .column_number = 1, .length = 1}; EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "bad"), - Eq("error: bad\n" - " .-| foo.carbon:1:1\n" - " |\n" + Eq(" .-| foo.carbon:1:1\n" "-> 1 | x = ;\n" - " : -\n" - " '------------\n" + " : ^\n" + " : '--| error: bad\n" + " '----\n" "")); } @@ -279,12 +270,11 @@ TEST(RendererTest, WideCharactersTakeTwoColumnsUnderUtf8) { .column_number = 16, .length = 6}; EXPECT_THAT(RenderOne(capabilities, Level::Error, loc, "not found"), - Eq("error: not found\n" - " ╭─┤ foo.carbon:3:16\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:3:16\n" "-> 3 │ var x: i32 = 世界;\n" - " · ────\n" - " ╰────────────\n" + " · ━━┳━\n" + " · ┗━━┫ error: not found\n" + " ╰────\n" "")); } @@ -295,12 +285,11 @@ TEST(RendererTest, SpanPastEndOfLineIsClamped) { .column_number = 40, .length = 10}; EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "at end"), - Eq("error: at end\n" - " .-| foo.carbon:1:40\n" - " |\n" + Eq(" .-| foo.carbon:1:40\n" "-> 1 | var\n" - " : -\n" - " '------------\n" + " : ^\n" + " : '--| error: at end\n" + " '----\n" "")); } @@ -311,19 +300,17 @@ TEST(RendererTest, MergedShowsOneViewOfTheFile) { .labels = { MakeLabel(LabelCategory::Info, At(1, 1, 12), "declared here")}}; // The note is above the error in the file, so it is drawn first, and the two - // lines between them are elided. The row below the anchor is not an elision, - // because the snippet starts at the top of the file. + // lines between them are elided. EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: too many arguments\n" - " .-| foo.carbon:4:3\n" - " |\n" + Eq(" .-| foo.carbon:4:3\n" " 1 | fn Run0() {}\n" " : ------.-----\n" " : '--| declared here\n" " :\n" "-> 4 | Run0(1);\n" - " : -------\n" - " '------------\n" + " : ^^^^^^^\n" + " : '--| error: too many arguments\n" + " '----\n" "")); } @@ -333,20 +320,19 @@ TEST(RendererTest, MergedShowsASingleSkippedLine) { .message = MakeMessage(At(3, 1, 2), "bad"), .labels = {MakeLabel(LabelCategory::Info, At(1, 1, 2), "here")}}; // Only line 2 is between them, so it is shown rather than elided. - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad\n" - " .-| foo.carbon:3:1\n" - " |\n" + EXPECT_THAT(Render(Plain(), diagnostic), Eq(" .-| foo.carbon:3:1\n" " 1 | fn Run0() {}\n" " : -.\n" " : '--| here\n" " 2 |\n" "-> 3 | fn Main() {\n" - " : --\n" - " '------------\n" + " : ^^\n" + " : '--| error: bad\n" + " '----\n" "")); } -TEST(RendererTest, NotesInAnotherFileGetTheirOwnAnchor) { +TEST(RendererTest, NotesInAnotherFileGetTheirOwnLocationRow) { Loc other = {.filename = "bar.carbon", .line = "class C {", .line_number = 9, @@ -357,48 +343,44 @@ TEST(RendererTest, NotesInAnotherFileGetTheirOwnAnchor) { .message = MakeMessage(At(4, 3, 7), "bad"), .labels = {MakeLabel(LabelCategory::Info, other, "declared here")}}; EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: bad\n" - " .-| foo.carbon:4:3\n" - " :\n" + Eq(" .-| foo.carbon:4:3\n" "-> 4 | Run0(1);\n" - " : -------\n" - " |------------\n" - " |-| bar.carbon:9:1\n" + " : ^^^^^^^\n" + " : '--| error: bad\n" " :\n" + " |-| bar.carbon:9:1\n" " 9 | class C {\n" " : ----.----\n" " : '--| declared here\n" - " '------------\n" + " '----\n" "")); } TEST(RendererTest, APrimaryLabelTeesIntoItsRange) { - // The connector leaves the middle of the underline through a junction, so the - // mark and what it says are one stroke and the words point into the range - // rather than off an end of it. + // The label line leaves the middle of the underline through a junction, so + // the underline and what it says are one line and the words point into the + // range rather than off an end of it. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 7), "1 argument passed to function expecting 0"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), "1 argument passed here")}}; - EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: 1 argument passed to function expecting 0\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : ---.---\n" - " : '--| 1 argument passed here\n" - " '------------\n" - "")); + EXPECT_THAT( + Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^^^^\n" + " : '--| error: 1 argument passed to function expecting 0\n" + " : '----| 1 argument passed here\n" + " '----\n" + "")); } TEST(RendererTest, TheShapeTheDesignDocDraws) { // The anatomy illustration in /toolchain/docs/diagnostics_rendering.md, so // that the picture there is output this produced rather than one drawn by // hand and left behind by the next change. - // The declaration is in an imported file, so the picture carries the path - // above an anchor as well as the rows a single file needs. static constexpr llvm::StringLiteral LibFile = "fn Run0() {}\n"; Loc declaration = {.filename = "lib.carbon", .line = "fn Run0() {}", @@ -406,40 +388,47 @@ TEST(RendererTest, TheShapeTheDesignDocDraws) { .line_number = 1, .column_number = 1, .length = 12}; - Loc import = {.filename = "foo.carbon", .line_number = 2, .column_number = 1}; Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage( At(4, 3, 7), "1 argument passed to function expecting 0 arguments"), - .labels = { - MakeLabel(LabelCategory::Info, declaration, - "calling function declared here, expecting 0 arguments", - {MakeOrigin(import, "imported from")}), - MakeLabel(LabelCategory::Primary, At(4, 3, 7), - "1 argument passed here")}}; + .labels = {MakeLabel(LabelCategory::Info, declaration, + "calling function declared here")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: 1 argument passed to function expecting 0 arguments\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───┬───\n" - " · ╰──┤ 1 argument passed here\n" - " ├────────────\n" - " │ ╭── imported from: foo.carbon:2:1\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: 1 argument passed to function " + "expecting 0 arguments\n" + " ┆\n" " ├─┤ lib.carbon:1:1\n" - " │\n" " 1 │ fn Run0() {}\n" " · ──────┬─────\n" - " · ╰──┤ calling function declared here, " + " · ╰──┤ calling function declared here\n" + " ╰────\n" + "")); + + // The same diagnostic on a terminal with neither color nor Unicode, which is + // the document's degradation example. + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^^^^\n" + " : '--| error: 1 argument passed to function " "expecting 0 arguments\n" - " ╰────────────\n" + " :\n" + " |-| lib.carbon:1:1\n" + " 1 | fn Run0() {}\n" + " : ------.-----\n" + " : '--| calling function declared here\n" + " '----\n" "")); } -TEST(RendererTest, TheMessageRowTheDesignDocDraws) { - // The message row illustration in /toolchain/docs/diagnostics_rendering.md, - // for the one row an ordinary diagnostic doesn't reach. +TEST(RendererTest, AFileOnlyLabelIsPlacedUnderItsLocationRow) { + // A label whose location names only a file has its text placed under a + // location row of its own, which an ordinary diagnostic doesn't need. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, @@ -447,148 +436,173 @@ TEST(RendererTest, TheMessageRowTheDesignDocDraws) { .labels = {MakeLabel(LabelCategory::Info, FileOnly(), "type `A` does not implement interface " "`Core.Copy`")}}; - EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: cannot copy argument of type `A`\n" - " ╭─┤ foo.carbon:4:8\n" - " ┆\n" - "-> 4 │ Run0(1);\n" - " · ─\n" - " ├────────────\n" - " ├─ note: type `A` does not implement interface " - "`Core.Copy`\n" - " ╰────────────\n" - "")); + EXPECT_THAT( + Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:8\n" + "-> 4 │ Run0(1);\n" + " · ┳\n" + " · ┗━━┫ error: cannot copy argument of type `A`\n" + " ┆\n" + " ├─┤ foo.carbon\n" + " · ╰──┤ type `A` does not implement interface `Core.Copy`\n" + " ╰────\n" + "")); } TEST(RendererTest, ARangeContainingTheMessageLocHostsIt) { // A range containing the message's location is drawn over the code that - // location names, so it stands in for it and the location marks nothing of + // location names, so it stands in for it and the location has no underline of // its own. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 1), "bad call"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), "")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : -------\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^^^^\n" + " : '--| error: bad call\n" + " '----\n" + "")); } -TEST(RendererTest, AMessageLocOutsideEveryRangeMarksNothing) { - // A range on the line the message's location names stands in for it whether - // or not it contains it, so the location itself is not drawn and the line - // carries only the range's own mark. +TEST(RendererTest, ARangeElsewhereOnTheLineDoesNotHostTheMessage) { + // Only a range containing the message's location takes its place. A range + // elsewhere on the same line is not about the code the location names, so + // the message keeps its own underline and text. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 1), "bad call"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 8, 3), "")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : ---\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^ ---\n" + " : '--| error: bad call\n" + " '----\n" + "")); } -TEST(RendererTest, RepeatedSpansAreOneMark) { - // Two labels marking the same range draw the same underline in the same - // columns, so they are one mark rather than two identical rows. A message - // that a context leads and the range attached to it reach this shape. +TEST(RendererTest, RepeatedSpansAreOneUnderline) { + // Two labels attached to the same range draw the same underline in the same + // columns, so they are one underline rather than two identical rows. A + // message that a context leads and the range attached to it reach this shape. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 1), "bad call"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), ""), MakeLabel(LabelCategory::Primary, At(4, 3, 7), "wrong")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : ---.---\n" - " : '--| wrong\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^^^^\n" + " : '--| error: bad call\n" + " : '----| wrong\n" + " '----\n" + "")); } TEST(RendererTest, ARangeCoveringOthersIsRepairedRatherThanStacked) { - // A range attached over the whole expression, with the operands inside it - // marked separately, is the shape overlap actually arrives in. Nothing is in - // a position to reject it, so it is drawn as one row with the operands - // showing through the range that covers them. + // A range attached over the whole expression, with ranges attached to the + // operands inside it, is the shape overlap actually arrives in. Nothing is in + // a position to reject it, so it is drawn as one row: the covering range is + // the heavy underline and stays whole, and each operand shows as the tee + // where its label line leaves that underline -- which ASCII keeps as the + // corner inside the `^` run, since the `^` would hide where the label line + // left. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 1), "bad call"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), ""), MakeLabel(LabelCategory::Info, At(4, 3, 4), "callee"), MakeLabel(LabelCategory::Info, At(4, 8, 1), "argument")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : --.--.-\n" - " : | '--| argument\n" - " : '--| callee\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^.^^.^\n" + " : |'----| error: bad call\n" + " : '-------| callee\n" + " : '------| argument\n" + " '----\n" + "")); } TEST(RendererTest, ALabelOnASingleColumnRangeDropsStraightDown) { - // With one column marked there is no underline to turn out of, and reaching - // in from the side would read as attaching to the column beside it. The - // connector starts on the row below instead and takes the gap, which says - // the column above is a point and not a range. + // With one column underlined there is no underline to turn out of, and + // reaching in from the side would read as attaching to the column beside it. + // The label line drops straight down the underline's own column, teeing into + // it. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 8, 1), "bad index"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 4), "indexed here"), MakeLabel(LabelCategory::Primary, At(4, 8, 1), "with this")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad index\n" - " .-| foo.carbon:4:8\n" - " :\n" - "-> 4 | Run0(1);\n" - " : --.- .\n" - " : | '--| with this\n" - " : '--| indexed here\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:8\n" + "-> 4 | Run0(1);\n" + " : --.- ^\n" + " : | '--| error: bad index\n" + " : '-------| indexed here\n" + " : '------| with this\n" + " '----\n" + "")); } TEST(RendererTest, OverlappingSpansStillShareOneRow) { - // Ranges covering some of the same columns are still one row of marks. The - // narrower one is drawn over the wider, since a range containing another says - // less about the columns they share than the range inside it does. + // Ranges covering some of the same columns are still one underline row. The + // wider one here is the heavy underline, drawn last, so a range inside it + // with no text of its own shows nothing. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 1), "bad call"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), ""), MakeLabel(LabelCategory::Info, At(4, 7, 3), "")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : -------\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^^^^\n" + " : '--| error: bad call\n" + " '----\n" + "")); } -// The glyphs a row of marks must never hold. A corner reads as a mark turning -// into the connector leaving it, a crossing as two marks meeting, and an upward -// tee as a mark joining the source above it. None of those is ever what -// happened, whatever the ranges on the row are. -static constexpr std::array ForbiddenInMarks = { +TEST(RendererTest, ARangeInsideTheHeavyUnderlineShowsAsItsTee) { + // The heavy underline is drawn last, so a narrower range inside it leaves it + // whole, with no stretch of it light or in a ramp color, and the range shows + // as the tee where its label line leaves the heavy underline. Over any other + // underline, the narrower range is drawn on top. + Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(At(4, 3, 7), "bad call"), + .labels = {MakeLabel(LabelCategory::Info, At(4, 3, 4), "callee"), + MakeLabel(LabelCategory::Info, At(4, 8, 1), "argument")}}; + EXPECT_THAT(Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:3\n" + "-> 4 │ Run0(1);\n" + " · ━━┯┳━┯━\n" + " · │┗━━━━┫ error: bad call\n" + " · ╰───────┤ callee\n" + " · ╰──────┤ argument\n" + " ╰────\n" + "")); +} + +// The glyphs an underline row must never hold. A corner reads as an underline +// turning into the label line leaving it, a crossing as two underlines meeting, +// and an upward tee as an underline joining the source above it. None of those +// is ever what happened, whatever the ranges on the row are. +static constexpr std::array ForbiddenInUnderlines = { "╭", "╮", "╯", "╰", "┼", "┴"}; // The ASCII stand-ins for the same shapes: `'` is a corner arriving from // above and `+` a crossing. `.`, the corner leaving downward, is left out // because it is also how a point with no room for anything else degrades. -static constexpr std::array ForbiddenInAsciiMarks = { - "'", "+"}; +static constexpr std::array ForbiddenInAsciiUnderlines = + {"'", "+"}; -// Returns the row of marks under the source, which is the row after it. -static auto MarkRow(llvm::StringRef rendered) -> std::string { +// Returns the underline row under the source, which is the row after it. +static auto UnderlineRow(llvm::StringRef rendered) -> std::string { llvm::SmallVector rows; rendered.split(rows, '\n'); for (auto [index, row] : llvm::enumerate(rows)) { @@ -599,10 +613,11 @@ static auto MarkRow(llvm::StringRef rendered) -> std::string { return ""; } -TEST(RendererTest, MarksNeverHoldACornerOrACrossing) { - // Adjacency moves the ends of marks and the columns connectors leave them - // from, which is where a shape nothing drew could come from. This sweeps what - // ranges on one row can be rather than naming the combinations one at a time. +TEST(RendererTest, UnderlinesNeverHoldACornerOrACrossing) { + // Adjacency moves the ends of underlines and the columns label lines leave + // them from, which is where a shape nothing drew could come from. This sweeps + // what ranges on one row can be rather than naming the combinations one at a + // time. static constexpr llvm::StringLiteral Line = " abcdefghijklmnopqrstuvwxyz"; auto at = [&](int column, int length) { return Loc{.filename = "f.carbon", @@ -624,7 +639,8 @@ TEST(RendererTest, MarksNeverHoldACornerOrACrossing) { labels.push_back(MakeLabel(category, at(range.start, range.length), range.has_words ? "words" : "")); } - // The message points past every range, so each mark comes from a label. + // The message points past every range, so each underline comes from a + // label. Diagnostic diagnostic = {.level = Level::Error, .message = MakeMessage(at(26, 1), "m"), .labels = std::move(labels)}; @@ -635,16 +651,18 @@ TEST(RendererTest, MarksNeverHoldACornerOrACrossing) { }; auto check = [&](Terminal::Charset charset, llvm::StringRef what, llvm::StringRef rendered) { - std::string marks = MarkRow(rendered); - // An empty marks row means the source row went missing, which would let + std::string underlines = UnderlineRow(rendered); + // An empty underline row means the source row went missing, which would let // every check below pass over nothing. - EXPECT_THAT(marks, Not(testing::IsEmpty())) << what << "\n" << rendered; + EXPECT_THAT(underlines, Not(testing::IsEmpty())) << what << "\n" + << rendered; auto forbidden_glyphs = charset == Terminal::Charset::Utf8 - ? llvm::ArrayRef(ForbiddenInMarks) - : llvm::ArrayRef(ForbiddenInAsciiMarks); + ? llvm::ArrayRef(ForbiddenInUnderlines) + : llvm::ArrayRef(ForbiddenInAsciiUnderlines); for (llvm::StringLiteral forbidden : forbidden_glyphs) { - EXPECT_THAT(marks, Not(HasSubstr(forbidden))) << what << "\n" << rendered; + EXPECT_THAT(underlines, Not(HasSubstr(forbidden))) << what << "\n" + << rendered; } }; @@ -707,42 +725,61 @@ TEST(RendererTest, AdjacentRangesAreDrawnApart) { .message = MakeMessage(At(4, 3, 4), "bad call"), .labels = {MakeLabel(LabelCategory::Info, At(4, 7, 3), "with these")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad call\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───╴╶┬─\n" - " · ╰──┤ with these\n" - " ╰────────────\n" + " · ━━┳╸╶┬─\n" + " · ┗━━━━━┫ error: bad call\n" + " · ╰────┤ with these\n" + " ╰────\n" "")); } -TEST(RendererTest, AConnectorWithNothingToTeeIntoTakesTheMarksColumn) { - // A single column with a range beside it has nowhere a connector could leave - // the mark without the mark reaching the range next to it. The connector - // takes the column instead of teeing into it, leaving from the center of the - // cell: the column is marked, and nothing is claimed of the row above it. +TEST(RendererTest, ALabelLineWithNothingToTeeIntoTakesTheUnderlinesColumn) { + // A single column with a range beside it has nowhere a label line could leave + // the underline without the underline reaching the range next to it. The + // label line takes the column instead of teeing into it, leaving from the + // center of the cell: the column is underlined, and nothing is claimed of the + // row above it. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 4), "bad call"), .labels = {MakeLabel(LabelCategory::Info, At(4, 7, 1), "this one")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad call\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───╴╷\n" - " · ╰──┤ this one\n" - " ╰────────────\n" + " · ━━┳╸╷\n" + " · ┗━━━━┫ error: bad call\n" + " · ╰────┤ this one\n" + " ╰────\n" "")); } -TEST(RendererTest, AdjacentConnectorsAreTwoMarksRatherThanOne) { - // Two single columns side by side each have their connector for a mark, and - // a connector leaving from the center of its cell is what keeps the pair - // reading as two marks: running them the height of their cells would draw - // one unbroken stroke two columns wide. +TEST(RendererTest, ALabelLineInPlaceOfAnUnderlineKeepsTheCaretUnderAscii) { + // Where the message's underline is one column with an end pulled in to clear + // the range beside it, there is no junction, so the label line is drawn down + // that column in place of the underline. Its top cell is still part of the + // heavy underline, so under ASCII it is `^`, not the `|` of a light label + // line, and the rest of the label line is light like any label's. + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(At(4, 7, 1), "bad call"), + .labels = {MakeLabel(LabelCategory::Info, At(4, 8, 2), "operand")}}; + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:7\n" + "-> 4 | Run0(1);\n" + " : ^-.\n" + " : '----| error: bad call\n" + " : '----| operand\n" + " '----\n" + "")); +} + +TEST(RendererTest, AdjacentLabelLinesAreTwoUnderlinesRatherThanOne) { + // Two single columns side by side each have their label line in place of an + // underline, and a label line leaving from the center of its cell is what + // keeps the pair reading as two underlines: running them the height of their + // cells would draw one unbroken line two columns wide. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, @@ -750,54 +787,53 @@ TEST(RendererTest, AdjacentConnectorsAreTwoMarksRatherThanOne) { .labels = {MakeLabel(LabelCategory::Info, At(4, 7, 1), "left one"), MakeLabel(LabelCategory::Info, At(4, 8, 1), "right one")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad call\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───╴╷╷\n" - " · │╰──┤ right one\n" - " · ╰──┤ left one\n" - " ╰────────────\n" + " · ━━┳╸╷╷\n" + " · ┗━━━━━┫ error: bad call\n" + " · ╰─────┤ left one\n" + " · ╰──────┤ right one\n" + " ╰────\n" "")); - // ASCII draws no half cell, so a stroke stopping at one is `|` there like - // any other: the pair reads as two marks only where the character set can + // ASCII draws no half cell, so a line stopping at one is `|` there like any + // other: the pair reads as two underlines only where the character set can // draw the halves. - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : ----||\n" - " : |'--| right one\n" - " : '--| left one\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^||\n" + " : '-----| error: bad call\n" + " : '-----| left one\n" + " : '------| right one\n" + " '----\n" + "")); } -TEST(RendererTest, AConnectorStepsAwayFromAnAdjacentRangeToTee) { - // Two columns leave the connector one to tee into once the end beside the +TEST(RendererTest, ALabelLineStepsAwayFromAnAdjacentRangeToTee) { + // Two columns leave the label line one to tee into once the end beside the // next range is pulled in, so it steps inward rather than turning a corner - // where the mark stops. The label follows it. + // where the underline stops. The label follows it. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 5, 2), "bad call"), .labels = {MakeLabel(LabelCategory::Info, At(4, 3, 2), "and this")}}; - EXPECT_THAT(Render(capabilities, diagnostic), Eq("error: bad call\n" - " ╭─┤ foo.carbon:4:5\n" - " ┆\n" - "-> 4 │ Run0(1);\n" - " · ┬╴╶─\n" - " · ╰──┤ and this\n" - " ╰────────────\n" - "")); + EXPECT_THAT(Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:5\n" + "-> 4 │ Run0(1);\n" + " · ┬╴╺┳\n" + " · │ ┗━━┫ error: bad call\n" + " · ╰───────┤ and this\n" + " ╰────\n" + "")); } -TEST(RendererTest, AGapGivesWayToAMarkThatCannotSpareIt) { +TEST(RendererTest, AGapGivesWayToAnUnderlineThatCannotSpareIt) { // The gap is worth having but not worth paying for. Two columns with a range - // on either side can give up one end but not both, since the connector needs - // a column the mark still runs out through on both sides. The end beside the - // range that begins after it keeps its column, and that range gives way + // on either side can give up one end but not both, since the label line needs + // a column the underline still runs out through on both sides. The end beside + // the range that begins after it keeps its column, and that range gives way // instead, so the boundary still shows a gap. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { @@ -807,20 +843,19 @@ TEST(RendererTest, AGapGivesWayToAMarkThatCannotSpareIt) { MakeLabel(LabelCategory::Info, At(4, 5, 2), "middle"), MakeLabel(LabelCategory::Info, At(4, 7, 2), "")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad call\n" - " ╭─┤ foo.carbon:4:10\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:10\n" "-> 4 │ Run0(1);\n" - " · ─╴╶┬╶─ ─\n" - " · ╰──┤ middle\n" - " ╰────────────\n" + " · ─╴╶┬╶─ ┳\n" + " · │ ┗━━┫ error: bad call\n" + " · ╰────────┤ middle\n" + " ╰────\n" "")); } TEST(RendererTest, ARangeWithNeighborsOnBothSidesAndNoLabelIsAPoint) { // A single column between two ranges has both its ends pulled in, and with no - // words to hang there is no connector to draw down it either. The mark is a - // point: nothing that fits one column shows a gap on each side of it. + // words to hang there is no label line to draw down it either. The underline + // is a point: nothing that fits one column shows a gap on each side of it. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, @@ -828,45 +863,43 @@ TEST(RendererTest, ARangeWithNeighborsOnBothSidesAndNoLabelIsAPoint) { .labels = {MakeLabel(LabelCategory::Info, At(4, 7, 1), ""), MakeLabel(LabelCategory::Info, At(4, 8, 1), "this one")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad call\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───╴·╷\n" - " · ╰──┤ this one\n" - " ╰────────────\n" + " · ━━┳╸·╷\n" + " · ┗━━━━━┫ error: bad call\n" + " · ╰────┤ this one\n" + " ╰────\n" "")); } TEST(RendererTest, AsciiDrawsAdjacentRangesWithoutTheGap) { // Half a cell is not something the ASCII stand-ins can draw, so the gap is - // one of the distinctions that character set costs. The marks still run the - // width of their ranges. + // one of the distinctions that character set costs. The underlines still run + // the width of their ranges. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 4), "bad call"), .labels = {MakeLabel(LabelCategory::Info, At(4, 7, 3), "with these")}}; EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" + Eq(" .-| foo.carbon:4:3\n" "-> 4 | Run0(1);\n" - " : -----.-\n" - " : '--| with these\n" - " '------------\n" + " : ^^^^-.-\n" + " : '-----| error: bad call\n" + " : '----| with these\n" + " '----\n" "")); } TEST(RendererTest, AnInformationalRangeDoesNotHostTheMessage) { // Only a range that is part of the problem stands in for the message's - // location. A note covering the same code is a different mark, in the note's - // own color, and the message still marks where it points. + // location. A note covering the same code is a different underline, in the + // note's own color, and the message's own location is still underlined. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 1), "bad call"), .labels = {MakeLabel(LabelCategory::Info, At(4, 3, 7), "")}}; - // Rendered in color, since with none the two marks are the same characters - // and the whole distinction is which color each is drawn in. + // Rendered in color, since with none the two underlines are the same + // characters and the whole distinction is which color each is drawn in. Terminal::Capabilities capabilities = {.color_mode = Terminal::ColorMode::Ansi16}; std::string rendered = Render(capabilities, diagnostic); @@ -881,21 +914,22 @@ TEST(RendererTest, TwoSpansOnOneLineShareItsRow) { .level = Level::Error, .message = MakeMessage(At(1, 4, 4), "bad"), .labels = {MakeLabel(LabelCategory::Info, At(1, 1, 2), "here")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad\n" - " .-| foo.carbon:1:4\n" - " |\n" + EXPECT_THAT(Render(Plain(), diagnostic), Eq(" .-| foo.carbon:1:4\n" "-> 1 | fn Run0() {}\n" - " : -. ----\n" - " : '--| here\n" - " '------------\n" + " : -. ^^^^\n" + " : | '--| error: bad\n" + " : '--------| here\n" + " '----\n" "")); } -TEST(RendererTest, LabelsOnOneLineHangRightToLeft) { - // Every label on the line turns out of the end of its own range, and they are - // drawn rightmost first so that each connector reaches across the ones - // already hanging rather than descending through them. Their words then run - // left to right in the order the operands do, which is how they are read. +TEST(RendererTest, LabelsOnOneLineReadInSourceOrder) { + // The rows read top to bottom in the order the code reads left to right: + // the message first, then each label in the order of its range. Each + // label's text starts two columns right of the text above it and right of + // every label line's column, so a label line descending to a later label runs + // beside the text above it and breaks only for single cells of the runs it + // crosses. static constexpr llvm::StringLiteral Line = " return count * flag;"; auto at = [&](int column, int length) { return Loc{.filename = "foo.carbon", @@ -913,14 +947,14 @@ TEST(RendererTest, LabelsOnOneLineHangRightToLeft) { "right operand has type `bool`")}}; EXPECT_THAT( Render(Plain(), diagnostic), - Eq("error: `i32` does not implement `MulWith`\n" - " .-| foo.carbon:3:16\n" - " :\n" + Eq(" .-| foo.carbon:3:16\n" "-> 3 | return count * flag;\n" - " : --.-- --.-\n" - " : | '--| right operand has type `bool`\n" - " : '--| left operand has type `i32`\n" - " '------------\n" + " : --.-- ^ --.-\n" + " : | '------| error: `i32` does not implement " + "`MulWith`\n" + " : '------------| left operand has type `i32`\n" + " : '------| right operand has type `bool`\n" + " '----\n" "")); } @@ -944,19 +978,18 @@ TEST(RendererTest, SpansOnOneLineShareOneWindow) { .labels = {MakeLabel(LabelCategory::Info, at(41, 6), "and here")}}; EXPECT_THAT( Render(capabilities, diagnostic), - Eq("error: bad\n" - " .-| foo.carbon:1:21\n" - " |\n" + Eq(" .-| foo.carbon:1:21\n" "-> 1 | " "...xxxxxxxxxxxxxxxxFIRSTxxxxxxxxxxxxxxxSECONDxxxxxxxxxxxxxxxxxxxxxxx." "..\n" - " : ----- ---.--\n" - " : '--| and here\n" - " '------------\n" + " : ^^^^^ ---.--\n" + " : '-----------------------| error: bad\n" + " : '----| and here\n" + " '----\n" "")); } -TEST(RendererTest, MultipleFilesEachGetAnAnchor) { +TEST(RendererTest, MultipleFilesEachGetALocationRow) { Loc first = {.filename = "b.carbon", .line = "fn Shape() {}", .line_number = 3, @@ -972,22 +1005,20 @@ TEST(RendererTest, MultipleFilesEachGetAnAnchor) { .labels = {MakeLabel(LabelCategory::Info, second, "previously declared")}}; EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: duplicate name\n" - " .-| b.carbon:3:1\n" - " :\n" + Eq(" .-| b.carbon:3:1\n" "-> 3 | fn Shape() {}\n" - " : -------------\n" - " |------------\n" - " |-| a.carbon:3:1\n" + " : ^^^^^^^^^^^^^\n" + " : '--| error: duplicate name\n" " :\n" + " |-| a.carbon:3:1\n" " 3 | class Shape {}\n" " : -------.------\n" " : '--| previously declared\n" - " '------------\n" + " '----\n" "")); } -TEST(RendererTest, ContextLeadsIntoTheAnchorItReached) { +TEST(RendererTest, ALabelsPathIsNotDrawn) { Loc import_loc = {.filename = "c.carbon", .line = "import library \"a\";", .line_number = 1, @@ -1003,22 +1034,52 @@ TEST(RendererTest, ContextLeadsIntoTheAnchorItReached) { .message = MakeMessage(At(4, 3, 7), "duplicate name"), .labels = {MakeLabel(LabelCategory::Info, other, "previously declared", {MakeOrigin(import_loc, "in import")})}}; - // The rule closes off the first snippet, and the context runs into the - // anchor of the location it led to rather than getting an anchor of its own. + // A label's path is not drawn, so its location row has no path rows above it. EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: duplicate name\n" - " .-| foo.carbon:4:3\n" - " :\n" + Eq(" .-| foo.carbon:4:3\n" "-> 4 | Run0(1);\n" - " : -------\n" - " |------------\n" - " | .-- in import: c.carbon:1:1\n" - " |-| a.carbon:3:1\n" + " : ^^^^^^^\n" + " : '--| error: duplicate name\n" " :\n" + " |-| a.carbon:3:1\n" " 3 | class Shape {}\n" " : -------.------\n" " : '--| previously declared\n" - " '------------\n" + " '----\n" + "")); +} + +TEST(RendererTest, APathLeadsIntoTheLocationRowItReaches) { + Loc import_loc = {.filename = "c.carbon", + .line = "import library \"a\";", + .line_number = 1, + .column_number = 1, + .length = 6}; + Loc reported = {.filename = "a.carbon", + .line = "class Shape {}", + .line_number = 3, + .column_number = 1, + .length = 14}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(reported, "duplicate name", + {MakeOrigin(import_loc, "in import")}), + .contexts = {MakeContext(At(4, 3, 7), "in call")}}; + // The message's own path is drawn, above the location row of the file it + // leads to -- here the second location row, since the context's snippet comes + // first. + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^^^^\n" + " : '--| error: in call\n" + " :\n" + " | .-- in import: c.carbon:1:1\n" + " |-| a.carbon:3:1\n" + " 3 | class Shape {}\n" + " : -------.------\n" + " : '--| duplicate name\n" + " '----\n" "")); } @@ -1033,27 +1094,20 @@ TEST(RendererTest, ContextStepsStackInOrder) { .length = 3}; Diagnostic diagnostic = { .level = Level::Error, - .message = MakeMessage(At(4, 3, 7), "no matching function"), - .labels = {MakeLabel(LabelCategory::Info, target, "candidate not viable", - {MakeOrigin(step("main.carbon", 4), "included from"), - MakeOrigin(step("outer.h", 3), "included from")})}}; - // Each step leads to the next, and the last leads into the anchor, so the - // path reads in the order it was walked. + .message = + MakeMessage(target, "no matching function", + {MakeOrigin(step("main.carbon", 4), "included from"), + MakeOrigin(step("outer.h", 3), "included from")})}; + // Each step leads to the next, and the last leads into the location row, so + // the path reads in the order it was walked. EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: no matching function\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : -------\n" - " |------------\n" - " | .-- included from: main.carbon:4:1\n" + Eq(" | .-- included from: main.carbon:4:1\n" " | |-- included from: outer.h:3:1\n" " |-| inner.h:7:6\n" - " :\n" - " 7 | void Use(int, int);\n" - " : -.-\n" - " : '--| candidate not viable\n" - " '------------\n" + "-> 7 | void Use(int, int);\n" + " : ^^^\n" + " : '--| error: no matching function\n" + " '----\n" "")); } @@ -1067,19 +1121,41 @@ TEST(RendererTest, LocationInfoHasNoSnippet) { .level = Level::Error, .message = MakeMessage(At(4, 3, 7), "duplicate name", {MakeOrigin(import_loc, "in import")})}; - // The location information sits above the anchor of the location it + // The location information sits above the location row of the location it // describes, and its own location follows its words. EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: duplicate name\n" - " | .-- in import: a.carbon:2:1\n" + Eq(" | .-- in import: a.carbon:2:1\n" " |-| foo.carbon:4:3\n" - " :\n" "-> 4 | Run0(1);\n" - " : -------\n" - " '------------\n" + " : ^^^^^^^\n" + " : '--| error: duplicate name\n" + " '----\n" "")); } +TEST(RendererTest, AFileOnlyLeadingMessageGivesItsFileOneLocationRow) { + // A message located at a file and nothing more is placed under that file's + // location row, and the file's spans follow under the same location row below + // an elision, so the file has one location row. + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(FileOnly(), "bad"), + .labels = {MakeLabel(LabelCategory::Info, At(1, 1, 2), "declared here"), + MakeLabel(LabelCategory::Info, At(4, 3, 7), "used here")}}; + EXPECT_THAT(Render(Plain(), diagnostic), Eq("-> .-| foo.carbon\n" + " : '--| error: bad\n" + " :\n" + " 1 | fn Run0() {}\n" + " : -.\n" + " : '--| declared here\n" + " :\n" + " 4 | Run0(1);\n" + " : ---.---\n" + " : '--| used here\n" + " '----\n" + "")); +} + TEST(RendererTest, FirstContextMessageTakesTheDiagnosticLevel) { Diagnostic diagnostic = {.level = Level::Error, .message = MakeMessage({}, "the problem"), @@ -1105,24 +1181,23 @@ TEST(RendererTest, Utf8DrawsTheFrameWithBoxDrawing) { .level = Level::Error, .message = MakeMessage(At(4, 3, 7), "bad"), .labels = {MakeLabel(LabelCategory::Info, At(1, 1, 12), "here")}}; - EXPECT_THAT(Render(capabilities, diagnostic), Eq("error: bad\n" - " ╭─┤ foo.carbon:4:3\n" - " │\n" - " 1 │ fn Run0() {}\n" - " · ──────┬─────\n" - " · ╰──┤ here\n" - " ┆\n" - "-> 4 │ Run0(1);\n" - " · ───────\n" - " ╰────────────\n" - "")); + EXPECT_THAT(Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:3\n" + " 1 │ fn Run0() {}\n" + " · ──────┬─────\n" + " · ╰──┤ here\n" + " ┆\n" + "-> 4 │ Run0(1);\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: bad\n" + " ╰────\n" + "")); } -TEST(RendererTest, Utf8SeparatorAndAnchorAreTeedOffTheFrame) { - // Under ASCII every junction is `+`, so this is the only place the shapes the - // frame is made of are distinguishable: the rule closing one snippet is a tee - // because the frame carries on past it, the anchor below it is a tee for the - // same reason, and only the closing rule is a corner. +TEST(RendererTest, Utf8ElisionContinuesTheFrameToTheNextLocationRow) { + // The step from one snippet to the next file's location row is an elision, as + // skipped lines inside a snippet are, so the frame continues unbroken down + // to the next location row's `├`. Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; static constexpr llvm::StringLiteral LibFile = "fn Run0() {}\n"; Loc declaration = {.filename = "lib.carbon", @@ -1136,18 +1211,16 @@ TEST(RendererTest, Utf8SeparatorAndAnchorAreTeedOffTheFrame) { .message = MakeMessage(At(4, 3, 7), "too many arguments"), .labels = {MakeLabel(LabelCategory::Info, declaration, "declared here")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: too many arguments\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───────\n" - " ├────────────\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: too many arguments\n" + " ┆\n" " ├─┤ lib.carbon:1:1\n" - " │\n" " 1 │ fn Run0() {}\n" " · ──────┬─────\n" " · ╰──┤ declared here\n" - " ╰────────────\n" + " ╰────\n" "")); } @@ -1163,75 +1236,109 @@ TEST(RendererTest, Utf8ContextStepsStackIntoOneLine) { Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, - .message = MakeMessage(At(4, 3, 7), "no matching function"), - .labels = {MakeLabel(LabelCategory::Info, target, "candidate not viable", - {MakeOrigin(step("main.carbon", 4), "included from"), - MakeOrigin(step("outer.h", 3), "included from")})}}; - // Each step's connector descends into the next, so the first opens the line - // and the rest are tees on it, and the last descends into the bracket that - // opens the anchor. All of that is junctions the buffer forms where the + .message = + MakeMessage(target, "no matching function", + {MakeOrigin(step("main.carbon", 4), "included from"), + MakeOrigin(step("outer.h", 3), "included from")})}; + // Each step's line descends into the next, so the first opens the line and + // the rest are tees on it, and the last descends into the bracket that opens + // the location row. All of that is junctions the buffer forms where the // segments meet; none of these glyphs is named by the renderer. EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: no matching function\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" - "-> 4 │ Run0(1);\n" - " · ───────\n" - " ├────────────\n" - " │ ╭── included from: main.carbon:4:1\n" + Eq(" ╷ ╭── included from: main.carbon:4:1\n" " │ ├── included from: outer.h:3:1\n" " ├─┤ inner.h:7:6\n" - " ┆\n" - " 7 │ void Use(int, int);\n" - " · ─┬─\n" - " · ╰──┤ candidate not viable\n" - " ╰────────────\n" + "-> 7 │ void Use(int, int);\n" + " · ━┳━\n" + " · ┗━━┫ error: no matching function\n" + " ╰────\n" "")); } -TEST(RendererTest, Utf8MessageRowBranchesOffTheFrame) { +TEST(RendererTest, Utf8LocationLabelIsPlacedUnderItsLocationRow) { Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 7), "bad"), .labels = {MakeLabel(LabelCategory::Info, FileOnly(), "declared here")}}; - // A label with no source to point at says what it has to say on a row of its - // own, branching off the frame with a two-column stub, which is a tee rather - // than the corner an anchor opens with. + // A label with no source has its text placed under a location row naming what + // location it has, and an elision separates that location row from the + // snippet above, as for any other location row. EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───────\n" - " ├────────────\n" - " ├─ note: declared here\n" - " ╰────────────\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: bad\n" + " ┆\n" + " ├─┤ foo.carbon\n" + " · ╰──┤ declared here\n" + " ╰────\n" "")); } -TEST(RendererTest, ALineWithoutAColumnGetsNoAnchor) { +TEST(RendererTest, ALineWithoutAColumnIsPlacedUnderItsLocationRow) { Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 7), "bad"), .labels = {MakeLabel(LabelCategory::Info, LineOnly(1), "declared here")}}; - // A line with no column reaches no source, so it draws as no location at - // all does: an anchor above the words would open a snippet that never - // comes. + // A location with a line and no column has no source, so the label's text + // is placed under a location row naming the line, as for one naming only a + // file. EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───────\n" - " ├────────────\n" - " ├─ note: declared here\n" - " ╰────────────\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: bad\n" + " ┆\n" + " ├─┤ foo.carbon:1\n" + " · ╰──┤ declared here\n" + " ╰────\n" "")); } -TEST(RendererTest, Utf8WrappedMessageRowMarksItsContinuations) { +TEST(RendererTest, APartWithNoLocationGetsANoLocationRow) { + Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(At(4, 3, 7), "bad"), + .labels = {MakeLabel(LabelCategory::Info, Loc(), "declared here")}}; + // A part with no location at all still gets a location row for its text, + // which names ``. + EXPECT_THAT(Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:3\n" + "-> 4 │ Run0(1);\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: bad\n" + " ┆\n" + " ├─┤ \n" + " · ╰──┤ declared here\n" + " ╰────\n" + "")); +} + +TEST(RendererTest, ALeadingMessageWithNoLocationOpensTheFrame) { + Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(Loc(), "bad"), + .labels = {MakeLabel(LabelCategory::Info, At(1, 1, 2), "declared here")}}; + // A message with no location still leads: its text is placed under a + // `` location row with a heavy label line and bar, the location + // row takes the `->`, and the label's file gets a location row after it. + EXPECT_THAT(Render(capabilities, diagnostic), + Eq("-> ╭─┤ \n" + " · ┗━━┫ error: bad\n" + " ┆\n" + " ├─┤ foo.carbon:1:1\n" + " 1 │ fn Run0() {}\n" + " · ─┬\n" + " · ╰──┤ declared here\n" + " ╰────\n" + "")); +} + +TEST(RendererTest, Utf8WrappedLocationLabelKeepsItsBar) { Terminal::Capabilities capabilities = { .charset = Terminal::Charset::Utf8, .is_terminal = true, .columns = 76}; Diagnostic diagnostic = { @@ -1241,20 +1348,19 @@ TEST(RendererTest, Utf8WrappedMessageRowMarksItsContinuations) { LabelCategory::Info, FileOnly(), "this one has rather a lot to say about the declaration it points " "at, more than fits a row")}}; - // A message row that wraps pushes the rows below it down, and each row it - // spills onto breaks the frame the same way its first row does, so the block - // reads as one message rather than as several. + // A location label wraps as a label does, with the bar down every row it + // takes. EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ───────\n" - " ├────────────\n" - " ├─ note: this one has rather a lot to say about the " + " · ━━━┳━━━\n" + " · ┗━━┫ error: bad\n" + " ┆\n" + " ├─┤ foo.carbon\n" + " · ╰──┤ this one has rather a lot to say about the " "declaration it\n" - " · points at, more than fits a row\n" - " ╰────────────\n" + " · │ points at, more than fits a row\n" + " ╰────\n" "")); } @@ -1266,17 +1372,17 @@ TEST(RendererTest, ColorStylesEachElement) { // Bold and the color arrive as separate sequences, and blanks between // styled runs carry no style of their own. The message is one style // throughout, backticks included. - Eq("\x1b[1m\x1b[91merror: \x1b[0m\x1b[1mbad `x` here\n" - "\x1b[0m \x1b[1m\x1b[94m.-|\x1b[0m foo.carbon:4:3\n" - " \x1b[1m\x1b[94m:\n" - "\x1b[91m->\x1b[0m \x1b[1m\x1b[91m4\x1b[0m \x1b[1m\x1b[94m|\x1b[0m " - " Run0(1);\n" - " \x1b[91m:\x1b[0m \x1b[91m-------\n" - "\x1b[0m \x1b[1m\x1b[94m'------------\x1b[0m\n" + Eq(" \x1b[1m\x1b[94m.-|\x1b[0m foo.carbon:4:3\n" + "\x1b[1m\x1b[91m->\x1b[0m \x1b[1m\x1b[91m4\x1b[0m " + "\x1b[1m\x1b[94m|\x1b[0m Run0(1);\n" + " \x1b[91m:\x1b[0m \x1b[1m\x1b[91m^^^^^^^\n" + "\x1b[0m \x1b[91m:\x1b[0m \x1b[1m\x1b[91m'--|\x1b[0m " + "\x1b[1m\x1b[91merror: \x1b[0m\x1b[1mbad `x` here\n" + "\x1b[0m \x1b[1m\x1b[94m'----\x1b[0m\n" "")); } -TEST(RendererTest, AnnotationsTakeTheColorOfTheirMessage) { +TEST(RendererTest, UnderlinesTakeTheColorOfTheirMessage) { Terminal::Capabilities capabilities = {.color_mode = Terminal::ColorMode::Ansi16}; Diagnostic diagnostic = { @@ -1285,9 +1391,10 @@ TEST(RendererTest, AnnotationsTakeTheColorOfTheirMessage) { .labels = {MakeLabel(LabelCategory::Info, At(1, 1, 12), "aside")}}; std::string rendered = Render(capabilities, diagnostic); // The message's underline is the warning color and the note's is the note - // color, so each mark matches the words that explain it. Neither is bold: a - // mark's weight says nothing a terminal renders reliably. - EXPECT_THAT(rendered, HasSubstr("\x1b[93m-------\n")); + // color, so each underline matches the text that explains it. The message's + // underline is heavy and bold, matching its bold text; the note's is neither, + // since terminals render bold on line art unreliably. + EXPECT_THAT(rendered, HasSubstr("\x1b[1m\x1b[93m^^^^^^^\n")); EXPECT_THAT(rendered, HasSubstr("\x1b[96m------.-----\n")); // The line the problem is on takes the level's color and its weight. Every // other line number is as light as the frame it belongs to, so the one being @@ -1304,10 +1411,9 @@ TEST(RendererTest, TheFrameSeparatorIsFrame) { .message = MakeMessage(At(4, 3, 7), "careful", {}, Level::Warning), .labels = {MakeLabel(LabelCategory::Info, At(1, 1, 12), "aside")}}; std::string rendered = Render(capabilities, diagnostic); - // The separator runs down the frame's own column, so it is the headline's - // color on every row -- including the note's, whose underline and words are - // the note color beside it. Coloring it per row made it read as belonging to - // whichever range was there rather than to the frame. + // The frame's glyph on underline and label rows is in the frame's column, so + // it is the leading part's color on every row, including the note's, whose + // underline and label are the note color beside it. EXPECT_THAT(rendered, HasSubstr("\x1b[93m:\x1b[0m \x1b[96m------.-----")); EXPECT_THAT(rendered, HasSubstr("\x1b[93m:\x1b[0m \x1b[96m'--|")); } @@ -1321,11 +1427,11 @@ TEST(RendererTest, RotateColorsEachRangeOnALine) { .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 4), ""), MakeLabel(LabelCategory::Primary, At(4, 8, 1), "")}}; std::string rendered = Render(capabilities, diagnostic); - // A ramp left to right, dark end first, so several ranges read as a - // progression across the line. Both are reds: which theme a range belongs to - // is what its color says first. - EXPECT_THAT(rendered, HasSubstr("\x1b[31m----")); - EXPECT_THAT(rendered, HasSubstr("\x1b[91m-")); + // The range hosting the message keeps the theme's center color, heavy and + // bold. The other problem range takes the ramp with the center left out, so + // it gets the dark end. Both are reds, so the color shows the theme first. + EXPECT_THAT(rendered, HasSubstr("\x1b[1m\x1b[91m^^^^")); + EXPECT_THAT(rendered, HasSubstr("\x1b[31m-")); } TEST(RendererTest, RotateStaysInsideAThemeWithOnlyNamedColors) { @@ -1333,13 +1439,13 @@ TEST(RendererTest, RotateStaysInsideAThemeWithOnlyNamedColors) { Terminal::ColorMode::Ansi16}; Diagnostic diagnostic = { .level = Level::Error, - .message = MakeMessage(At(4, 3, 7), "bad call"), - .labels = {MakeLabel(LabelCategory::Info, At(4, 3, 4), ""), - MakeLabel(LabelCategory::Info, At(4, 8, 1), "")}}; + .message = MakeMessage(At(4, 3, 4), "bad call"), + .labels = {MakeLabel(LabelCategory::Info, At(4, 8, 1), ""), + MakeLabel(LabelCategory::Info, At(4, 9, 1), "")}}; std::string rendered = Render(capabilities, diagnostic); // The ranges explaining the problem walk their own ramp, so a second note // range is another cyan rather than the level's second color. - EXPECT_THAT(rendered, HasSubstr("\x1b[36m----")); + EXPECT_THAT(rendered, HasSubstr("\x1b[36m-")); EXPECT_THAT(rendered, HasSubstr("\x1b[96m-")); } @@ -1435,14 +1541,13 @@ TEST(RendererTest, LongSourceLineIsWindowedOnATerminal) { .length = 4}; EXPECT_THAT( RenderOne(capabilities, Level::Error, loc, "found it"), - Eq("error: found it\n" - " .-| foo.carbon:1:101\n" - " |\n" + Eq(" .-| foo.carbon:1:101\n" "-> 1 | " "...xxxxxxxxxxxxxxxxHERExxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx." "..\n" - " : ----\n" - " '------------\n" + " : ^^^^\n" + " : '--| error: found it\n" + " '----\n" "")); } @@ -1501,9 +1606,7 @@ TEST(RendererTest, LineShownBetweenTwoSpansIsWindowedToo) { .message = MakeMessage(at(3), "bad"), .labels = {MakeLabel(LabelCategory::Info, at(1), "and")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad\n" - " .-| foo.carbon:3:1\n" - " |\n" + Eq(" .-| foo.carbon:3:1\n" " 1 | short\n" " : --.-\n" " : '--| and\n" @@ -1511,8 +1614,9 @@ TEST(RendererTest, LineShownBetweenTwoSpansIsWindowedToo) { "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxx...\n" "-> 3 | also short\n" - " : ----\n" - " '------------\n" + " : ^^^^\n" + " : '--| error: bad\n" + " '----\n" "")); } @@ -1536,14 +1640,14 @@ TEST(RendererTest, WindowingKeepsWideCharactersWhole) { // The underline lands under the `x`, however the window fell. Both columns // are measured rather than compared as byte offsets, since every `界` before // them is three bytes and two columns. - auto column_of = [&](llvm::StringRef prefix, llvm::StringRef mark) { + auto column_of = [&](llvm::StringRef prefix, llvm::StringRef glyph) { llvm::StringRef row = llvm::StringRef(rendered).split(prefix).second; row = row.take_until([](char c) { return c == '\n'; }); - size_t at = row.find(mark); + size_t at = row.find(glyph); EXPECT_NE(at, llvm::StringRef::npos) << row.str(); return metrics.Width(row.substr(0, at)); }; - EXPECT_THAT(column_of("-> 1 │", "x"), Eq(column_of(" ·", "─"))); + EXPECT_THAT(column_of("-> 1 │", "x"), Eq(column_of(" ·", "┳"))); // Every row fits the terminal, which needs each `界` kept whole. llvm::StringRef rest = rendered; while (!rest.empty()) { @@ -1564,14 +1668,14 @@ TEST(RendererTest, AnUnstatedWidthIsStillATargetToWrapTo) { // Wrapped under itself, past the level word, so a continuation cannot read as // the start of another diagnostic. EXPECT_THAT(RenderOne(Plain(), Level::Error, At(4, 3, 7), text), - Eq("error: a message with rather a lot to say, more than would " - "fit a terminal of the usual\n" - " width, and so more than enough to wrap\n" - " .-| foo.carbon:4:3\n" - " :\n" + Eq(" .-| foo.carbon:4:3\n" "-> 4 | Run0(1);\n" - " : -------\n" - " '------------\n" + " : ^^^^^^^\n" + " : '--| error: a message with rather a lot to say, " + "more than would fit a terminal\n" + " : | of the usual width, and so more than " + "enough to wrap\n" + " '----\n" "")); // A width that is stated is fitted, which is the whole of the difference @@ -1579,7 +1683,7 @@ TEST(RendererTest, AnUnstatedWidthIsStillATargetToWrapTo) { Terminal::Capabilities capabilities = {.is_terminal = true, .columns = 80}; std::string wrapped = RenderOne(capabilities, Level::Error, At(4, 3, 7), text); - // The headline wraps under itself, past the level word. + // The message wraps to the column after its level word, inside its bar. EXPECT_THAT(wrapped, HasSubstr("\n ")); llvm::StringRef rest = wrapped; while (!rest.empty()) { @@ -1641,13 +1745,12 @@ TEST(RendererTest, AKindTagTakesARowOfItsOwnWhenItCannotShareOne) { EXPECT_THAT( render("short label"), - Eq("error: bad [TestDiagnostic]\n" - " ╭─┤ foo.carbon:2:11\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:2:11\n" "-> 2 │ NeedsIt(\"definitely not the right type\");\n" - " · ───────────────┬──────────────\n" - " · ╰──┤ short label [TestLabel]\n" - " ╰────────────\n" + " · ━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad [TestDiagnostic]\n" + " · ╰────┤ short label [TestLabel]\n" + " ╰────\n" "")); // The tag is drawn on its own rather than joined to the text, so it keeps its @@ -1678,112 +1781,124 @@ TEST(RendererTest, AKindTagTakesARowOfItsOwnWhenItCannotShareOne) { render("type `str` does not implement interface " "`Core.ImplicitAs(i32)` at all, and it really will not " "be doing so any time soon either, sorry"), - Eq("error: bad [TestDiagnostic]\n" - " ╭─┤ foo.carbon:2:11\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:2:11\n" "-> 2 │ NeedsIt(\"definitely not the right type\");\n" - " · ┬─────────────────────────────\n" - " · │ │ type `str` does not implement interface\n" - " · ╰──┤ `Core.ImplicitAs(i32)` at all, and it really " - "will\n" - " · │ not be doing so any time soon either, sorry\n" - " · │ [TestLabel]\n" - " ╰────────────\n" + " · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad [TestDiagnostic]\n" + " · ╰────┤ type `str` does not implement interface\n" + " · │ `Core.ImplicitAs(i32)` at all, and it " + "really will\n" + " · │ not be doing so any time soon either, " + "sorry\n" + " · │ [TestLabel]\n" + " ╰────\n" "")); } +TEST(RendererTest, AQuotedRunWrapsWhole) { + // Code a message quotes is one word to wrapping, so a type written with + // spaces moves to the next row whole rather than splitting at a space + // inside the backticks. Every wrapped block follows the rule: the message's, + // a label's, and the routed decision that asks how wide the widest word is. + EXPECT_THAT(RenderLabel(62, "cannot convert type `{.a: i32, .b: i32}` here"), + Eq(" ╭─┤ foo.carbon:2:11\n" + "-> 2 │ NeedsIt(\"definitely not the right type\");\n" + " · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad\n" + " · ╰────┤ cannot convert type\n" + " · │ `{.a: i32, .b: i32}` here\n" + " ╰────\n" + "")); +} + TEST(RendererTest, ALabelIsFramedWhenItWraps) { // The bar frames every row the label takes, so what belongs to it is bounded - // rather than left to be read off the indentation, and the connector meets - // that bar in the label's middle row. + // rather than left to be read off the indentation, and the label line meets + // that bar on the label's first row, where its text begins. EXPECT_THAT( RenderLabel(76, "type `str` does not implement interface " "`Core.ImplicitAs(i32)` at all, and it really will not " "be doing so any time soon either, sorry"), - Eq("error: bad\n" - " ╭─┤ foo.carbon:2:11\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:2:11\n" "-> 2 │ NeedsIt(\"definitely not the right type\");\n" - " · ┬─────────────────────────────\n" - " · │ │ type `str` does not implement interface\n" - " · ╰──┤ `Core.ImplicitAs(i32)` at all, and it really " - "will\n" - " · │ not be doing so any time soon either, sorry\n" - " ╰────────────\n" + " · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad\n" + " · ╰────┤ type `str` does not implement interface\n" + " · │ `Core.ImplicitAs(i32)` at all, and it " + "really will\n" + " · │ not be doing so any time soon either, " + "sorry\n" + " ╰────\n" "")); // A label of one row is framed the same as a label of ten: the bar is a - // stroke on each row rather than a line between them, so the cell the - // connector arrives at is a tee and not the corner an end would be. + // separate line on each row rather than one line through them, so the cell + // the label line arrives at is a tee and not the corner an end would be. EXPECT_THAT(RenderLabel(76, "type `str` does not implement it"), - Eq("error: bad\n" - " ╭─┤ foo.carbon:2:11\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:2:11\n" "-> 2 │ NeedsIt(\"definitely not the right type\");\n" - " · ───────────────┬──────────────\n" - " · ╰──┤ type `str` does not " + " · ━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad\n" + " · ╰────┤ type `str` does not " "implement it\n" - " ╰────────────\n" + " ╰────\n" "")); - // Under ASCII every junction is `+`, so the bar below the connector is what - // says the second row belongs to the label above it. + // ASCII keeps each corner's own glyph, and the bar below the label line is + // what says the second row belongs to the label above it. EXPECT_THAT( RenderLabel(76, "type `str` does not implement interface " "`Core.ImplicitAs(i32)` at all", Terminal::Charset::Ascii), - Eq("error: bad\n" - " .-| foo.carbon:2:11\n" - " :\n" + Eq(" .-| foo.carbon:2:11\n" "-> 2 | NeedsIt(\"definitely not the right type\");\n" - " : .-----------------------------\n" - " : '--| type `str` does not implement interface\n" - " : | `Core.ImplicitAs(i32)` at all\n" - " '------------\n" + " : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + " : '--| error: bad\n" + " : '----| type `str` does not implement interface\n" + " : | `Core.ImplicitAs(i32)` at all\n" + " '----\n" "")); } TEST(RendererTest, ALabelSlidesLeftBeforeItWraps) { - // Sliding the connector left inside the range is what a label gives up - // first, since that buys columns and costs nothing to read. Only then does it - // wrap, and it is out-dented only where even its widest word doesn't fit - // beside the connector. + // Label lines slide left inside their ranges before any text wraps. Here the + // label and the message share the range, so both label lines slide to its + // start. Only then does text wrap, and a label is out-dented only where its + // widest word does not fit right of its label line. EXPECT_THAT( RenderLabel(76, "type `str` does not implement interface " "`Core.ImplicitAs(i32)` at all"), - Eq("error: bad\n" - " ╭─┤ foo.carbon:2:11\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:2:11\n" "-> 2 │ NeedsIt(\"definitely not the right type\");\n" - " · ┬─────────────────────────────\n" - " · ╰──┤ type `str` does not implement interface\n" - " · │ `Core.ImplicitAs(i32)` at all\n" - " ╰────────────\n" + " · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad\n" + " · ╰────┤ type `str` does not implement interface\n" + " · │ `Core.ImplicitAs(i32)` at all\n" + " ╰────\n" "")); } TEST(RendererTest, ALabelWithNowhereToHangIsRoutedBack) { // The label's widest word doesn't fit beside either end of the range, so it - // is out-dented past the connector and its own frame is what reaches back: + // is out-dented past the label line and its own frame is what reaches back: // the top of the bar turns right along the row under the underline and runs - // to the column the connector came down. + // to the column the label line came down. EXPECT_THAT( RenderLabel(76, "`Core.ImplicitAs(" "ExtremelyLongNamedGenericContainerTypeForTesting(i32))`"), - Eq("error: bad\n" - " ╭─┤ foo.carbon:2:11\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:2:11\n" "-> 2 │ NeedsIt(\"definitely not the right type\");\n" - " · ┬─────────────────────────────\n" - " · ╭─────────╯\n" + " · ━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad\n" + " · ╭────────────────────────╯\n" " · │ " "`Core.ImplicitAs(ExtremelyLongNamedGenericContainerTypeForTesting(" "i32))`\n" - " ╰────────────\n" + " ╰────\n" "")); } @@ -1799,43 +1914,141 @@ TEST(RendererTest, ARoutedLabelIsFramedDownEveryRow) { "i32, ExtremelyLongNamedGenericContainerTypeForTesting(i32, i32)))` " "and it " "will not be doing so any time soon"), - Eq("error: bad\n" - " ╭─┤ foo.carbon:2:11\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:2:11\n" "-> 2 │ NeedsIt(\"definitely not the right type\");\n" - " · ┬─────────────────────────────\n" - " · ╭─────────╯\n" + " · ━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━\n" + " · ┗━━┫ error: bad\n" + " · ╭────────────────────────╯\n" " · │ type `str` does not implement interface\n" " · │ " "`Core.ImplicitAs(ExtremelyLongNamedGenericContainerTypeForTesting(" - "i32,\n" - " · │ ExtremelyLongNamedGenericContainerTypeForTesting(i32, " - "i32)))` and\n" - " · │ it will not be doing so any time soon\n" - " ╰────────────\n" + "i32, ExtremelyLongNamedGenericContainerTypeForTesting(i32, i32)))`\n" + " · │ and it will not be doing so any time soon\n" + " ╰────\n" + "")); +} + +TEST(RendererTest, LabelLinesSlideForAnotherLabelsWords) { + // Every label's text starts right of every label line's column, so the + // message's text fits on one row here only because the label line of the + // label to its right slides left within that label's range, and only as + // far as the message's text needs, short of where the range starts. + static constexpr llvm::StringLiteral Line = " Run0(aVeryLongArgument);"; + auto at = [&](int column, int length) { + return Loc{.filename = "foo.carbon", + .line = Line, + .line_number = 4, + .column_number = column, + .length = length}; + }; + Terminal::Capabilities capabilities = { + .charset = Terminal::Charset::Utf8, .is_terminal = true, .columns = 60}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(at(3, 4), "call would overflow the result"), + .labels = {MakeLabel(LabelCategory::Info, at(8, 17), "short")}}; + EXPECT_THAT( + Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:3\n" + "-> 4 │ Run0(aVeryLongArgument);\n" + " · ━━┳━ ──┬──────────────\n" + " · ┗━━━━━━━┫ error: call would overflow the result\n" + " · ╰────┤ short\n" + " ╰────\n" + "")); +} + +TEST(RendererTest, RoutedLabelsStackInReadingOrder) { + // Two labels whose widest words do not fit even with every label line slid + // are each out-dented to the source's column, in reading order, while the + // message stays under its underline. Each block's bar reaches back to its + // label line, and the label line descending to the later block passes the + // earlier block's reach-back row and skips its text rows. + static constexpr llvm::StringLiteral Line = " Run0(first, second);"; + auto at = [&](int column, int length) { + return Loc{.filename = "foo.carbon", + .line = Line, + .line_number = 4, + .column_number = column, + .length = length}; + }; + Terminal::Capabilities capabilities = { + .charset = Terminal::Charset::Utf8, .is_terminal = true, .columns = 60}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(at(3, 4), "bad call"), + .labels = { + MakeLabel(LabelCategory::Info, at(8, 5), + "`ExtremelyLongUnbreakableTypeNameForTestingNumberOne`"), + MakeLabel(LabelCategory::Info, at(15, 6), + "`ExtremelyLongUnbreakableTypeNameForTestingNumberTwo`")}}; + EXPECT_THAT( + Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:3\n" + "-> 4 │ Run0(first, second);\n" + " · ━━┳━ ──┬── ───┬──\n" + " · ┗━━━━━━━━━━━━━━━┫ error: bad call\n" + " · ╭────────╯ │\n" + " · │ `ExtremelyLongUnbreakableTypeNameForTestingNumberOne`\n" + " · ╭────────────────╯\n" + " · │ `ExtremelyLongUnbreakableTypeNameForTestingNumberTwo`\n" + " ╰────\n" + "")); +} + +TEST(RendererTest, ALabelFollowsAnOutDentedBlock) { + // An out-dented block takes its place in reading order like any label row, + // so a later label is drawn below the block. Its label line skips the block's + // text rows, and its text still starts right of every label line, including + // an out-dented label's. + static constexpr llvm::StringLiteral Line = " Run0(first, second);"; + auto at = [&](int column, int length) { + return Loc{.filename = "foo.carbon", + .line = Line, + .line_number = 4, + .column_number = column, + .length = length}; + }; + Terminal::Capabilities capabilities = { + .charset = Terminal::Charset::Utf8, .is_terminal = true, .columns = 60}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage(at(3, 4), "bad call"), + .labels = { + MakeLabel(LabelCategory::Info, at(8, 5), + "`ExtremelyLongUnbreakableTypeNameForTestingNumberOne`"), + MakeLabel(LabelCategory::Info, at(15, 6), "short")}}; + EXPECT_THAT( + Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:3\n" + "-> 4 │ Run0(first, second);\n" + " · ━━┳━ ──┬── ───┬──\n" + " · ┗━━━━━━━━━━━━━━━┫ error: bad call\n" + " · ╭────────╯ │\n" + " · │ `ExtremelyLongUnbreakableTypeNameForTestingNumberOne`\n" + " · ╰────┤ short\n" + " ╰────\n" "")); } TEST(RendererTest, ARoutedLabelUnderAscii) { - // Every corner on the route collapses to `+` here, so what tells them apart - // is the segments running into them, the same way the rest of the frame - // degrades. + // The route degrades to the same corner and bar glyphs as the rest of the + // frame, with the segments running into them telling the corners apart. EXPECT_THAT( RenderLabel(76, "type `str` does not implement interface `Core.ImplicitAs(" "ExtremelyLongNamedGenericContainerTypeForTesting(i32))`", Terminal::Charset::Ascii), - Eq("error: bad\n" - " .-| foo.carbon:2:11\n" - " :\n" + Eq(" .-| foo.carbon:2:11\n" "-> 2 | NeedsIt(\"definitely not the right type\");\n" - " : .-----------------------------\n" - " : .---------'\n" + " : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + " : '--| error: bad\n" + " : .------------------------'\n" " : | type `str` does not implement interface\n" " : | " "`Core.ImplicitAs(ExtremelyLongNamedGenericContainerTypeForTesting(" "i32))`\n" - " '------------\n" + " '----\n" "")); } @@ -1862,12 +2075,11 @@ TEST(RendererTest, InvalidUtf8IsReplacedUnderUtf8) { // The bytes have no rendering of their own, so the buffer replaces them, and // each still takes the one column the underline was measured against. EXPECT_THAT(RenderOne(capabilities, Level::Error, loc, "bad"), - Eq("error: bad\n" - " ╭─┤ foo.carbon:1:1\n" - " │\n" + Eq(" ╭─┤ foo.carbon:1:1\n" "-> 1 │ x = ��;\n" - " · ─\n" - " ╰────────────\n" + " · ┳\n" + " · ┗━━┫ error: bad\n" + " ╰────\n" "")); } @@ -1884,12 +2096,11 @@ TEST(RendererTest, ARangeStartingInsideAWideCharacterCoversItWhole) { .column_number = 3, .length = 1}; EXPECT_THAT(RenderOne(capabilities, Level::Error, loc, "bad"), - Eq("error: bad\n" - " ╭─┤ foo.carbon:1:3\n" - " │\n" + Eq(" ╭─┤ foo.carbon:1:3\n" "-> 1 │ a世b\n" - " · ──\n" - " ╰────────────\n" + " · ━┳\n" + " · ┗━━┫ error: bad\n" + " ╰────\n" "")); } @@ -1900,16 +2111,15 @@ TEST(RendererTest, CarriageReturnIsNotDrawn) { .column_number = 5, .length = 1}; EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "bad"), - Eq("error: bad\n" - " .-| foo.carbon:1:5\n" - " |\n" + Eq(" .-| foo.carbon:1:5\n" "-> 1 | var x;\n" - " : -\n" - " '------------\n" + " : ^\n" + " : '--| error: bad\n" + " '----\n" "")); } -TEST(RendererTest, PrimaryLabelAnchorUnderUtf8) { +TEST(RendererTest, PrimaryLabelUnderUtf8) { Terminal::Capabilities capabilities = {.charset = Terminal::Charset::Utf8}; Diagnostic diagnostic = { .level = Level::Error, @@ -1917,14 +2127,14 @@ TEST(RendererTest, PrimaryLabelAnchorUnderUtf8) { .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), "here")}}; // A primary range turns into its label the same way an informational one // does; only the underline itself differs. - EXPECT_THAT(Render(capabilities, diagnostic), Eq("error: too many arguments\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" - "-> 4 │ Run0(1);\n" - " · ───┬───\n" - " · ╰──┤ here\n" - " ╰────────────\n" - "")); + EXPECT_THAT(Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:4:3\n" + "-> 4 │ Run0(1);\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: too many arguments\n" + " · ╰────┤ here\n" + " ╰────\n" + "")); } TEST(RendererTest, LocationInfoAloneFallsBackToCompact) { @@ -1943,25 +2153,6 @@ TEST(RendererTest, LocationInfoAloneFallsBackToCompact) { "b.carbon: error: bad\n")); } -TEST(RendererTest, TrailingContextStillSaysWhereItIs) { - Diagnostic diagnostic = {.level = Level::Error, - .message = MakeMessage(At(4, 3, 7), "bad")}; - // TODO: This is meant to cover location information with no anchor after it - // to lead into, which says where it is on a row of its own rather than - // losing its location. It doesn't: the diagnostic it builds has no location - // information at all, so it only repeats `ErrorWithSnippet`. Every path that - // adds location information adds the part it leads into straight after, so - // it isn't clear the case is reachable; work out whether it is, and either - // cover it or drop the handling. - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : -------\n" - " '------------\n" - "")); -} - TEST(RendererTest, SnippetsOffSpellsEachRangeInItsLocation) { Diagnostic diagnostic = { .level = Level::Error, @@ -1980,8 +2171,8 @@ TEST(RendererTest, SnippetsOffSpellsEachRangeInItsLocation) { } TEST(RendererTest, AWordlessLabelSaysNothingInTheCompactForm) { - // The label marks a range, and the compact form has no source to mark it - // against, so it contributes no line rather than an empty one. + // The label is attached to a range, and the compact form has no source to + // underline it in, so it contributes no line rather than an empty one. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 1), "bad call"), @@ -1991,19 +2182,19 @@ TEST(RendererTest, AWordlessLabelSaysNothingInTheCompactForm) { } TEST(RendererTest, ARepeatedPathIsDrawnOnce) { - // A primary range over the message's own location was reached the same way - // the message was, so the path leading there is not walked twice. + // A context and the message reached the same way share one drawn path. Loc import_loc = { .filename = "c.carbon", .line_number = 1, .column_number = 1}; llvm::SmallVector origin = { MakeOrigin(import_loc, "imported from")}; Diagnostic diagnostic = { .level = Level::Error, - .message = MakeMessage(At(4, 3, 1), "bad call", origin), - .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), "", origin)}}; + .message = MakeMessage(At(4, 3, 7), "bad call", origin), + .contexts = {MakeContext(At(4, 3, 1), "in call", origin)}}; EXPECT_THAT(Render(Narrow(), diagnostic), Eq("imported from: c.carbon:1:1\n" - "foo.carbon:4:3: error: bad call\n")); + "foo.carbon:4:3: error: in call\n" + "foo.carbon:4:3-9: note: bad call\n")); } TEST(RendererTest, SnippetsOffPutsAContextLocationAfterItsWords) { @@ -2095,68 +2286,62 @@ TEST(RendererTest, TheShapeTheHeaderDraws) { .column_number = 3, .length = 7}; EXPECT_THAT( - Render(capabilities, - {.level = Level::Error, - .message = MakeMessage( - call, "1 argument passed to function expecting 0 arguments"), - .labels = {MakeLabel(LabelCategory::Primary, call, - "1 argument passed here"), - MakeLabel(LabelCategory::Info, decl, - "calling function declared here")}}), - Eq("error: 1 argument passed to function expecting 0 arguments\n" - " ╭─┤ foo.carbon:19:3\n" - " │\n" + Render( + capabilities, + {.level = Level::Error, + .message = MakeMessage(call, "invalid arguments in function call"), + .labels = {MakeLabel(LabelCategory::Info, decl, + "calling function declared here")}}), + Eq(" ╭─┤ foo.carbon:19:3\n" " 1 │ fn Run0() {}\n" " · ──────┬─────\n" " · ╰──┤ calling function declared here\n" " ┆\n" "-> 19 │ Run0(1);\n" - " · ───┬───\n" - " · ╰──┤ 1 argument passed here\n" - " ╰────────────\n" + " · ━━━┳━━━\n" + " · ┗━━┫ error: invalid arguments in function call\n" + " ╰────\n" "")); } TEST(RendererTest, ARangeOnAnotherLineDoesNotStandInForTheLocation) { - // Only a range marking the line the message's location names stands in for - // it. One somewhere else says nothing about that line, and taking its place - // would hang the message's words off code they aren't about while dropping - // the line they are, so the message keeps its own mark and both lines show. + // Only a range on the line the message's location names stands in for it. One + // somewhere else says nothing about that line, and taking its place would + // hang the message's words off code they aren't about while dropping the line + // they are, so the message keeps its own underline and both lines show. EXPECT_THAT(Render(Plain(), {.level = Level::Error, .message = MakeMessage(At(1, 1, 2), "bad"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), "here")}}), - Eq("error: bad\n" - " .-| foo.carbon:1:1\n" - " |\n" + Eq(" .-| foo.carbon:1:1\n" "-> 1 | fn Run0() {}\n" - " : --\n" + " : ^^\n" + " : '--| error: bad\n" " :\n" - "-> 4 | Run0(1);\n" + " 4 | Run0(1);\n" " : ---.---\n" " : '--| here\n" - " '------------\n" + " '----\n" "")); } -TEST(RendererTest, RotateLeavesTheHeadlineTheLevelColor) { - // The level word, the mark in the margin, and the line number beside the - // reported line say what the diagnostic is, so the ramp a range is colored - // from must not reach them. A context leading the diagnostic is a range like - // any other, and the leftmost range of a kind takes the dark end of the ramp. +TEST(RendererTest, RotateLeavesTheHeavyUnderlineTheLevelColor) { + // The level word, the `->` in the margin, the reported line's number, and + // the heavy underline identify the diagnostic, so they keep the level's + // center color. The other problem ranges take colors from the ramp with the + // center left out, starting from the dark end. Terminal::Capabilities capabilities = {.color_mode = Terminal::ColorMode::Truecolor}; Diagnostic diagnostic = { .level = Level::Error, - .message = MakeMessage(At(4, 3, 7), "bad call"), - .contexts = {MakeContext(At(4, 3, 7), "in call")}, + .message = MakeMessage(At(4, 3, 4), "bad call"), + .contexts = {MakeContext(At(4, 3, 4), "in call")}, .labels = {MakeLabel(LabelCategory::Primary, At(4, 8, 1), "")}}; std::string rendered = Render(capabilities, diagnostic); EXPECT_THAT(rendered, HasSubstr("\x1b[1m\x1b[38;2;255;114;97merror: ")); EXPECT_THAT(rendered, HasSubstr("\x1b[38;2;255;114;97m->")); - // The context's own underline still takes the dark end, since it is the - // leftmost of the two ranges marking the problem. - EXPECT_THAT(rendered, HasSubstr("\x1b[38;2;181;86;0m---")); + EXPECT_THAT(rendered, HasSubstr("\x1b[1m\x1b[38;2;255;114;97m^^")); + EXPECT_THAT(rendered, HasSubstr("\x1b[38;2;181;86;0m-")); } TEST(RendererTest, ARampRunsOutAndRepeats) { @@ -2196,9 +2381,9 @@ TEST(RendererTest, Ansi256GetsTheChosenColors) { EXPECT_THAT(rendered, HasSubstr("\x1b[38;5;")); } -TEST(RendererTest, AHostedMessagesConnectorFollowsTheHostsRampColor) { +TEST(RendererTest, AHostedMessagesLabelLineFollowsTheHostsRampColor) { // With a context leading, the message's words hang from the range containing - // its location, and the rotation recolors that host: the connector and bar + // its location, and the rotation recolors that host: the label line and bar // follow the host's rotated color rather than keeping the theme's center. Terminal::Capabilities capabilities = {.color_mode = Terminal::ColorMode::Truecolor}; @@ -2210,15 +2395,15 @@ TEST(RendererTest, AHostedMessagesConnectorFollowsTheHostsRampColor) { MakeLabel(LabelCategory::Primary, At(4, 8, 2), "")}}; std::string rendered = Render(capabilities, diagnostic); // The host is the leftmost problem range on its line and takes the dark - // end; the message's connector reaches its label in the same color. + // end; the message's label line reaches its label in the same color. EXPECT_THAT(rendered, HasSubstr("\x1b[38;2;181;86;0m'--|")) << rendered; } TEST(RendererTest, ASpanPastTheEndOfAFullWidthLineIsWindowedIn) { // An 80-column line exactly fills the unstated-width target, and the span // names the column after its last character -- a missing `;`. The span is - // part of the width, so the line is windowed and the mark lands inside the - // columns rather than one past every cell there is. + // part of the width, so the line is windowed and the underline lands inside + // the columns rather than one past every cell there is. std::string line(80, 'x'); Loc loc = {.filename = "foo.carbon", .line = line, @@ -2226,16 +2411,18 @@ TEST(RendererTest, ASpanPastTheEndOfAFullWidthLineIsWindowedIn) { .column_number = 81, .length = 1}; EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "missing `;`"), - Eq("error: missing `;`\n" - " .-| foo.carbon:1:81\n" - " |\n" + Eq(" .-| foo.carbon:1:81\n" "-> 1 | " "..." "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "xxxxxxxxxxxx\n" " : " - " -\n" - " '------------\n" + " ^\n" + " : " + ".------------------------------------------------------------" + "---------------'\n" + " : | error: missing `;`\n" + " '----\n" "")); } @@ -2261,15 +2448,14 @@ TEST(RendererTest, ASpanOutsideASharedWindowIsClampedToIt) { MakeLabel(LabelCategory::Primary, at(201, 3), "")}}; EXPECT_THAT( Render(capabilities, diagnostic), - Eq("error: bad\n" - " .-| foo.carbon:1:33\n" - " |\n" + Eq(" .-| foo.carbon:1:33\n" "-> 1 | " "...xxxxxxxxxxxxxxxxFIRSTxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx." "..\n" - " : ----- " + " : ^^^^^ " " -\n" - " '------------\n" + " : '--| error: bad\n" + " '----\n" "")); } @@ -2292,19 +2478,18 @@ TEST(RendererTest, ASpanCutOffTheLeftOfAWindowIsNotCarried) { .message = MakeMessage(at(252, 1), "bad"), .labels = {MakeLabel(LabelCategory::Primary, at(250, 5), ""), MakeLabel(LabelCategory::Primary, at(11, 40), "")}}; - // The window shows the right span; the left label, cut off, is a single mark - // on the leading `...` rather than dragging its 40-column length across the - // source that took its place. + // The window shows the right span; the left label, cut off, is a one-column + // underline on the leading `...` rather than dragging its 40-column length + // across the source that took its place. EXPECT_THAT( Render(capabilities, diagnostic), - Eq("error: bad\n" - " .-| foo.carbon:1:252\n" - " |\n" + Eq(" .-| foo.carbon:1:252\n" "-> 1 | " - "...xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - "...\n" - " : - -----\n" - " '------------\n" + "...xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx." + "..\n" + " : - ^^^^^\n" + " : '--| error: bad\n" + " '----\n" "")); } @@ -2318,8 +2503,8 @@ TEST(RendererTest, AControlByteInAFilenameCannotBreakTheFrame) { .length = 1}; std::string rendered = RenderOne(Plain(), Level::Error, loc, "bad"); EXPECT_THAT(rendered, HasSubstr("ab cd tab.carbon:1:5")) << rendered; - // The anchor is one row: the location's own bytes add no newline of their - // own, so the frame still has exactly the rows it draws. + // The location row stays a single row: the location's own bytes add no + // newline of their own, so the frame still has exactly the rows it draws. EXPECT_THAT(rendered, Not(HasSubstr("\n\n"))) << rendered; } @@ -2338,16 +2523,15 @@ TEST(RendererTest, AMergedPairWithoutFileTextStillElides) { .level = Level::Error, .message = MakeMessage(at("first line", 1), "bad"), .labels = {MakeLabel(LabelCategory::Info, at("third line", 3), "here")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad\n" - " .-| foo.carbon:1:1\n" - " |\n" + EXPECT_THAT(Render(Plain(), diagnostic), Eq(" .-| foo.carbon:1:1\n" "-> 1 | first line\n" - " : --\n" + " : ^^\n" + " : '--| error: bad\n" " :\n" " 3 | third line\n" " : -.\n" " : '--| here\n" - " '------------\n" + " '----\n" "")); } @@ -2358,20 +2542,20 @@ TEST(RendererTest, ControlCharactersInWordsBecomeSpaces) { HasSubstr("error: bad call\n")); } -TEST(RendererTest, AWhitespaceOnlyLabelIsJustAMark) { +TEST(RendererTest, AWhitespaceOnlyLabelIsJustAnUnderline) { // A label whose text scrubs away to spaces has nothing to hang: it becomes - // a mark with no connector, rather than rows framing nothing. + // an underline with no label line, rather than rows framing nothing. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 3, 4), "bad call"), .labels = {MakeLabel(LabelCategory::Primary, At(4, 8, 2), "\n")}}; - EXPECT_THAT(Render(Plain(), diagnostic), Eq("error: bad call\n" - " .-| foo.carbon:4:3\n" - " :\n" - "-> 4 | Run0(1);\n" - " : --\n" - " '------------\n" - "")); + EXPECT_THAT(Render(Plain(), diagnostic), + Eq(" .-| foo.carbon:4:3\n" + "-> 4 | Run0(1);\n" + " : ^^^^ --\n" + " : '--| error: bad call\n" + " '----\n" + "")); } TEST(RendererTest, AZeroLengthSpanIsDrawnAsAPoint) { @@ -2383,41 +2567,72 @@ TEST(RendererTest, AZeroLengthSpanIsDrawnAsAPoint) { .column_number = 5, .length = 0}; EXPECT_THAT(RenderOne(Plain(), Level::Error, loc, "bad"), - Eq("error: bad\n" - " .-| foo.carbon:1:5\n" - " |\n" + Eq(" .-| foo.carbon:1:5\n" "-> 1 | var x: i32\n" - " : -\n" - " '------------\n" + " : ^\n" + " : '--| error: bad\n" + " '----\n" "")); } TEST(RendererTest, AContextLeadsTheFrameAndTheMessageHangs) { - // A context with a location leads the diagnostic: it is the headline, and - // the message's words hang as a label from the range standing in for its - // location. + // A context with a location leads the diagnostic: the level word and the + // heavy underline are its, and the message's text is placed like a label's + // under the range containing its location, in the problem's color. Diagnostic diagnostic = { .level = Level::Error, .message = MakeMessage(At(4, 4, 1), "no matching call"), .contexts = {MakeContext(At(3, 4, 4), "in `Main`")}, .labels = {MakeLabel(LabelCategory::Primary, At(4, 3, 7), "")}}; EXPECT_THAT(Render(Plain(), diagnostic), - Eq("error: in `Main`\n" - " .-| foo.carbon:3:4\n" - " :\n" + Eq(" .-| foo.carbon:3:4\n" "-> 3 | fn Main() {\n" - " : ----\n" - "-> 4 | Run0(1);\n" + " : ^^^^\n" + " : '--| error: in `Main`\n" + " 4 | Run0(1);\n" " : ---.---\n" " : '--| no matching call\n" - " '------------\n" + " '----\n" "")); } -TEST(RendererTest, AConnectorCrossingARoutedLabelYieldsToItsWords) { - // A routed label's words span the full width, so a later label's connector - // crosses their rows; the words win the cells they share, interrupting the - // connector rather than being struck through. +TEST(RendererTest, ALabelLinePassingAnOutDentedBlockSkipsItsRowsWhole) { + // An out-dented block occupies its rows from the bar to the right edge, + // blank cells included, so a label line descending past it skips every row of + // the block. A line in the indent under the level word would look like a + // second bar framing the continuation. + auto routed_at = [](int column, int length) { + Loc loc = RoutedLoc(); + loc.column_number = column; + loc.length = length; + return loc; + }; + Terminal::Capabilities capabilities = { + .charset = Terminal::Charset::Utf8, .is_terminal = true, .columns = 76}; + Diagnostic diagnostic = { + .level = Level::Error, + .message = MakeMessage( + RoutedLoc(), + "type `str` does not implement interface `Core.ImplicitAs(" + "ExtremelyLongNamedGenericContainerTypeForTesting(i32))` at all"), + .labels = {MakeLabel(LabelCategory::Info, routed_at(3, 7), "callee")}}; + EXPECT_THAT(Render(capabilities, diagnostic), + Eq(" ╭─┤ foo.carbon:2:11\n" + "-> 2 │ NeedsIt(\"definitely not the right type\");\n" + " · ───┬─── ━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━\n" + " · ┏━━━━━━━━━━━━━━━━━━━━━━━━┛\n" + " · ┃ error: type `str` does not implement interface\n" + " · ┃ `Core.ImplicitAs(" + "ExtremelyLongNamedGenericContainerTypeForTesting(i32))`\n" + " · ┃ at all\n" + " · ╰──────────────────────┤ callee\n" + " ╰────\n" + "")); +} + +TEST(RendererTest, ALabelLineSkipsARoutedLabelsRows) { + // A routed label's text spans the full width, so the label line of a later + // label skips its rows and resumes below them. Terminal::Capabilities capabilities = { .charset = Terminal::Charset::Utf8, .is_terminal = true, .columns = 80}; Diagnostic diagnostic = { @@ -2427,19 +2642,20 @@ TEST(RendererTest, AConnectorCrossingARoutedLabelYieldsToItsWords) { MakeLabel(LabelCategory::Info, At(4, 3, 1), "left words"), MakeLabel(LabelCategory::Info, At(4, 8, 2), "`AnExtremelyLongUnbreakableGenericTypeNameForTesting(" - "AnExtremelyLongUnbreakableGenericTypeNameForTesting)`")}}; + "AnExtremelyLongUnbreakableGenericTypeNameForTesting)`"), + MakeLabel(LabelCategory::Info, At(4, 10, 1), "right words")}}; EXPECT_THAT(Render(capabilities, diagnostic), - Eq("error: bad call\n" - " ╭─┤ foo.carbon:4:3\n" - " ┆\n" + Eq(" ╭─┤ foo.carbon:4:3\n" "-> 4 │ Run0(1);\n" - " · ┬ ┬─\n" - " · ╭─┼────╯\n" + " · ┳ ┬╴╷\n" + " · ┗━━━━━━━━━┫ error: bad call\n" + " · ╰───────────┤ left words\n" + " · ╭──────╯ │\n" " · │ " "`AnExtremelyLongUnbreakableGenericTypeNameForTesting(" "AnExtremelyLongUnbreakableGenericTypeNameForTesting)`\n" - " · ╰──┤ left words\n" - " ╰────────────\n" + " · ╰──────┤ right words\n" + " ╰────\n" "")); } diff --git a/toolchain/diagnostics/testdata/fail_diagnostics_demo.carbon b/toolchain/diagnostics/testdata/fail_diagnostics_demo.carbon new file mode 100644 index 000000000000..dfe2e63bc296 --- /dev/null +++ b/toolchain/diagnostics/testdata/fail_diagnostics_demo.carbon @@ -0,0 +1,150 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon +// ARGS: --include-diagnostic-kind --diagnostic-snippets --terminal-unicode=always compile --phase=check %s +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/diagnostics/testdata/fail_diagnostics_demo.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/diagnostics/testdata/fail_diagnostics_demo.carbon + +// A tour of how diagnostics are drawn. None of the code below is meant to +// compile: every line is here to pull a different part of the rendering into +// the output. See /toolchain/docs/diagnostics_rendering.md for what each part +// is and why it looks the way it does. +// +// This is an ordinary Carbon file, so it runs outside the test suite too: +// +// carbon compile --include-diagnostic-kind --terminal-unicode=always \ +// --phase=check toolchain/diagnostics/testdata/fail_diagnostics_demo.carbon +// +// The `CHECK` lines below are that output, captured, so the tour reads without +// running anything. With no terminal to measure, layout targets the width code +// is formatted to, so the fitting behaviors appear here too: a long source +// line windowed to fit, a label line slid left inside its range, and a label +// wrapped inside its frame are all below. What can't appear is anything that +// needs a real terminal's width -- an out-dented label needs a narrower +// terminal than the fixed target; `renderer_test` covers it. A diagnostic +// reaching into a second file, with the import path drawn above it, needs a +// library to import and so isn't here either. +// +// What each line is for: +// +// - `Blend(1)`: a label elsewhere in the same file, shown with the error in +// one view of the file, with the lines between them elided. +// - `Blend(0, "...")`: a context leading the diagnostic, so the message is read +// against the code as a label. The underline is measured in columns rather +// than bytes. +// - `Cpp.Paint(0)`: a diagnostic from Clang, drawn here rather than by Clang. +// It is located at the callee the message names, as Clang does, and its note +// becomes two labels: the candidate considered, on its name, and what was +// wrong with it, on the parameters the count it reports came from. +// - `missing`: the message placed under its own range with nothing else on +// the line, which is the common case. The warning below it has the same +// shape on the binding it initializes. +// - `count * flag`: the message placed under the whole expression it reports, +// which is a binary operator and both its operands. The other two errors on +// this line are separate diagnostics, so each is drawn in its own frame, +// which shows the line again. +// - `cell[n]`: the same shape for an index, with the message under the object +// and the index together. +// - `-flag`: the same shape for a prefix operator, with the message under the +// operator and its operand. + +library "demo"; + +import Cpp inline ''' + void Paint(int layer, int depth); +'''; + +fn Blend(first_operand: i32, second_operand: Core.Optional(i32)); + +fn Tour(count: i32, flag: bool, cell: {.a: i32}, n: i32) -> i32 { + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE+12]]:3 + // CHECK:STDERR: 63 │ fn Blend(first_operand: i32, second_operand: Core.Optional(i32)); + // CHECK:STDERR: · ────────────────────────────────┬──────────────────────────────── + // CHECK:STDERR: · ╰──┤ calling function declared here + // CHECK:STDERR: · │ [InCallToEntity] + // CHECK:STDERR: ┆ + // CHECK:STDERR: -> 78 │ Blend(1); + // CHECK:STDERR: · ━━━━┳━━━ + // CHECK:STDERR: · ┗━━┫ error: 1 argument passed to function expecting 2 arguments + // CHECK:STDERR: · ┃ [CallArgCountMismatch] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + Blend(1); + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE+16]]:12 + // CHECK:STDERR: 63 │ fn Blend(first_operand: i32, second_operand: Core.Optional(i32)); + // CHECK:STDERR: · ───────────────┬────────────────── + // CHECK:STDERR: · ╰──┤ initializing function parameter + // CHECK:STDERR: · │ [InCallToFunctionParam] + // CHECK:STDERR: ┆ + // CHECK:STDERR: -> 95 │ Blend(0, "全角文字の幅も列で数えるので、下線はずれず、長すぎる行は両端を... + // CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + // CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `str` to + // CHECK:STDERR: · │ ┃ `Core.Optional(i32 as Core.OptionalStorage)` + // CHECK:STDERR: · │ ┃ [ConversionFailure] + // CHECK:STDERR: · ╰────┤ type `str` does not implement interface + // CHECK:STDERR: · │ `Core.ImplicitAs(Core.Optional(i32 as Core.OptionalStorage))` + // CHECK:STDERR: · │ [MissingImplInMemberAccessInContext] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + Blend(0, "全角文字の幅も列で数えるので、下線はずれず、長すぎる行は両端を切り詰めて窓のように表示されます"); + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE+13]]:3 + // CHECK:STDERR: 60 │ void Paint(int layer, int depth); + // CHECK:STDERR: · ┬ ──────────┬───────── + // CHECK:STDERR: · ╰──────────────────┤ candidate function not viable [CppInteropParseNote] + // CHECK:STDERR: · ╰────┤ requires 2 arguments, but 1 was provided + // CHECK:STDERR: · │ [CppInteropParseNoteReason] + // CHECK:STDERR: ┆ + // CHECK:STDERR: -> 109 │ Cpp.Paint(0); + // CHECK:STDERR: · ━━━━┳━━━━ + // CHECK:STDERR: · ┗━━┫ error: no matching function for call to 'Paint' + // CHECK:STDERR: · ┃ [CppInteropParseError] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + Cpp.Paint(0); + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE+6]]:19 + // CHECK:STDERR: -> 116 │ var tint: i32 = missing; + // CHECK:STDERR: · ━━━┳━━━ + // CHECK:STDERR: · ┗━━┫ error: name `missing` not found [NameNotFound] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + var tint: i32 = missing; + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE+32]]:10 + // CHECK:STDERR: -> 149 │ return count * flag + cell[n] + -flag; + // CHECK:STDERR: · ┳━━━━━━━━━━━ + // CHECK:STDERR: · ┗━━┫ error: cannot access member of interface `Core.MulWith(bool)` in + // CHECK:STDERR: · ┃ type `i32` that does not implement that interface + // CHECK:STDERR: · ┃ [MissingImplInMemberAccess] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE+24]]:25 + // CHECK:STDERR: -> 149 │ return count * flag + cell[n] + -flag; + // CHECK:STDERR: · ┳━━━━━━ + // CHECK:STDERR: · ┗━━┫ error: cannot access member of interface + // CHECK:STDERR: · ┃ `Core.IndexWith(i32)` in type `{.a: i32}` + // CHECK:STDERR: · ┃ that does not implement that interface + // CHECK:STDERR: · ┃ [MissingImplInMemberAccess] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE+15]]:35 + // CHECK:STDERR: -> 149 │ return count * flag + cell[n] + -flag; + // CHECK:STDERR: · ┳━━━━ + // CHECK:STDERR: · ┗━━┫ error: cannot access member of interface + // CHECK:STDERR: · ┃ `Core.Negate` in type `bool` that + // CHECK:STDERR: · ┃ does not implement that interface + // CHECK:STDERR: · ┃ [MissingImplInMemberAccess] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + // CHECK:STDERR: ╭─┤ fail_diagnostics_demo.carbon:[[@LINE-27]]:7 + // CHECK:STDERR: -> 116 │ var tint: i32 = missing; + // CHECK:STDERR: · ━━━━┳━━━━ + // CHECK:STDERR: · ┗━━┫ warning: binding `tint` unused [UnusedBinding] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + return count * flag + cell[n] + -flag; +} diff --git a/toolchain/diagnostics/testdata/fail_recovery_demo.carbon b/toolchain/diagnostics/testdata/fail_recovery_demo.carbon new file mode 100644 index 000000000000..385a6dbaf6f4 --- /dev/null +++ b/toolchain/diagnostics/testdata/fail_recovery_demo.carbon @@ -0,0 +1,83 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon +// ARGS: --include-diagnostic-kind --diagnostic-snippets --terminal-unicode=always compile --phase=parse %s +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/diagnostics/testdata/fail_recovery_demo.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/diagnostics/testdata/fail_recovery_demo.carbon + +// A tour of how a missing token is drawn, which is the case where nothing in +// the source is wrong: what the reader needs is not a range to look at but a +// place to put something. See /toolchain/docs/diagnostics_rendering.md for +// the rendering. +// +// The rule is that the message is located at the token the parser found where +// the missing one should be, which is the first token after the gap. That token +// is underlined like any other range, so the place to put the missing token is +// its left edge. When it is the end of the file, the message is located just +// past the last token, which covers no text and is drawn as a lone `┳`. +// +// This is a parse-phase tour, so nothing here reaches checking. What each line +// is for: +// +// - `fn Paint`: a separator missing between two elements of a list, located at +// the first token of the element after the gap. +// - `if true`: an opening delimiter missing after its introducer, located at +// the token after the introducer. +// - `var n`: the lexer inserting a `)` to recover, which the label reports, +// because everything reported after that point is about that reading of the +// file rather than about what was written. +// - `class Widget`: a `;` missing at the end of a declaration, which is the +// case where the next token is the end of the file, so the message is drawn +// as a point just past `Widget`. This is last in the file because recovery +// skips to what looks like the end of the declaration, which consumes +// everything after it. + +library "recovery_demo"; + +// CHECK:STDERR: ╭─┤ fail_recovery_demo.carbon:[[@LINE+7]]:17 +// CHECK:STDERR: -> 50 │ fn Paint(a: i32 b: i32); +// CHECK:STDERR: · ┳ +// CHECK:STDERR: · ┗━━┫ error: expected `,` or `)` +// CHECK:STDERR: · ┃ [UnexpectedTokenAfterListElement] +// CHECK:STDERR: ╰──── +// CHECK:STDERR: +fn Paint(a: i32 b: i32); + +fn Blend() { + // CHECK:STDERR: ╭─┤ fail_recovery_demo.carbon:[[@LINE+6]]:6 + // CHECK:STDERR: -> 59 │ if true { } + // CHECK:STDERR: · ━━┳━ + // CHECK:STDERR: · ┗━━┫ error: expected `(` after `if` [ExpectedParenAfter] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + if true { } +} + +fn Tint() { + // CHECK:STDERR: ╭─┤ fail_recovery_demo.carbon:[[@LINE+9]]:16 + // CHECK:STDERR: -> 72 │ var n: i32 = (1; + // CHECK:STDERR: · ┳ ┬ + // CHECK:STDERR: · ┗━━━━┫ error: opening symbol without a corresponding closing + // CHECK:STDERR: · │ ┃ symbol + // CHECK:STDERR: · │ ┃ [UnmatchedOpening] + // CHECK:STDERR: · ╰────┤ possibly missing `)` here [PossiblyMissingBracketHere] + // CHECK:STDERR: ╰──── + // CHECK:STDERR: + var n: i32 = (1; +} + +// CHECK:STDERR: ╭─┤ fail_recovery_demo.carbon:[[@LINE+8]]:13 +// CHECK:STDERR: -> 83 │ class Widget +// CHECK:STDERR: · ┳ +// CHECK:STDERR: · ┗━━┫ error: `class` declarations must either end with a `;` or have +// CHECK:STDERR: · ┃ a `{ ... }` block for a definition +// CHECK:STDERR: · ┃ [ExpectedDeclSemiOrDefinition] +// CHECK:STDERR: ╰──── +// CHECK:STDERR: +class Widget diff --git a/toolchain/diagnostics/testdata/fail_rendering.carbon b/toolchain/diagnostics/testdata/fail_rendering.carbon index 627303d5f6be..33f63bd4a49c 100644 --- a/toolchain/diagnostics/testdata/fail_rendering.carbon +++ b/toolchain/diagnostics/testdata/fail_rendering.carbon @@ -20,19 +20,17 @@ library "[[@TEST_NAME]]"; fn F() { - // CHECK:STDERR: error: name `missing` not found [NameNotFound] - // CHECK:STDERR: .-| fail_one_message.carbon:[[@LINE+13]]:23 - // CHECK:STDERR: : - // CHECK:STDERR: -> 19 | var unused_x: i32 = missing; - // CHECK:STDERR: : ------- - // CHECK:STDERR: '------------ + // CHECK:STDERR: .-| fail_one_message.carbon:[[@LINE+12]]:23 + // CHECK:STDERR: -> 17 | var unused_x: i32 = missing; + // CHECK:STDERR: : ^^^^^^^ + // CHECK:STDERR: : '--| error: name `missing` not found [NameNotFound] + // CHECK:STDERR: '---- // CHECK:STDERR: - // CHECK:STDERR: warning: binding `unused_x` unused [UnusedBinding] // CHECK:STDERR: .-| fail_one_message.carbon:[[@LINE+6]]:7 - // CHECK:STDERR: : - // CHECK:STDERR: -> 19 | var unused_x: i32 = missing; - // CHECK:STDERR: : ------------- - // CHECK:STDERR: '------------ + // CHECK:STDERR: -> 17 | var unused_x: i32 = missing; + // CHECK:STDERR: : ^^^^^^^^^^^^^ + // CHECK:STDERR: : '--| warning: binding `unused_x` unused [UnusedBinding] + // CHECK:STDERR: '---- // CHECK:STDERR: var unused_x: i32 = missing; } @@ -44,16 +42,16 @@ library "[[@TEST_NAME]]"; fn G() {} fn H() { - // CHECK:STDERR: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch] - // CHECK:STDERR: .-| fail_note_in_same_file.carbon:[[@LINE+10]]:3 - // CHECK:STDERR: : + // CHECK:STDERR: .-| fail_note_in_same_file.carbon:[[@LINE+11]]:3 // CHECK:STDERR: 4 | fn G() {} // CHECK:STDERR: : ----.--- // CHECK:STDERR: : '--| calling function declared here [InCallToEntity] // CHECK:STDERR: : // CHECK:STDERR: -> 18 | G(1); - // CHECK:STDERR: : ---- - // CHECK:STDERR: '------------ + // CHECK:STDERR: : ^^^^ + // CHECK:STDERR: : '--| error: 1 argument passed to function expecting 0 arguments + // CHECK:STDERR: : | [CallArgCountMismatch] + // CHECK:STDERR: '---- // CHECK:STDERR: G(1); } @@ -68,19 +66,18 @@ fn Wide() { // // // - // CHECK:STDERR: error: name `also_missing` not found [NameNotFound] // CHECK:STDERR: .-| fail_wide_line_numbers.carbon:[[@LINE+13]]:23 - // CHECK:STDERR: : - // CHECK:STDERR: -> 24 | var unused_y: i32 = also_missing; - // CHECK:STDERR: : ------------ - // CHECK:STDERR: '------------ + // CHECK:STDERR: -> 23 | var unused_y: i32 = also_missing; + // CHECK:STDERR: : ^^^^^^^^^^^^ + // CHECK:STDERR: : '--| error: name `also_missing` not found + // CHECK:STDERR: : | [NameNotFound] + // CHECK:STDERR: '---- // CHECK:STDERR: - // CHECK:STDERR: warning: binding `unused_y` unused [UnusedBinding] // CHECK:STDERR: .-| fail_wide_line_numbers.carbon:[[@LINE+6]]:7 - // CHECK:STDERR: : - // CHECK:STDERR: -> 24 | var unused_y: i32 = also_missing; - // CHECK:STDERR: : ------------- - // CHECK:STDERR: '------------ + // CHECK:STDERR: -> 23 | var unused_y: i32 = also_missing; + // CHECK:STDERR: : ^^^^^^^^^^^^^ + // CHECK:STDERR: : '--| warning: binding `unused_y` unused [UnusedBinding] + // CHECK:STDERR: '---- // CHECK:STDERR: var unused_y: i32 = also_missing; } @@ -98,19 +95,17 @@ library "[[@TEST_NAME]]"; import library "declared"; fn Use() { - // CHECK:STDERR: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch] - // CHECK:STDERR: .-| fail_across_files.carbon:[[@LINE+13]]:3 + // CHECK:STDERR: .-| fail_across_files.carbon:[[@LINE+12]]:3 + // CHECK:STDERR: -> 19 | Declared(1); + // CHECK:STDERR: : ^^^^^^^^^^^ + // CHECK:STDERR: : '--| error: 1 argument passed to function expecting 0 arguments + // CHECK:STDERR: : | [CallArgCountMismatch] // CHECK:STDERR: : - // CHECK:STDERR: -> 21 | Declared(1); - // CHECK:STDERR: : ----------- - // CHECK:STDERR: |------------ - // CHECK:STDERR: | .-- imported from: fail_across_files.carbon:[[@LINE-9]]:1 [InImport] // CHECK:STDERR: |-| declared.carbon:4:1 - // CHECK:STDERR: : // CHECK:STDERR: 4 | fn Declared(); // CHECK:STDERR: : -------.------ // CHECK:STDERR: : '--| calling function declared here [InCallToEntity] - // CHECK:STDERR: '------------ + // CHECK:STDERR: '---- // CHECK:STDERR: Declared(1); } @@ -119,13 +114,14 @@ fn Use() { library "[[@TEST_NAME]]"; -// CHECK:STDERR: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch] -// CHECK:STDERR: .-| fail_two_spans_on_one_line.carbon:[[@LINE+7]]:27 -// CHECK:STDERR: : -// CHECK:STDERR: -> 12 | fn Same() {} fn Twice() { Same(1); } -// CHECK:STDERR: : -----.----- ------- -// CHECK:STDERR: : '--| calling function declared here [InCallToEntity] -// CHECK:STDERR: '------------ +// CHECK:STDERR: .-| fail_two_spans_on_one_line.carbon:[[@LINE+9]]:27 +// CHECK:STDERR: -> 13 | fn Same() {} fn Twice() { Same(1); } +// CHECK:STDERR: : -----.----- ^^^^^^^ +// CHECK:STDERR: : | '--| error: 1 argument passed to function expecting 0 +// CHECK:STDERR: : | | arguments +// CHECK:STDERR: : | | [CallArgCountMismatch] +// CHECK:STDERR: : '-------------------------| calling function declared here [InCallToEntity] +// CHECK:STDERR: '---- // CHECK:STDERR: fn Same() {} fn Twice() { Same(1); } @@ -134,19 +130,19 @@ fn Same() {} fn Twice() { Same(1); } library "[[@TEST_NAME]]"; fn Wide() { - // CHECK:STDERR: error: name `Core.String` implicitly referenced here, but not found [CoreNameNotFound] - // CHECK:STDERR: .-| fail_non_ascii_source.carbon:[[@LINE+13]]:19 - // CHECK:STDERR: : + // CHECK:STDERR: .-| fail_non_ascii_source.carbon:[[@LINE+14]]:19 // CHECK:STDERR: -> 19 | var text: i32 = "<96><95><8C>"; - // CHECK:STDERR: : -------------------------- - // CHECK:STDERR: '------------ + // CHECK:STDERR: : ^^^^^^^^^^^^^^^^^^^^^^^^^^ + // CHECK:STDERR: : '--| error: name `Core.String` implicitly referenced here, but + // CHECK:STDERR: : | not found + // CHECK:STDERR: : | [CoreNameNotFound] + // CHECK:STDERR: '---- // CHECK:STDERR: - // CHECK:STDERR: warning: binding `text` unused [UnusedBinding] // CHECK:STDERR: .-| fail_non_ascii_source.carbon:[[@LINE+6]]:7 - // CHECK:STDERR: : // CHECK:STDERR: -> 19 | var text: i32 = "<96><95><8C>"; - // CHECK:STDERR: : --------- - // CHECK:STDERR: '------------ + // CHECK:STDERR: : ^^^^^^^^^ + // CHECK:STDERR: : '--| warning: binding `text` unused [UnusedBinding] + // CHECK:STDERR: '---- // CHECK:STDERR: var text: i32 = "世界"; } @@ -156,19 +152,18 @@ fn Wide() { library "[[@TEST_NAME]]"; fn Tabbed() { -// CHECK:STDERR: error: name `nowhere` not found [NameNotFound] // CHECK:STDERR: .-| fail_tab_indented.carbon:[[@LINE+13]]:26 -// CHECK:STDERR: : -// CHECK:STDERR: -> 19 | var also_missing: i32 = nowhere; -// CHECK:STDERR: : ------- -// CHECK:STDERR: '------------ +// CHECK:STDERR: -> 18 | var also_missing: i32 = nowhere; +// CHECK:STDERR: : ^^^^^^^ +// CHECK:STDERR: : '--| error: name `nowhere` not found +// CHECK:STDERR: : | [NameNotFound] +// CHECK:STDERR: '---- // CHECK:STDERR: -// CHECK:STDERR: warning: binding `also_missing` unused [UnusedBinding] // CHECK:STDERR: .-| fail_tab_indented.carbon:[[@LINE+6]]:6 -// CHECK:STDERR: : -// CHECK:STDERR: -> 19 | var also_missing: i32 = nowhere; -// CHECK:STDERR: : ----------------- -// CHECK:STDERR: '------------ +// CHECK:STDERR: -> 18 | var also_missing: i32 = nowhere; +// CHECK:STDERR: : ^^^^^^^^^^^^^^^^^ +// CHECK:STDERR: : '--| warning: binding `also_missing` unused [UnusedBinding] +// CHECK:STDERR: '---- // CHECK:STDERR: var also_missing: i32 = nowhere; } @@ -185,21 +180,18 @@ library "[[@TEST_NAME]]"; import Cpp library "cpp_decl.h"; fn CallIt() { - // CHECK:STDERR: error: no matching function for call to 'Use' [CppInteropParseError] - // CHECK:STDERR: .-| fail_cpp_interop.carbon:[[@LINE+15]]:3 + // CHECK:STDERR: .-| fail_cpp_interop.carbon:[[@LINE+13]]:3 + // CHECK:STDERR: -> 20 | Cpp.Use(1); + // CHECK:STDERR: : ^^^^^^^ + // CHECK:STDERR: : '--| error: no matching function for call to 'Use' [CppInteropParseError] // CHECK:STDERR: : - // CHECK:STDERR: -> 23 | Cpp.Use(1); - // CHECK:STDERR: : ------- - // CHECK:STDERR: |------------ - // CHECK:STDERR: | .-- included from: fail_cpp_interop.carbon:[[@LINE-9]]:10 [InCppInclude] // CHECK:STDERR: |-| ./cpp_decl.h:3:6 - // CHECK:STDERR: : // CHECK:STDERR: 3 | void Use(Widget w, int extra); // CHECK:STDERR: : . ---------.--------- - // CHECK:STDERR: : | '--| requires 2 arguments, but 1 was provided - // CHECK:STDERR: : | | [CppInteropParseNoteReason] - // CHECK:STDERR: : '--| candidate function not viable [CppInteropParseNote] - // CHECK:STDERR: '------------ + // CHECK:STDERR: : '---------------| candidate function not viable [CppInteropParseNote] + // CHECK:STDERR: : '----| requires 2 arguments, but 1 was provided + // CHECK:STDERR: : | [CppInteropParseNoteReason] + // CHECK:STDERR: '---- // CHECK:STDERR: Cpp.Use(1); } diff --git a/toolchain/docs/diagnostics_rendering.md b/toolchain/docs/diagnostics_rendering.md index 9e0dfc9b28ad..c730d269e63f 100644 --- a/toolchain/docs/diagnostics_rendering.md +++ b/toolchain/docs/diagnostics_rendering.md @@ -74,20 +74,20 @@ and one or more **ranges** that the problem covers: the location's own, plus any the emitter added, such as the operand of an `&` that has no address to take. A range containing the location is underlined instead of the location itself, and the message's text is placed under that range; every other range -is underlined by itself. In the rendered form the text appears under the range -it marks, and in the compact form or an editor it appears by itself, so it is -worded for both. +is underlined by itself. In the rendered form the text appears under its range, +and in the compact form or an editor it appears by itself, so it is worded for +both. **Labels** are attached to the message to explain it. A label is a range of source with optional **text** saying what that range has to do with the -problem, read together with the code it marks: `declared here` is not a -sentence anyone would read alone. A label with no text marks its range and -nothing more, telling the reader to look there but not why, which is all a +problem, read together with the code it is attached to: `declared here` is not +a sentence anyone would read alone. A label with no text underlines its range +and nothing more, telling the reader to look there but not why, which is all a Clang note's ranges convey. The **path** is how the message's location was reached: an import, an `#include`, a macro expansion. Each **step** is drawn as a single -`: ` row above the anchor of the file it reached, with no +`: ` row above the location row of the file it reached, with no snippet. The emitter calls a step location information. Which code emits the message and which attaches a label is the emitter's @@ -218,61 +218,62 @@ it, under the exact range that is wrong: ``` ╷ ╭── imported from: c.carbon:2:1 path row - ├─┤ b.carbon:3:1 anchor --> 3 │ fn Shape() {} source row, marked in the margin - · ━━━━━━┳━━━━━ mark row: the mark - · ┗━━┫ error: duplicate name ... label row: connector, bar, text + ├─┤ b.carbon:3:1 location row +-> 3 │ fn Shape() {} source row, `->` in the margin + · ━━━━━━┳━━━━━ underline row: the heavy underline + · ┗━━┫ error: duplicate name ... label row: label line, bar, text ┆ elision - ├─┤ a.carbon:3:7 anchor for a second file + ├─┤ a.carbon:3:7 location row for a second file 3 │ class Shape {} source row - · ──┬── mark row + · ──┬── underline row · ╰──┤ previously declared here label row ╰──── close ``` -- The **frame** runs from the `╭` of the first anchor to the `╰────` +- The **frame** runs from the `╭` of the first location row to the `╰────` **close**. -- An **anchor**, `╭─┤ ::`, gives the location of the part - whose snippet is below it: the message's, or a label's for a file the +- A **location row**, `╭─┤ ::`, gives the location of the + part whose snippet is below it: the message's, or a label's for a file the message is not in. It is a location to go to, not the first row shown: ranges in one file share one view of it in source order, so a declaration - above the problem is drawn above the message, and the anchor's line can - name a row further down. Unknown parts of the location are omitted from - the right. The frame's first anchor starts with `╭`, any other with `├`. + above the problem is drawn above the message, and the location row's line + can name a row further down. Unknown parts of the location are omitted from + the right. The frame's first location row starts with `╭`, any other with + `├`. - A **source row** is a line of the file, numbered in the gutter. The line - the message is placed under is marked `->` in the **margin**, and its - number takes the level's color: that is where to begin reading, wherever - it is in the frame. + the message is placed under has `->` in the **margin**, and its number + takes the level's color: that is where to begin reading, wherever it is in + the frame. -- A **mark row** holds the **marks**, the underlines under ranges, with `·` - in place of the frame so the row isn't mistaken for source. The mark the - message is placed under is heavy; every other mark is light, in the - level's colors for - another of the message's ranges and the label color for a label's. - Everything marking one line goes on one row. +- An **underline row** holds the **underlines** under ranges, with `·` in + place of the frame so the row isn't mistaken for source. The underline the + message is placed under is heavy; every other underline is light, in the + level's colors for another of the message's ranges and the label color for a + label's. Every underline for one line goes on one row. -- A **label row** holds the text placed under a mark: a **connector** leaves - the mark at a tee and meets the **bar** framing the text, `╰──┤`. The - message's row is a label row beginning with the **level word**, `error:`, - with bold text and a heavy connector and bar. +- A **label row** holds the text placed under an underline: a **label line** + leaves the underline at a tee and meets the **bar** framing the text, + `╰──┤`. The message's row is a label row beginning with the **level word**, + `error:`, with bold text and a heavy label line and bar. - An **elision row**, `┆`, continues the frame as a dotted line across - whatever isn't contiguous: skipped lines, or the step to the next anchor. A - single skipped line is shown instead, which takes the same number of rows. + whatever isn't contiguous: skipped lines, or the step to the next location + row. A single skipped line is shown instead, which takes the same number of + rows. -- A **path row**, `╭── : `, is drawn above an anchor and +- A **path row**, `╭── : `, is drawn above a location row and states how that file was reached, its line continuing down into the - anchor's bracket. + location row's bracket. - A part with **no source**, because its location names only a file or nothing - at all, is the fallback. It still gets an anchor, naming what location it - has or ``, and its text is placed under the anchor instead of - under a mark, starting at the source's first column. A message's text is - placed the same way, beginning with the level word, with the `->` on its - anchor, and the file's other ranges follow under that anchor past an - elision: + at all, is the fallback. It still gets a location row, naming what location + it has or ``, and its text is placed under the location row + instead of under an underline, starting at the source's first column. A + message's text is placed the same way, beginning with the level word, with + the `->` on its location row, and the file's other ranges follow under that + location row past an elision: ``` -> ╭─┤ thunk.carbon @@ -295,50 +296,52 @@ it, under the exact range that is wrong: ### Finding the message There is no headline. Everything that makes the message findable is on its own -row: the level word, its weight and color, the heavy mark, and the `->` in the -margin of its line. With color the red `error:` is the first thing seen; -without it the `->` points to the heavy mark, whose connector runs down to the -sentence. The reading order is the same either way: the sentence and its code, -the other labels as needed, and the anchors as the coordinates for going there. +row: the level word, its weight and color, the heavy underline, and the `->` in +the margin of its line. With color the red `error:` is the first thing seen; +without it the `->` points to the heavy underline, whose label line runs down to +the sentence. The reading order is the same either way: the sentence and its +code, the other labels as needed, and the location rows as the coordinates for +going there. The drawback is that the message is not at a fixed row of its frame, since a declaration above the problem is drawn first. The fixed positions to scan for in a long log are the `╭` that starts every diagnostic and the `->` in column zero, drawn once per frame on the row to begin reading at. A message with no -source to mark is placed under its anchor, and the `->` marks the anchor. +source to underline is placed under its location row, and the `->` points to +that row. One frame per diagnostic, rather than one per message, shows the reader where one problem ends and the next begins. Each file the diagnostic points into -gets an anchor inside that frame, and the frame continues as a dotted `┆` +gets a location row inside that frame, and the frame continues as a dotted `┆` rather than breaking. The message is placed under its location's range unless another of its ranges contains that location, in which case that range is used instead: the location is a point chosen for a cursor, and the range shows what the problem covers. -Overlapping ranges are drawn widest first, so the narrowest mark on a column is -the one left visible, except that the heavy mark is drawn last so nothing -repaints it. A range inside it appears only as the tee where its connector -leaves the heavy stroke, or not at all if it has no text. +Overlapping ranges are drawn widest first, so the narrowest underline on a +column is the one left visible, except that the heavy underline is drawn last so +nothing repaints it. A range inside it appears only as the tee where its label +line leaves the heavy underline, or not at all if it has no text. ### Placing the text -The rows under a mark row hold the text placed under its marks, laid out by -these rules in this order. +The rows under an underline row hold the text placed under its underlines, laid +out by these rules in this order. **Order.** The rows read top to bottom the way the code reads left to right: the message first, then each label in the order of its range. Each label's text starts two columns right of the text above, so the indentation steps with the order. -**Meeting the text.** A connector reaches the bar on the first row of its text, +**Meeting the text.** A label line reaches the bar on the first row of its text, where the level word is, so following the heavy line arrives at the start of the sentence. The bar continues down every row the text wraps onto. **Placement.** Every label's text, the message's included, starts right of every -connector's column, so a connector descending to a later label runs beside the +label line's column, so a label line descending to a later label runs beside the text above it, never behind it. -**Crossings.** Reading order makes a later connector descend through rows +**Crossings.** Reading order makes a later label line descend through rows already drawn. Earlier rows keep what they drew: the descending line breaks around each run it meets in a single cell, never at a junction, and the gap shows that the two don't connect. On a terminal wide enough that nothing wraps @@ -346,33 +349,33 @@ this is the common shape: a label right of a one-row message descends `┬`, a gap, `╰`, with no vertical cell showing. The tee and the corner are what show the connection. -**Out-dented blocks.** Text that does not fit under its mark, because its -widest word does not fit right of the connector, is out-dented to the source's +**Out-dented blocks.** Text that does not fit under its underline, because its +widest word does not fit right of the label line, is out-dented to the source's column (see [Fitting the terminal](#fitting-the-terminal)). A block occupies -its rows entirely, blank cells included, so a connector descending past it +its rows entirely, blank cells included, so a label line descending past it skips those rows and resumes below. **Quoted code.** Wrapping breaks at spaces, except inside backticks: a quoted type or snippet moves to the next row whole or extends past the edge like a path. -A mark and the connector and bar of its label take the color of the message they -belong to, following `rustc`; the label's text does not, since color belongs on -what it points at. Only the message's marks are heavy and bold: the heavy -strokes supply the emphasis where a terminal ignores bold on line art, and bold -matches the marks to the text where it doesn't. +An underline and the label line and bar of its label take the color of the +message they belong to, following `rustc`; the label's text does not, since +color belongs on what it points at. Only the message's underlines are heavy and +bold: the heavy stroke weight supplies the emphasis where a terminal ignores +bold on line art, and bold matches the underlines to the text where it doesn't. Ranges that touch would run together, so an end that meets another range stops at the center of its cell, leaving a gap, but only where the range still has a -column for its label's connector. A one-column mark that gives up an end has -nothing to tee into, so its connector is drawn down the column in place of it, -from the cell's center, and two such columns side by side look like two marks. -ASCII has no half cell, so it does not draw the gap. +column for its label line. A one-column underline that gives up an end has +nothing to tee into, so its label line is drawn down the column in place of it, +from the cell's center, and two such columns side by side look like two +underlines. ASCII has no half cell, so it does not draw the gap. ### Several files in one diagnostic -Each file a diagnostic points into gets an anchor, in the order the parts reach -it, and the frame runs down through all of them. +Each file a diagnostic points into gets a location row, in the order the parts +reach it, and the frame runs down through all of them. Only the path to the problem itself is drawn: the message's own location, never a label's. How the file holding a declaration was reached is rarely useful to @@ -410,49 +413,49 @@ Sixty columns is a guess; nothing depends on it being right. Clang's diagnostics are drawn here rather than by Clang. Its message, location, ranges, and fix-its each become the thing they correspond to. A location names a -point and is marked as the one column Clang's caret marks; a range containing -that point is used instead, the `~~~` of `^~~~`, so the text is placed under the -whole range. The diagnostic's other ranges are the message's, in the level's -color; a note's are labels with no text, in the label color, as Clang would draw -them. A fix-it becomes a label saying what to do, which is still shown in the -compact form, where an inline rendering would not be; carrying the edit as data -is [future work](#future-work). +point and is underlined as the one column Clang's caret points to; a range +containing that point is used instead, the `~~~` of `^~~~`, so the text is +placed under the whole range. The diagnostic's other ranges are the message's, +in the level's color; a note's are labels with no text, in the label color, as +Clang would draw them. A fix-it becomes a label saying what to do, which is +still shown in the compact form, where an inline rendering would not be; +carrying the edit as data is [future work](#future-work). `SemIR::ConvertClangRangeToLoc` turns a Clang range into the location the renderer needs, on both the path with a Carbon `Context` and the one without. Several notes on one line share its source row, each placed under its own -mark. +underline. Overload-resolution candidate notes are written as -`: ` and mark the source the second -half is about, so each becomes two labels: the candidate on the declaration the -note names, and the reason on what Clang marked. The notes split are listed by -kind, since any note might contain a colon. Moving the split upstream is -[future work](#future-work). +`: ` and are located at the +source the second half is about, so each becomes two labels: the candidate on +the declaration the note names, and the reason on the source Clang located it +at. The notes split are listed by kind, since any note might contain a colon. +Moving the split upstream is [future work](#future-work). The `#include` and macro expansion stacks arrive as location information and read `included from`, `imported from module at`, and `expanded from macro -defined at` above the anchor of the message's own location. They are left out -for a note, as Clang leaves them out. +defined at` above the location row of the message's own location. They are left +out for a note, as Clang leaves them out. ## Style ### The palette -Styles are named for what they mark, so changing a color is one edit. +Styles are named for what they apply to, so changing a color is one edit. | Element | Style | Rationale | | :--------------------------- | :-------------------- | :------------------------------------------------------------------------------------------ | | `error` | bold, bright red | Clang, GCC, and `rustc` agree. | | `warning` | bold, bright yellow | `rustc`'s choice and the conventional caution color; Clang and GCC use magenta. | -| `note` | bold, bright cyan | GCC's choice; distinct from error and warning at any brightness. Begins a label's line in the compact form; in the frame a label's text is placed under its mark or anchor with no level word. | +| `note` | bold, bright cyan | GCC's choice; distinct from error and warning at any brightness. Begins a label's line in the compact form; in the frame a label's text is placed under its underline or location row with no level word. | | Message | bold, no color | The longest run of text; color belongs on what it points at. Bold only when placed under code. | | Frame | bold, bright blue | `rustc`'s choice. Not dim, which several terminals don't implement. | | Line numbers | bright blue | Not bold, so the one number colored as the reported line stands out. | -| Location in an anchor | plain | The bracket already delimits it. | +| Location in a location row | plain | The bracket already delimits it. | | Location in the compact form | bold | Begins the line with nothing around it. | -| The message's marks | the level color, bold | Makes the range and the sentence one unit. | -| A label's marks and connectors | the label ramp | Connects a mark to its text. Not bold or heavy: that emphasis is the message's alone. | +| The message's underlines | the level color, bold | Makes the range and the sentence one unit. | +| A label's underlines and label lines | the label ramp | Connects an underline to its text. Not bold or heavy: that emphasis is the message's alone. | | Path | dim | How the reader got here, not what is wrong. | | Kind | dim | Only present under a flag. | @@ -469,9 +472,9 @@ express more, colors are given as RGB, and each theme gets a ramp of three: A ramp is assigned darker, center, lighter, so several ranges on one line read as a progression; a range with no others of its theme beside it takes the -center. The mark the message is placed under always takes the center, and its -other ranges on that line take successive colors from the ramp, with the center -left out. +center. The underline the message is placed under always takes the center, and +its other ranges on that line take successive colors from the ramp, with the +center left out. The three centers are at one lightness: bright yellow is over four times the luminance of bright red, which would make a warning brighter than an error, and @@ -487,40 +490,41 @@ rendered without dim would make the frame as prominent as the code. ### Character set -| Element | `Charset::Utf8` | `Charset::Ascii` | -| :-------------------------- | :---------------- | :----------------------- | -| Frame and connectors | `│ ╭ ├ ╰ ─ ┤ ╯` | `\| . \| ' - \| '` | -| Frame stub above a path row | `╷` | `\|` | -| Mark and label rows' frame | `·` | `:` | -| Elision | `┆` | `:` | -| Light marks | `─ ┬ ╷ ╴ ╶` | `- . \| - -` | -| The message's marks | `━ ┳ ┗ ┫ ┃ ╻ ╸ ╺` | `^ ^ ' \| \| ^ ^ ^` | -| Out-dented message's reach | `┏ ┛` | `. '` | -| A label's tee on the heavy | `┯` | `.` | -| The margin's pointer | `->` | `->` | +| Element | `Charset::Utf8` | `Charset::Ascii` | +| :------------------------------ | :---------------- | :----------------------- | +| Frame and label lines | `│ ╭ ├ ╰ ─ ┤ ╯` | `\| . \| ' - \| '` | +| Frame's start above a path row | `╷` | `\|` | +| Underline and label rows' frame | `·` | `:` | +| Elision | `┆` | `:` | +| Light underlines | `─ ┬ ╷ ╴ ╶` | `- . \| - -` | +| The message's underlines | `━ ┳ ┗ ┫ ┃ ╻ ╸ ╺` | `^ ^ ' \| \| ^ ^ ^` | +| Out-dented message's reach | `┏ ┛` | `. '` | +| A label's tee on the heavy | `┯` | `.` | +| The margin's pointer | `->` | `->` | -The last two light marks and the last two heavy ones are ends that stop at the -center of their cell, the gap between touching ranges. +The last two light underline glyphs and the last two heavy ones are ends that +stop at the center of their cell, the gap between touching ranges. Everything is drawn as lines through `Terminal::Buffer`, which picks the glyph -for the character set and forms corners and tees where lines meet, so a -connector joins an underline at a junction and a light connector on the heavy +for the character set and forms corners and tees where lines meet, so a label +line joins an underline at a junction and a light label line on the heavy underline forms `┯`. Each glyph is one column in both character sets, so the -frame occupies the same columns. A label's connector never joins the message's: -sharing its column it leaves the shared stretch heavy, and crossing its rows it -gaps. +frame occupies the same columns. No other label line joins the message's: +sharing its column one leaves the shared stretch heavy, and crossing its rows +one gaps. -ASCII has no weights, so weight degrades to one distinction. A cell holding a -heavy stroke that no line enters from above is `^`, the emphatic underline C++ -compilers have long used: the heavy run, the tee the message's own connector -leaves it by, and a one-column mark that the connector replaces. The connector -below keeps a label's strokes. A light tee degrades to `.`, the corner for a -line leaving downward, on a light run or the heavy one: the dashes either side -draw the through-stroke, and the branch is the only thing marking the connection -when the connector below may be rows away with only gaps between. `+` is a -crossing where lines connect, which a diagnostic never draws. +ASCII has no weights, so weight degrades to one distinction. A cell with a heavy +line leaving it that no line enters from above is `^`, the emphatic underline +C++ compilers have long used: the heavy underline, the tee where the message's +own label line leaves it, and a one-column underline that the label line +replaces. Below that cell the label line is drawn as a light line, as a label's +is. A light tee degrades to `.`, the corner for a line leaving downward, on a +light underline or the heavy one: the dashes either side draw the underline, and +the `.` is the only thing showing where the label line leaves it when the rest +of the label line may be rows away with only gaps between. `+` is a crossing +where lines connect, which a diagnostic never draws. -A run of `~` provides no junction for a connector to join, and Unicode has no +A run of `~` provides no junction for a label line to join, and Unicode has no one-column wavy character. A glyph also has to be one column in practice, not only by the width tables: a terminal that counts one as two cells shifts the rest of its row, and in the margin that puts the source a column off from its @@ -533,8 +537,8 @@ something other than color, so plain output loses appearance and no information. ## Fitting the terminal -Nothing a diagnostic says is ever dropped; source outside a marked range is what -gets elided. The width comes from `COLUMNS` if exported, otherwise from the +Nothing a diagnostic says is ever dropped; source outside an underlined range is +what gets elided. The width comes from `COLUMNS` if exported, otherwise from the terminal with `TIOCGWINSZ`, and otherwise is the width code is formatted to plus the gutter, so a formatted line is shown whole. @@ -548,15 +552,15 @@ the gutter, so a formatted line is shown whole. another diagnostic. Wrapping breaks only at spaces outside backticks, so a path, a URL, or a quoted type overhangs rather than splitting. -- Connectors slide left before any text wraps. Since text starts right of - every connector, making room for one label's text can require moving - several: each connector right of where the text needs to start slides +- Label lines slide left before any text wraps. Since text starts right of + every label line, making room for one label's text can require moving + several: each label line right of where the text needs to start slides within its own range, as far as the widest word requires, whichever label it belongs to. - A label whose widest word still does not fit is out-dented to the source's column, keeping its place in the reading order, with the top of - its bar turning right to reach back to its connector. Several such blocks + its bar turning right to reach back to its label line. Several such blocks stack in that order. ## Normalizing source text @@ -582,11 +586,11 @@ Generating them is the HTML target under [Future work](#future-work). The message is placed under the operator, which connects the syntax to the interface it reports missing, a rule the reader has no other way to learn. The operands are labeled with the types they contributed, since a type is nothing -the source can show. Their marks take successive colors from the label ramp, the -labels read in operand order stepping right, and the right operand's connector -runs beside the message, crossing its run in single cells. That connector is at -its range's start rather than its middle because the message's text occupies the -columns its middle would need. +the source can show. Their underlines take successive colors from the label +ramp, the labels read in operand order stepping right, and the right operand's +label line runs beside the message, crossing its line in single cells. That +label line is at its range's start rather than its middle because the message's +text occupies the columns its middle would need. ### Several files, reached by an import The problem is in an imported file, so the path by which the reader's own build -reached it draws above its anchor, dim. The declaration it collides with gets a -bare anchor, since a label's path is never drawn, and the label marks the name. +reached it draws above its location row, dim. The declaration it collides with +gets a location row with no path, since a label's path is never drawn, and the +label is attached to the name. @@ -659,9 +664,9 @@ completing a type, attached one to whatever was diagnosed inside it. ### Without color or Unicode -The message's mark degrades to `^`, every other mark to `-` with a `.` where a -label leaves it, and the `->`, the `^` run, and the level word still say where -to look first: +The message's underline degrades to `^`, every other underline to `-` with a `.` +where a label line leaves it, and the `->`, the `^` run, and the level word +still say where to look first: ``` .-| foo.carbon:4:3 @@ -689,7 +694,7 @@ Three invariants shape the code: - Everything is drawn as lines through the buffer, so every corner and tee is a junction it forms, and the ASCII fallback is whatever it draws lines - with. The message's marks are the same lines drawn heavy. + with. The message's underlines are the same lines drawn heavy. - The renderer repairs what it is given rather than failing: a range past the end of its line is clamped, a location missing parts still draws, and @@ -734,12 +739,12 @@ File tests cover the rendering end to end. `toolchain/diagnostics/testdata` keeps full numbering, and its `fail_rendering.carbon` checks the ASCII form. Every other `file_test` runs with `--terminal-unicode=always` and `--no-diagnostic-line-numbers`, so its goldens are the frames nearly every -terminal gets, with one location apiece, the leading anchor's, which autoupdate -maintains as a `[[@LINE...]]` offset. Full numbering would make a golden depend -on the positions of its own `CHECK` lines, and an anchor in a second file names -lines no offset can express. The rows above the leading anchor, the path, take -its location in `ToolchainFileTest::FinalizeCheckLines` so a frame moves as one -block. +terminal gets, with one location apiece, the leading location row's, which +autoupdate maintains as a `[[@LINE...]]` offset. Full numbering would make a +golden depend on the positions of its own `CHECK` lines, and a location row in a +second file names lines no offset can express. The rows above the leading +location row, the path, take its location in +`ToolchainFileTest::FinalizeCheckLines` so a frame moves as one block. Goldens differ from what a user sees in two ways: every file test also passes `--include-diagnostic-kind`, so a wrapped block may use an extra row that only @@ -753,16 +758,16 @@ None of this is needed for the rendering to be useful. - Removing location-less parts: everything that reaches the renderer with only a filename, such as conversions in compiler-generated thunks and C++ imports without a mapped location, restructured to carry one, and a - diagnostic about a file as a whole anchored at its start or end. + diagnostic about a file as a whole located at its start or end. - Ranges spanning several lines, which are clamped to their first line today, usually a declaration's least informative part. - Two ranges on one line too far apart to share a window. The one outside the - window is marked at its edge, over the `...`, rather than getting its own - view of the line. + window is underlined at its edge, over the `...`, rather than getting its + own view of the line. -- Marking ranges within the source row, with color on or behind the text, +- Showing ranges within the source row, with color on or behind the text, where past two or three the underlines stack faster than a reader can match them; it has to leave the row no worse to read without color. @@ -802,24 +807,24 @@ None of this is needed for the rendering to be useful. ## Alternatives considered - A headline row above the frame, as an earlier iteration did. It uses a row - to say, away from the code, what the message says better on its mark, and - splits the cues a reader finds a diagnostic by between the headline and the - mark below. It provides a fixed row to scan for, which the `╭` corner and - the margin's `->` provide instead. + to say, away from the code, what the message says better on its underline, + and splits the cues a reader finds a diagnostic by between the headline and + the underline below. It provides a fixed row to scan for, which the `╭` + corner and the margin's `->` provide instead. -- Stacking labels rightmost first, so no connector crosses another. Every +- Stacking labels rightmost first, so no label line crosses another. Every line stayed whole, but the rows read in reverse and the message could end - up mid-stack. Reading order matters more than unbroken connectors. + up mid-stack. Reading order matters more than unbroken label lines. - Meeting wrapped words at their middle row, where a brace would. A reader following the heavy line then arrives partway through the sentence. - Out-denting a label before its text fails to fit, whenever placing it under - its mark would wrap deeply. At seventy columns a message anchored far right - can wrap four ways in a twenty-column column where out-denting would give - two clean rows. Placing it under the mark is kept: out-denting adds a - reach-back row and moves the text away from its mark, and a threshold would - be one more guess. + its underline would wrap deeply. At seventy columns a message placed far + right can wrap four ways in a twenty-column column where out-denting would + give two clean rows. Placing it under the underline is kept: out-denting + adds a reach-back row and moves the text away from its underline, and a + threshold would be one more guess. - Clang and GCC's location-first header. The message is what the reader needs, and the tooling case for the location is met by the language server @@ -831,33 +836,33 @@ None of this is needed for the rendering to be useful. - A frame per file, separated by blank lines: a blank line stops meaning "next diagnostic", and it uses more rows. -- A heavier frame, with a blank row under each anchor, a rule between +- A heavier frame, with a blank row under each location row, a rule between snippets, and a full-width close. Each added a row that showed nothing the neighboring rows didn't already show. -- A path above every anchor. On anything explanatory it restates the +- A path above every location row. On anything explanatory it restates the filename, and it was the most prominent text in the frame and the least useful. - A message row, `├─ note: `, for a part with no source, as an earlier - iteration did. It was a row shorter than an anchor and its label, but a + iteration did. It was a row shorter than a location row and its label, but a form of its own, which dropped the part's filename and began with a level word no other label has. -- Closing the anchor after the location, `╭─┤ file:1:1 │`, as `ariadne` - draws it: the location then looks like a caption rather than where the - snippet comes from. +- Closing the location row's bracket after the location, `╭─┤ file:1:1 │`, as + `ariadne` draws it: the location then looks like a caption rather than where + the snippet comes from. -- Placing the path below the anchor. It only reads correctly with the steps - reversed, since each row's subject is the file named on the row above. +- Placing the path below the location row. It only reads correctly with the + steps reversed, since each row's subject is the file named on the row above. -- Underlining with `~`, as Clang does: a run of characters gives a connector +- Underlining with `~`, as Clang does: a run of characters gives a label line no junction to join, and doesn't degrade through the same line drawing as the frame. - Reverse video on the source row instead of an underline, which halves a - snippet's rows. It shows nothing without color, and the mark row is where - every connector tees in. + snippet's rows. It shows nothing without color, and the underline row is + where every label line tees in. - Emoji for the severity. They are one column in some terminals and two in others, and a font drawing one in color ignores the color asked for, which