Add Destroy.SubobjectDestroy as a temporary replacement for Destroy.Op (#7773)

This change partially implements [PR #7362], which revises how objects
are destroyed. It is a partial implementation for two reasons:

1. This change moves `Destroy.Op`'s current behaviour into
`Destroy.SubobjectDestroy`, but it doesn't add support for objects with
non-trivial destruction.
2. `Destroy.SubobjectDestroy` is a workaround for `require impls
SubobjectDestroy`. We aren't able to use the latter until the dependents
add their requirements' implementations to their own witness tables.

[PR #7362]: https://github.com/carbon-language/carbon-lang/pulls/7362
This commit is contained in:
Christopher Di Bella
2026-09-24 00:06:28 +00:00
committed by GitHub
parent 03939a9223
commit f7cd39428e
309 changed files with 51760 additions and 15269 deletions
+5 -3
View File
@@ -554,9 +554,11 @@ auto BuildDestroyThunk(Context& context, SemIR::LocId loc_id,
auto self_inst_id = params[0];
// Build the function body. This calls the `Destroy` operator on `self`.
auto destroy_inst_id = BuildUnaryOperator(
context, loc_id, {.interface_name = CoreIdentifier::Destroy},
self_inst_id);
auto destroy_inst_id =
BuildUnaryOperator(context, loc_id,
{.interface_name = CoreIdentifier::Destroy,
.op_name = CoreIdentifier::SelfDestruct},
self_inst_id);
DiscardExpr(context, destroy_inst_id);
BuildReturnWithNoExpr(context, loc_id);