mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Preserve the type-as-written for bindings and use it in diagnostics. (#7804)
In the `EntityName` for a binding, preserve the `TypeInstId` describing how the type was written. When a diagnostic refers to that type via `TypeOfInstId`, use the type-as-written in the diagnostic rather than the canonical type. Assisted-by: Claude Opus via Antigravity
This commit is contained in:
+1
-1
@@ -112,7 +112,7 @@ import Cpp library "conversions.h";
|
||||
|
||||
fn ConstructorExplicit(s: Cpp.Source) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_conditionally_explicit_implicit.carbon:[[@LINE+7]]:42: error: cannot implicitly convert expression of type `Cpp.Source` to `Cpp.ConditionallyExplicit` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_conditionally_explicit_implicit.carbon:[[@LINE+7]]:42: error: cannot implicitly convert expression of type `Source` to `Cpp.ConditionallyExplicit` [ConversionFailure]
|
||||
// CHECK:STDERR: let _: Cpp.ConditionallyExplicitTrue = s;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_conditionally_explicit_implicit.carbon:[[@LINE+4]]:42: note: type `Cpp.Source` does not implement interface `Core.ImplicitAs(Cpp.ConditionallyExplicit)` [MissingImplInMemberAccessInContext]
|
||||
|
||||
+2
-2
@@ -120,7 +120,7 @@ fn CopyDeletedMove(c: Cpp.DeletedMove) -> Cpp.DeletedMove {
|
||||
|
||||
fn CopyNonConstCopy(c: Cpp.NonConstCopy) -> Cpp.NonConstCopy {
|
||||
// TODO: List candidates here.
|
||||
// CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `Cpp.NonConstCopy` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `NonConstCopy` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: return c;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: note: type `Cpp.NonConstCopy` does not implement interface `Core.Copy` [MissingImplInMemberAccessInContext]
|
||||
@@ -132,7 +132,7 @@ fn CopyNonConstCopy(c: Cpp.NonConstCopy) -> Cpp.NonConstCopy {
|
||||
|
||||
fn CopyAmbiguousCopy(c: Cpp.AmbiguousCopy) -> Cpp.AmbiguousCopy {
|
||||
// TODO: List candidates here.
|
||||
// CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `Cpp.AmbiguousCopy` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+7]]:10: error: cannot copy value of type `AmbiguousCopy` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: return c;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_copy_noncopyable.carbon:[[@LINE+4]]:10: note: type `Cpp.AmbiguousCopy` does not implement interface `Core.Copy` [MissingImplInMemberAccessInContext]
|
||||
|
||||
@@ -92,7 +92,7 @@ import Cpp library "implicit_conversions.h";
|
||||
|
||||
fn NonConstConversionTest(s: Cpp.NonConstConversion) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_expr_category.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `Cpp.NonConstConversion` to `Cpp.Dest` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_expr_category.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `NonConstConversion` to `Cpp.Dest` [ConversionFailure]
|
||||
// CHECK:STDERR: let _: Cpp.Dest = s;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_expr_category.carbon:[[@LINE+4]]:21: note: type `Cpp.NonConstConversion` does not implement interface `Core.ImplicitAs(Cpp.Dest)` [MissingImplInMemberAccessInContext]
|
||||
@@ -145,7 +145,7 @@ import Cpp library "implicit_conversions.h";
|
||||
|
||||
fn DeletedConstructorTest(s: Cpp.Source) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:35: error: cannot implicitly convert expression of type `Cpp.Source` to `Cpp.DeletedConstructor` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:35: error: cannot implicitly convert expression of type `Source` to `Cpp.DeletedConstructor` [ConversionFailure]
|
||||
// CHECK:STDERR: let _: Cpp.DeletedConstructor = s;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_deleted.carbon:[[@LINE+4]]:35: note: type `Cpp.Source` does not implement interface `Core.ImplicitAs(Cpp.DeletedConstructor)` [MissingImplInMemberAccessInContext]
|
||||
@@ -158,7 +158,7 @@ fn DeletedConstructorTest(s: Cpp.Source) {
|
||||
|
||||
fn DeletedConversionTest(s: Cpp.DeletedConversion) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `Cpp.DeletedConversion` to `Cpp.Dest` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_deleted.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `DeletedConversion` to `Cpp.Dest` [ConversionFailure]
|
||||
// CHECK:STDERR: let _: Cpp.Dest = s;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_deleted.carbon:[[@LINE+4]]:21: note: type `Cpp.DeletedConversion` does not implement interface `Core.ImplicitAs(Cpp.Dest)` [MissingImplInMemberAccessInContext]
|
||||
@@ -177,7 +177,7 @@ import Cpp library "implicit_conversions.h";
|
||||
|
||||
fn ExplicitConstructorTest(s: Cpp.Source) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:36: error: cannot implicitly convert expression of type `Cpp.Source` to `Cpp.ExplicitConstructor` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:36: error: cannot implicitly convert expression of type `Source` to `Cpp.ExplicitConstructor` [ConversionFailure]
|
||||
// CHECK:STDERR: let _: Cpp.ExplicitConstructor = s;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_explicit.carbon:[[@LINE+4]]:36: note: type `Cpp.Source` does not implement interface `Core.ImplicitAs(Cpp.ExplicitConstructor)` [MissingImplInMemberAccessInContext]
|
||||
@@ -190,7 +190,7 @@ fn ExplicitConstructorTest(s: Cpp.Source) {
|
||||
|
||||
fn ExplicitConversionTest(s: Cpp.ExplicitConversion) {
|
||||
//@dump-sem-ir-begin
|
||||
// CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `Cpp.ExplicitConversion` to `Cpp.Dest` [ConversionFailure]
|
||||
// CHECK:STDERR: fail_explicit.carbon:[[@LINE+7]]:21: error: cannot implicitly convert expression of type `ExplicitConversion` to `Cpp.Dest` [ConversionFailure]
|
||||
// CHECK:STDERR: let _: Cpp.Dest = s;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_explicit.carbon:[[@LINE+4]]:21: note: type `Cpp.ExplicitConversion` does not implement interface `Core.ImplicitAs(Cpp.Dest)` [MissingImplInMemberAccessInContext]
|
||||
|
||||
Reference in New Issue
Block a user