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

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

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

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

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

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

No files matched your search

@@ -140,9 +140,23 @@ import Cpp library "int_literal.h";
fn F() {
// TODO: get rid of the second error message here.
// i128_max + 1
// CHECK:STDERR: fail_import_large_int_literal.carbon:[[@LINE+4]]:44-82: error: integer value 170141183460469231731687303715884105728 too large to fit in a signed C++ integer type; requires 129 bits, but max is 128 [IntTooLargeForCppType]
// CHECK:STDERR: ╭─┤ fail_import_large_int_literal.carbon:[[@LINE+18]]:44
// CHECK:STDERR: -> │ ...ed h: i128 = Cpp.int_literal_foo(170141183460469231731687303715884105728);
// CHECK:STDERR: · ━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: integer value 170141183460469231731687303715884105728 too large to fit
// CHECK:STDERR: · ┃ in a signed C++ integer type; requires 129 bits, but max is 128
// CHECK:STDERR: · ┃ [IntTooLargeForCppType]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
// CHECK:STDERR: fail_import_large_int_literal.carbon:[[@LINE+2]]:44-82: error: call argument of type `Core.IntLiteral` is not supported [CppCallArgTypeNotSupported]
// CHECK:STDERR: ╭─┤ fail_import_large_int_literal.carbon:[[@LINE+9]]:44
// CHECK:STDERR: -> │ ...ed h: i128 = Cpp.int_literal_foo(170141183460469231731687303715884105728);
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: call argument of type
// CHECK:STDERR: · ┃ `Core.IntLiteral` is not
// CHECK:STDERR: · ┃ supported
// CHECK:STDERR: · ┃ [CppCallArgTypeNotSupported]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let unused h: i128 = Cpp.int_literal_foo(170141183460469231731687303715884105728);
}
@@ -174,8 +188,19 @@ 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+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: ╭─┤ fail_import_negative_literal_passed_to_unsigned.carbon:[[@LINE+14]]:27
// CHECK:STDERR: -> │ Cpp.neg_to_unsigned_foo(-1);
// CHECK:STDERR: · ┳━
// CHECK:STDERR: · ┗━━┫ error: negative integer value -1 converted to
// CHECK:STDERR: · ┃ unsigned type `u32`
// CHECK:STDERR: · ┃ [NegativeIntInUnsignedType]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./negative_literal_passed_to_unsigned.h
// CHECK:STDERR: │ auto neg_to_unsigned_foo(unsigned int a) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.neg_to_unsigned_foo(-1);
}
@@ -202,8 +227,19 @@ library "[[@TEST_NAME]]";
import Cpp library "floating_point_literal.h";
fn F() {
// 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: ╭─┤ fail_import_large_floating_point_literal.carbon:[[@LINE+14]]:25
// CHECK:STDERR: -> │ Cpp.float_literal_foo(1.8e+308);
// CHECK:STDERR: · ┳━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: value 18*10^307 too large for floating-point
// CHECK:STDERR: · ┃ type `f64`
// CHECK:STDERR: · ┃ [FloatLiteralTooLargeForType]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./floating_point_literal.h
// CHECK:STDERR: │ auto float_literal_foo(double a) -> double;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.float_literal_foo(1.8e+308);
}
@@ -247,33 +283,110 @@ 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+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: ╭─┤ fail_todo_struct_init_nonempty.carbon:[[@LINE+20]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields({.a = 1, .b = 2, .c = 3});
// CHECK:STDERR: · ━━━━━━━━━━━━┳━━━━━━━━━━━
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: cannot implicitly convert expression of type
// CHECK:STDERR: · ┃ `{.a: Core.IntLiteral, .b: Core.IntLiteral, .c: Core.IntLiteral}` to
// CHECK:STDERR: · ┃ `Cpp.ThreeFields`
// CHECK:STDERR: · ┃ [ConversionFailure]
// CHECK:STDERR: · ╭─────────────────────────────────╯
// CHECK:STDERR: · │ type `{.a: Core.IntLiteral, .b: Core.IntLiteral, .c: Core.IntLiteral}` does
// CHECK:STDERR: · │ not implement interface `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields({.a = 1, .b = 2, .c = 3});
// 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: ╭─┤ fail_todo_struct_init_nonempty.carbon:[[@LINE+19]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields(value);
// CHECK:STDERR: · ┳━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `{.a: i32, .b: i32, .c: i32}` to
// CHECK:STDERR: · │ ┃ `Cpp.ThreeFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `{.a: i32, .b: i32, .c: i32}` does not
// CHECK:STDERR: · │ implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields(value);
// 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: ╭─┤ fail_todo_struct_init_nonempty.carbon:[[@LINE+19]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields(reference);
// CHECK:STDERR: · ┳━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `{.a: i32, .b: i32, .c: i32}` to
// CHECK:STDERR: · │ ┃ `Cpp.ThreeFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `{.a: i32, .b: i32, .c: i32}` does not
// CHECK:STDERR: · │ implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields(reference);
// 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: ╭─┤ fail_todo_struct_init_nonempty.carbon:[[@LINE+19]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields(MakeThreeFields());
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `{.a: i32, .b: i32, .c: i32}` to
// CHECK:STDERR: · │ ┃ `Cpp.ThreeFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `{.a: i32, .b: i32, .c: i32}` does not
// CHECK:STDERR: · │ implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields(MakeThreeFields());
// 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: ╭─┤ fail_todo_struct_init_nonempty.carbon:[[@LINE+20]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields({.b = 1, .c = 2, .a = 3});
// CHECK:STDERR: · ━━━━━━━━━━━━┳━━━━━━━━━━━
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: cannot implicitly convert expression of type
// CHECK:STDERR: · ┃ `{.b: Core.IntLiteral, .c: Core.IntLiteral, .a: Core.IntLiteral}` to
// CHECK:STDERR: · ┃ `Cpp.ThreeFields`
// CHECK:STDERR: · ┃ [ConversionFailure]
// CHECK:STDERR: · ╭─────────────────────────────────╯
// CHECK:STDERR: · │ type `{.b: Core.IntLiteral, .c: Core.IntLiteral, .a: Core.IntLiteral}` does
// CHECK:STDERR: · │ not implement interface `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields({.b = 1, .c = 2, .a = 3});
}
@@ -285,15 +398,37 @@ library "[[@TEST_NAME]]";
import Cpp library "struct_init.h";
fn F() {
// 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: ╭─┤ fail_struct_init_field_mismatch.carbon:[[@LINE+15]]:3
// CHECK:STDERR: -> │ Cpp.PassThreeFields({.a = 1, .b = 2, .c = 3, .d = 4});
// CHECK:STDERR: · ━━━━━━━━━┳━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: no matching function for call to 'PassThreeFields'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬ ┬────────────
// CHECK:STDERR: · ╰──────────────────┤ candidate function not viable [CppInteropParseNote]
// CHECK:STDERR: · ╰────┤ cannot convert initializer list argument to
// CHECK:STDERR: · │ 'ThreeFields'
// CHECK:STDERR: · │ [CppInteropParseNoteReason]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields({.a = 1, .b = 2, .c = 3, .d = 4});
// 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: ╭─┤ fail_struct_init_field_mismatch.carbon:[[@LINE+15]]:3
// CHECK:STDERR: -> │ Cpp.PassThreeFields({.a = 1, .x = 2, .c = 3});
// CHECK:STDERR: · ━━━━━━━━━┳━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: no matching function for call to 'PassThreeFields'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬ ┬────────────
// CHECK:STDERR: · ╰──────────────────┤ candidate function not viable [CppInteropParseNote]
// CHECK:STDERR: · ╰────┤ cannot convert initializer list argument to
// CHECK:STDERR: · │ 'ThreeFields'
// CHECK:STDERR: · │ [CppInteropParseNoteReason]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields({.a = 1, .x = 2, .c = 3});
}
@@ -305,7 +440,12 @@ library "[[@TEST_NAME]]";
import Cpp library "struct_init.h";
fn F() {
// CHECK:STDERR: fail_struct_init_unsupported_field_name.carbon:[[@LINE+2]]:23-33: error: field name `base` cannot be mapped into C++ [CppCallFieldNameNotSupported]
// CHECK:STDERR: ╭─┤ fail_struct_init_unsupported_field_name.carbon:[[@LINE+7]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields({.base = 1});
// CHECK:STDERR: · ━━━┳━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: field name `base` cannot be mapped into C++
// CHECK:STDERR: · ┃ [CppCallFieldNameNotSupported]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields({.base = 1});
}
@@ -322,27 +462,79 @@ import Cpp library "struct_init.h";
fn MakeEmpty() -> ();
fn Empty(value: (), ref reference: ()) {
// 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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+17]]:20
// CHECK:STDERR: -> │ Cpp.PassNoFields(());
// CHECK:STDERR: · ┳━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `()`
// CHECK:STDERR: · │ ┃ to `Cpp.NoFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `()` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.NoFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassNoFields(NoFields s) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassNoFields(());
// 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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+17]]:20
// CHECK:STDERR: -> │ Cpp.PassNoFields(value);
// CHECK:STDERR: · ┳━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `()`
// CHECK:STDERR: · │ ┃ to `Cpp.NoFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `()` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.NoFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassNoFields(NoFields s) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassNoFields(value);
// 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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+17]]:20
// CHECK:STDERR: -> │ Cpp.PassNoFields(reference);
// CHECK:STDERR: · ┳━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `()`
// CHECK:STDERR: · │ ┃ to `Cpp.NoFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `()` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.NoFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassNoFields(NoFields s) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassNoFields(reference);
// 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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+17]]:20
// CHECK:STDERR: -> │ Cpp.PassNoFields(MakeEmpty());
// CHECK:STDERR: · ┳━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `()`
// CHECK:STDERR: · │ ┃ to `Cpp.NoFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `()` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.NoFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassNoFields(NoFields s) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassNoFields(MakeEmpty());
}
@@ -350,27 +542,83 @@ 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+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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+21]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields((1, 2, 3));
// CHECK:STDERR: · ┳━━━━━━━━
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: cannot implicitly convert expression of type
// CHECK:STDERR: · ┃ `(Core.IntLiteral, Core.IntLiteral, Core.IntLiteral)` to
// CHECK:STDERR: · ┃ `Cpp.ThreeFields`
// CHECK:STDERR: · ┃ [ConversionFailure]
// CHECK:STDERR: · ╰──┤ type
// CHECK:STDERR: · │ `(Core.IntLiteral, Core.IntLiteral, Core.IntLiteral)`
// CHECK:STDERR: · │ does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields((1, 2, 3));
// 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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+17]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields(value);
// CHECK:STDERR: · ┳━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `(i32, i32, i32)` to `Cpp.ThreeFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `(i32, i32, i32)` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields(value);
// 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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+17]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields(reference);
// CHECK:STDERR: · ┳━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `(i32, i32, i32)` to `Cpp.ThreeFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `(i32, i32, i32)` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields(reference);
// 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: ╭─┤ fail_struct_init_from_tuple.carbon:[[@LINE+17]]:23
// CHECK:STDERR: -> │ Cpp.PassThreeFields(MakeThreeFields());
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `(i32, i32, i32)` to `Cpp.ThreeFields`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `(i32, i32, i32)` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(Cpp.ThreeFields)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./struct_init.h
// CHECK:STDERR: │ auto PassThreeFields(ThreeFields t) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassThreeFields(MakeThreeFields());
}
@@ -393,15 +641,39 @@ 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+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: ╭─┤ fail_int_from_struct.carbon:[[@LINE+16]]:15
// CHECK:STDERR: -> │ Cpp.PassInt({});
// CHECK:STDERR: · ┳━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `{}` to
// CHECK:STDERR: · │ ┃ `i32`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `{}` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(i32)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./int_from_struct.h
// CHECK:STDERR: │ auto PassInt(int n) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassInt({});
// 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: ╭─┤ fail_int_from_struct.carbon:[[@LINE+16]]:15
// CHECK:STDERR: -> │ Cpp.PassInt(());
// CHECK:STDERR: · ┳━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type `()` to
// CHECK:STDERR: · │ ┃ `i32`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `()` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(i32)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./int_from_struct.h
// CHECK:STDERR: │ auto PassInt(int n) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassInt(());
}
@@ -416,15 +688,41 @@ 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+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: ╭─┤ fail_int_from_struct_overloaded.carbon:[[@LINE+17]]:22
// CHECK:STDERR: -> │ Cpp.PassOverloaded({});
// CHECK:STDERR: · ┳━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `{}` to `i32`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `{}` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(i32)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./int_from_struct.h
// CHECK:STDERR: │ auto PassOverloaded(int n) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassOverloaded({});
// 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: ╭─┤ fail_int_from_struct_overloaded.carbon:[[@LINE+17]]:22
// CHECK:STDERR: -> │ Cpp.PassOverloaded(());
// CHECK:STDERR: · ┳━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `()` to `i32`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `()` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(i32)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./int_from_struct.h
// CHECK:STDERR: │ auto PassOverloaded(int n) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.PassOverloaded(());
}
@@ -449,9 +747,19 @@ library "[[@TEST_NAME]]";
import Cpp library "nested_structs.h";
fn F() {
// 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: ╭─┤ fail_pass_nested_structs_inner_field_mismatch.carbon:[[@LINE+14]]:3
// CHECK:STDERR: -> │ Cpp.TakeB({.a = {.x = 1, .z = 2}, .n = 3});
// CHECK:STDERR: · ━━━━┳━━━━
// CHECK:STDERR: · ┗━━┫ error: no matching function for call to 'TakeB'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./nested_structs.h
// CHECK:STDERR: │ void TakeB(B);
// CHECK:STDERR: · ┬ ┬
// CHECK:STDERR: · ╰────────┤ candidate function not viable [CppInteropParseNote]
// CHECK:STDERR: · ╰────┤ cannot convert initializer list argument to 'B'
// CHECK:STDERR: · │ [CppInteropParseNoteReason]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.TakeB({.a = {.x = 1, .z = 2}, .n = 3});
}
@@ -463,9 +771,24 @@ library "[[@TEST_NAME]]";
import Cpp library "nested_structs.h";
fn F() {
// 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: ╭─┤ fail_todo_pass_nested_structs.carbon:[[@LINE+19]]:13
// CHECK:STDERR: -> │ Cpp.TakeB({.a = {.x = 1, .y = 2}, .n = 3});
// CHECK:STDERR: · ━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// CHECK:STDERR: · ┃ error: cannot implicitly convert expression of type
// CHECK:STDERR: · ┃ `{.a: {.x: Core.IntLiteral, .y: Core.IntLiteral}, .n: Core.IntLiteral}`
// CHECK:STDERR: · ┃ to `Cpp.B`
// CHECK:STDERR: · ┃ [ConversionFailure]
// CHECK:STDERR: · ╭──────────────────────────╯
// CHECK:STDERR: · │ type `{.a: {.x: Core.IntLiteral, .y: Core.IntLiteral}, .n: Core.IntLiteral}`
// CHECK:STDERR: · │ does not implement interface `Core.ImplicitAs(Cpp.B)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./nested_structs.h
// CHECK:STDERR: │ void TakeB(B);
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.TakeB({.a = {.x = 1, .y = 2}, .n = 3});
}
@@ -499,9 +822,22 @@ library "[[@TEST_NAME]]";
import Cpp library "signedness_change.h";
fn F() {
// 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: ╭─┤ fail_signedness_change_rejected.carbon:[[@LINE+17]]:22
// CHECK:STDERR: -> │ Cpp.signedness_foo(1 as i32);
// CHECK:STDERR: · ┳━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `i32` to `u32`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `i32` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(u32)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./signedness_change.h
// CHECK:STDERR: │ auto signedness_foo(unsigned int a) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.signedness_foo(1 as i32);
}
@@ -517,9 +853,22 @@ library "[[@TEST_NAME]]";
import Cpp library "downsizing_rejected.h";
fn F() {
// 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: ╭─┤ fail_import_downsizing_rejected.carbon:[[@LINE+17]]:22
// CHECK:STDERR: -> │ Cpp.downsizing_foo(1 as i32);
// CHECK:STDERR: · ┳━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot implicitly convert expression of type
// CHECK:STDERR: · │ ┃ `i32` to `i16`
// CHECK:STDERR: · │ ┃ [ConversionFailure]
// CHECK:STDERR: · ╰────┤ type `i32` does not implement interface
// CHECK:STDERR: · │ `Core.ImplicitAs(i16)`
// CHECK:STDERR: · │ [MissingImplInMemberAccessInContext]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./downsizing_rejected.h
// CHECK:STDERR: │ auto downsizing_foo(short a) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ initializing function parameter
// CHECK:STDERR: · │ [InCallToFunctionParam]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.downsizing_foo(1 as i32);
}
@@ -539,9 +888,20 @@ library "[[@TEST_NAME]]";
import Cpp library "no_viable_function.h";
fn F() {
// 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: ╭─┤ fail_import_no_viable_function.carbon:[[@LINE+15]]:3
// CHECK:STDERR: -> │ Cpp.no_viable_foo(1 as i64);
// CHECK:STDERR: · ━━━━━━━━┳━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: no matching function for call to 'no_viable_foo'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./no_viable_function.h
// CHECK:STDERR: │ auto no_viable_foo(short a, int b) -> void;
// CHECK:STDERR: · ┬ ───────┬──────
// CHECK:STDERR: · ╰───────────────────────┤ candidate function not viable
// CHECK:STDERR: · │ │ [CppInteropParseNote]
// CHECK:STDERR: · ╰────┤ requires 2 arguments, but 1 was provided
// CHECK:STDERR: · │ [CppInteropParseNoteReason]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.no_viable_foo(1 as i64);
}
@@ -562,9 +922,20 @@ library "[[@TEST_NAME]]";
import Cpp library "ambiguous_overload.h";
fn F() {
// 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: ╭─┤ fail_import_ambiguous_overload.carbon:[[@LINE+15]]:3
// CHECK:STDERR: -> │ Cpp.ambiguous_foo(1 as i64);
// CHECK:STDERR: · ━━━━━━━━┳━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: call to 'ambiguous_foo' is ambiguous
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./ambiguous_overload.h
// CHECK:STDERR: │ auto ambiguous_foo(short a) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ candidate function [CppInteropParseNote]
// CHECK:STDERR: │ auto ambiguous_foo(int a) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ candidate function [CppInteropParseNote]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.ambiguous_foo(1 as i64);
}
@@ -585,9 +956,20 @@ library "[[@TEST_NAME]]";
import Cpp library "deleted_function.h";
fn F() {
// 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: ╭─┤ fail_import_deleted_function.carbon:[[@LINE+15]]:3
// CHECK:STDERR: -> │ Cpp.deleted_foo(1 as i32);
// CHECK:STDERR: · ━━━━━━━┳━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: call to deleted function 'deleted_foo'
// CHECK:STDERR: · ┃ [CppInteropParseError]
// CHECK:STDERR: ┆
// CHECK:STDERR: ├─┤ ./deleted_function.h
// CHECK:STDERR: │ auto deleted_foo(short a) -> void;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ candidate function [CppInteropParseNote]
// CHECK:STDERR: │ auto deleted_foo(int a) -> void = delete;
// CHECK:STDERR: · ┬
// CHECK:STDERR: · ╰──┤ candidate function has been explicitly deleted [CppInteropParseNote]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
Cpp.deleted_foo(1 as i32);
}
@@ -605,8 +987,18 @@ interface I {}
fn EchoValue[ValueT: I](unused generic value: ValueT) {}
fn F() {
// CHECK:STDERR: fail_missing_impl.carbon:[[@LINE+3]]:3-33: error: cannot convert type `<type of Cpp.missing_impl_foo>` into type implementing `I` [ConversionFailureTypeToFacet]
// CHECK:STDERR: fail_missing_impl.carbon:[[@LINE-4]]:1-55: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: ╭─┤ fail_missing_impl.carbon:[[@LINE+13]]:3
// CHECK:STDERR: │ fn EchoValue[ValueT: I](unused generic value: ValueT) {}
// CHECK:STDERR: · ─────────────────────────┬─────────────────────────────
// CHECK:STDERR: · ╰──┤ while deducing parameters of generic declared here
// CHECK:STDERR: · │ [DeductionGenericHere]
// CHECK:STDERR: ┆
// CHECK:STDERR: -> │ EchoValue(Cpp.missing_impl_foo);
// CHECK:STDERR: · ┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CHECK:STDERR: · ┗━━┫ error: cannot convert type `<type of Cpp.missing_impl_foo>` into type
// CHECK:STDERR: · ┃ implementing `I`
// CHECK:STDERR: · ┃ [ConversionFailureTypeToFacet]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
EchoValue(Cpp.missing_impl_foo);
}