@@ -64,9 +64,7 @@ auto HandleParseNode(Context& context, Parse::ReturnTypeId node_id) -> bool {
64
64
// not on the pattern stacks yet. They are only needed in that case if we have
65
65
// a return type, which we now know that we do.
66
66
if (context.node_stack ().PeekNodeKind () ==
67
- Parse::NodeKind::IdentifierNameNotBeforeParams ||
68
- context.node_stack ().PeekNodeKind () ==
69
- Parse::NodeKind::KeywordNameNotBeforeParams) {
67
+ Parse::NodeKind::IdentifierNameNotBeforeParams) {
70
68
context.pattern_block_stack ().Push ();
71
69
context.full_pattern_stack ().PushFullPattern (
72
70
FullPatternStack::Kind::ExplicitParamList);
@@ -365,81 +363,6 @@ static auto RequestVtableIfVirtual(
365
363
context.vtable_stack ().AddInstId (decl_id);
366
364
}
367
365
368
- // Validates the `destroy` function's signature. May replace invalid values for
369
- // recovery.
370
- static auto ValidateIfDestroy (Context& context, bool is_redecl,
371
- std::optional<SemIR::Inst> parent_scope_inst,
372
- SemIR::Function& function_info) -> void {
373
- if (function_info.name_id != SemIR::NameId::Destroy) {
374
- return ;
375
- }
376
-
377
- // For recovery, always force explicit parameters to be empty. We do this
378
- // before any of the returns for simplicity.
379
- auto orig_param_patterns_id = function_info.param_patterns_id ;
380
- function_info.param_patterns_id = SemIR::InstBlockId::Empty;
381
-
382
- // Use differences on merge to diagnose remaining issues.
383
- if (is_redecl) {
384
- return ;
385
- }
386
-
387
- if (!parent_scope_inst || !parent_scope_inst->Is <SemIR::ClassDecl>()) {
388
- CARBON_DIAGNOSTIC (DestroyFunctionOutsideClass, Error,
389
- " declaring `fn destroy` in non-class scope" );
390
- context.emitter ().Emit (function_info.latest_decl_id (),
391
- DestroyFunctionOutsideClass);
392
- return ;
393
- }
394
-
395
- if (!function_info.self_param_id .has_value ()) {
396
- CARBON_DIAGNOSTIC (DestroyFunctionMissingSelf, Error,
397
- " missing implicit `self` parameter" );
398
- context.emitter ().Emit (function_info.latest_decl_id (),
399
- DestroyFunctionMissingSelf);
400
- return ;
401
- }
402
-
403
- // `self` must be the only implicit parameter.
404
- if (auto block =
405
- context.inst_blocks ().Get (function_info.implicit_param_patterns_id );
406
- block.size () > 1 ) {
407
- // Point at the first non-`self` parameter.
408
- auto param_id = block[function_info.self_param_id == block[0 ] ? 1 : 0 ];
409
- CARBON_DIAGNOSTIC (DestroyFunctionUnexpectedImplicitParam, Error,
410
- " unexpected implicit parameter" );
411
- context.emitter ().Emit (param_id, DestroyFunctionUnexpectedImplicitParam);
412
- return ;
413
- }
414
-
415
- if (!orig_param_patterns_id.has_value ()) {
416
- CARBON_DIAGNOSTIC (DestroyFunctionPositionalParams, Error,
417
- " missing empty explicit parameter list" );
418
- context.emitter ().Emit (function_info.latest_decl_id (),
419
- DestroyFunctionPositionalParams);
420
- return ;
421
- }
422
-
423
- if (orig_param_patterns_id != SemIR::InstBlockId::Empty) {
424
- CARBON_DIAGNOSTIC (DestroyFunctionNonEmptyExplicitParams, Error,
425
- " unexpected parameter" );
426
- context.emitter ().Emit (context.inst_blocks ().Get (orig_param_patterns_id)[0 ],
427
- DestroyFunctionNonEmptyExplicitParams);
428
- return ;
429
- }
430
-
431
- if (auto return_type_id =
432
- function_info.GetDeclaredReturnType (context.sem_ir ());
433
- return_type_id.has_value () &&
434
- return_type_id != GetTupleType (context, {})) {
435
- CARBON_DIAGNOSTIC (DestroyFunctionIncorrectReturnType, Error,
436
- " incorrect return type; must be unspecified or `()`" );
437
- context.emitter ().Emit (function_info.return_slot_pattern_id ,
438
- DestroyFunctionIncorrectReturnType);
439
- return ;
440
- }
441
- }
442
-
443
366
// Diagnoses when positional params aren't supported. Reassigns the pattern
444
367
// block if needed.
445
368
static auto DiagnosePositionalParams (Context& context,
@@ -505,12 +428,6 @@ static auto BuildFunctionDecl(Context& context,
505
428
function_info.definition_id = decl_id;
506
429
}
507
430
508
- // Analyze standard function signatures before positional parameters, so that
509
- // we can have more specific diagnostics and recovery.
510
- bool is_redecl =
511
- name_context.state == DeclNameStack::NameContext::State::Resolved;
512
- ValidateIfDestroy (context, is_redecl, parent_scope_inst, function_info);
513
-
514
431
DiagnosePositionalParams (context, function_info);
515
432
516
433
TryMergeRedecl (context, node_id, name_context, function_decl, function_info,
0 commit comments