mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:54:44 +01:00
Canonicalize generated functions for Core witnesses (#7729)
Use a single `SemIR::Function` per `Core` interface method, whether it's generated locally or imported. This prevents generating duplicate functions, which lead to different types when the witness appears in a `FacetValue` as part of a specific for a class. We use a `CanonicalValueStore` of `GeneratedFunction` objects that allow finding an existing FunctionId for a `Generated` special function before (re-)generating it. Mangling for `Generated` functions is also moved to use the values from the `GeneratedFunction`'s canonicalization key, so that we have a consistent source of truth for the unique ID of a `Generated` function across all files. New tests are in `toolchain/check/testdata/impl/custom_witness/destroy.carbon`.
This commit is contained in:
@@ -164,9 +164,8 @@ static auto BuildCopyWitness(
|
||||
}
|
||||
// Otherwise it's an enum (or eventually a C struct type). Perform a primitive
|
||||
// copy.
|
||||
return BuildPrimitiveCopyWitness(
|
||||
context, loc_id, GetClassScope(context, query_self_const_id),
|
||||
query_self_const_id, query_specific_interface_id);
|
||||
return BuildPrimitiveCopyWitness(context, loc_id, query_self_const_id,
|
||||
query_specific_interface_id);
|
||||
}
|
||||
|
||||
static auto BuildCppUnsafeDerefWitness(
|
||||
|
||||
Reference in New Issue
Block a user