Add a conversion impl from T* to const T* (#7010)

This is already allowed as a builtin conversion, but the impl allows the
generics system to know about it, so that conversions like
`Optional(T*)` to `Optional(const T*)` are allowed. This in turn allows
a C++ `T*` to be implicitly converted to a C++ `const T*` in Carbon
code.
This commit is contained in:
Richard Smith
2026-04-03 22:07:53 +00:00
committed by GitHub
parent 8e0d856725
commit 05ba1d7356
4 changed files with 262 additions and 8 deletions
@@ -2077,13 +2077,13 @@ fn F() {
// CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
// CHECK:STDOUT: %f128.b8c: type = class_type @Float, @Float(%int_128) [concrete]
// CHECK:STDOUT: %f128.853: type = float_type %int_128, f128 [concrete]
// CHECK:STDOUT: %As.type.6c6: type = facet_type <@As, @As(%f128.b8c)> [concrete]
// CHECK:STDOUT: %As.type.6c6a: type = facet_type <@As, @As(%f128.b8c)> [concrete]
// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.882: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%N) [symbolic]
// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.27d: %Core.FloatLiteral.as.As.impl.Convert.type.882 = struct_value () [symbolic]
// CHECK:STDOUT: %As.impl_witness.738: <witness> = impl_witness imports.%As.impl_witness_table.7c1, @Core.FloatLiteral.as.As.impl(%int_128) [concrete]
// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.e6b: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%int_128) [concrete]
// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.3b3: %Core.FloatLiteral.as.As.impl.Convert.type.e6b = struct_value () [concrete]
// CHECK:STDOUT: %As.facet: %As.type.6c6 = facet_value Core.FloatLiteral, (%As.impl_witness.738) [concrete]
// CHECK:STDOUT: %As.facet: %As.type.6c6a = facet_value Core.FloatLiteral, (%As.impl_witness.738) [concrete]
// CHECK:STDOUT: %As.WithSelf.Convert.type.c62: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%f128.b8c, %As.facet) [concrete]
// CHECK:STDOUT: %.d5b: type = fn_type_with_self_type %As.WithSelf.Convert.type.c62, %As.facet [concrete]
// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.bound: <bound method> = bound_method %float.96e, %Core.FloatLiteral.as.As.impl.Convert.3b3 [concrete]