Switch class to use a blanket impl for Destroy (#6125)

Right now, the class destroy impl is incorrectly generated (first
discussed [in
Discord](https://discord.com/channels/655572317891461132/941071822756143115/1418614787449032826)).
If we want it to be correct, deferred definition logic would need to be
added, and the declaration would need to be moved inside the `class`
scope (along with whatever generic logic that needs).

This instead switches to a blanket impl, to avoid creating latent bugs
with generating the `impl` and function body in the wrong scope. This
approach uses the same blanket impl as aggregate destruction that was
added by #6098.

The intent here is to allow progress on other parts of `Destroy`. For
example, under this model the implementation of the function body could
be done as part of lowering the specific.
This commit is contained in:
Jon Ross-Perkins
2025-09-29 16:05:06 +00:00
committed by GitHub
parent 5705b94da8
commit 49ba8cf3e1
230 changed files with 3632 additions and 21983 deletions
@@ -25,14 +25,14 @@ fn CallF() -> i32 {
// CHECK:STDOUT: ; ModuleID = 'call_method.carbon'
// CHECK:STDOUT: source_filename = "call_method.carbon"
// CHECK:STDOUT:
// CHECK:STDOUT: @C.val.loc20_3 = internal constant {} zeroinitializer
// CHECK:STDOUT: @C.val.loc20_3.1 = internal constant {} zeroinitializer
// CHECK:STDOUT:
// CHECK:STDOUT: define i32 @_CCallF.Main() !dbg !4 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !7
// CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !8
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !7
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc20_3, i64 0, i1 false), !dbg !7
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc20_3.1, i64 0, i1 false), !dbg !7
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !8
// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !8
// CHECK:STDOUT: %.loc22_14 = load i32, ptr %n.var, align 4, !dbg !9