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
-14
View File
@@ -290,19 +290,6 @@ Whether to use the implicit prelude import. Enabled by default.
arg_b.Default(true);
arg_b.Set(&prelude_import);
});
b.AddFlag(
{
.name = "gen-implicit-type-impls",
.help = R"""(
Whether to generate standard `impl`s for types, such as `Core.Destroy`. This
only controls generation of the `impl`; code which expects the `impl` is
expected to fail. Enabled by default.
)""",
},
[&](auto& arg_b) {
arg_b.Default(true);
arg_b.Set(&gen_implicit_type_impls);
});
b.AddFlag(
{
.name = "custom-core",
@@ -1053,7 +1040,6 @@ auto CompileSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
CARBON_VLOG_TO(driver_env.vlog_stream, "*** Check::CheckParseTrees ***\n");
Check::CheckParseTreesOptions options;
options.prelude_import = options_.prelude_import;
options.gen_implicit_type_impls = options_.gen_implicit_type_impls;
options.vlog_stream = driver_env.vlog_stream;
options.fuzzing = driver_env.fuzzing;
if (options.vlog_stream || options_.dump_sem_ir || options_.dump_cpp_ast ||