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
@@ -48,7 +48,7 @@ fn M() {
// CHECK:STDOUT: %.loc34 = load i32, ptr %n.var, align 4, !dbg !9
// CHECK:STDOUT: call void @_CF.Main.b88d1103f417c6d4(i32 %.loc34), !dbg !10
// CHECK:STDOUT: %.loc35_9 = load i32, ptr %n.var, align 4, !dbg !11
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.dedae426f8f6526d(i32 %.loc35_9), !dbg !12
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.5458818be7a67202(i32 %.loc35_9), !dbg !12
// CHECK:STDOUT: store i32 %G.call, ptr %m.var, align 4, !dbg !13
// CHECK:STDOUT: ret void, !dbg !14
// CHECK:STDOUT: }
@@ -61,7 +61,7 @@ fn M() {
// CHECK:STDOUT: ret void, !dbg !16
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.dedae426f8f6526d(i32 %x) !dbg !17 {
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.5458818be7a67202(i32 %x) !dbg !17 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %.loc25_6.3.temp = alloca i32, align 4, !dbg !18
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc25_6.3.temp), !dbg !18
@@ -102,7 +102,7 @@ fn M() {
// CHECK:STDOUT: !14 = !DILocation(line: 30, column: 1, scope: !4)
// CHECK:STDOUT: !15 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.b88d1103f417c6d4", scope: null, file: !3, line: 16, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !16 = !DILocation(line: 16, column: 1, scope: !15)
// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.dedae426f8f6526d", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !17 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.5458818be7a67202", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
// CHECK:STDOUT: !18 = !DILocation(line: 25, column: 3, scope: !17)
// CHECK:STDOUT: !19 = !DILocation(line: 26, column: 3, scope: !17)
// CHECK:STDOUT: !20 = !DILocation(line: 27, column: 3, scope: !17)