Repository: carbon-language/carbon-lang
File: toolchain/check/check_unit.cpp (C++)

Code before:
        break;
      }
      case CARBON_KIND(SemIR::ImplDecl impl_decl): {
        auto& impl = context_.impls().Get(impl_decl.impl_id);
        if (!impl.is_defined()) {
          FillImplWitnessWithErrors(context_, impl);
          CARBON_DIAGNOSTIC(ImplMissingDefinition, Error,
                            "impl declared but not defined");
          emitter_.Emit(decl_inst_id, ImplMissingDefinition);
        }
        break;
      }
      case SemIR::InterfaceDecl::Kind: {
        // TODO: Handle `interface` as well, once we can test it without
        // triggering
        // https://github.com/carbon-language/carbon-lang/issues/4071.
        CARBON_FATAL("TODO: Support interfaces in DiagnoseMissingDefinitions");
      }
      default: {
        CARBON_FATAL("Unexpected inst in definitions_required: {0}", decl_inst);
      }
    }
  }

  // Note that more required definitions can be added during this loop.
  // NOLINTNEXTLINE (modernize-loop-convert)
  for (size_t i = 0; i != context_.definitions_required_by_use().size(); ++i) {
    // This is using the location for the use. We could track the
    // list of enclosing locations if this was used from a generic.
    auto [loc, specific_id] = context_.definitions_required_by_use()[i];
    if (!ResolveSpecificDefinition(context_, loc, specific_id)) {
      CARBON_DIAGNOSTIC(MissingGenericFunctionDefinition, Error,
                        "use of undefined generic function");
      CARBON_DIAGNOSTIC(MissingGenericFunctionDefinitionHere, Note,
                        "generic function declared here");
      auto generic_decl_id =
          context_.generics()
              .Get(context_.specifics().Get(specific_id).generic_id)
              .decl_id;
      emitter_.Build(loc, MissingGenericFunctionDefinition)
          .Note(generic_decl_id, MissingGenericFunctionDefinitionHere)
          .Emit();
    }
  }
}

auto CheckUnit::FinishRun() -> void {
  // TODO: Remove this once we properly push and pop in the right places.
  context_.generic_region_stack().Pop();

  CheckRequiredDeclarations();

Review comment (suggestion):
```suggestion
  // NOLINTNEXTLINE(modernize-loop-convert)
```

Code after:
        break;
      }
      case CARBON_KIND(SemIR::ImplDecl impl_decl): {
        auto& impl = context_.impls().Get(impl_decl.impl_id);
        if (!impl.is_complete()) {
          FillImplWitnessWithErrors(context_, impl);
          CARBON_DIAGNOSTIC(ImplMissingDefinition, Error,
                            "impl declared but not defined");
          emitter_.Emit(decl_inst_id, ImplMissingDefinition);
        }
        break;
      }
      case SemIR::InterfaceDecl::Kind: {
        // TODO: Handle `interface` as well, once we can test it without
        // triggering
        // https://github.com/carbon-language/carbon-lang/issues/4071.
        CARBON_FATAL("TODO: Support interfaces in DiagnoseMissingDefinitions");
      }
      default: {
        CARBON_FATAL("Unexpected inst in definitions_required: {0}", decl_inst);
      }
    }
  }

  // Note that more required definitions can be added during this loop.
  // NOLINTNEXTLINE(modernize-loop-convert)
  for (size_t i = 0; i != context_.definitions_required_by_use().size(); ++i) {
    // This is using the location for the use. We could track the
    // list of enclosing locations if this was used from a generic.
    auto [loc, specific_id] = context_.definitions_required_by_use()[i];
    if (!ResolveSpecificDefinition(context_, loc, specific_id)) {
      CARBON_DIAGNOSTIC(MissingGenericFunctionDefinition, Error,
                        "use of undefined generic function");
      CARBON_DIAGNOSTIC(MissingGenericFunctionDefinitionHere, Note,
                        "generic function declared here");
      auto generic_decl_id =
          context_.generics()
              .Get(context_.specifics().Get(specific_id).generic_id)
              .decl_id;
      emitter_.Build(loc, MissingGenericFunctionDefinition)
          .Note(generic_decl_id, MissingGenericFunctionDefinitionHere)
          .Emit();
    }
  }
}

auto CheckUnit::FinishRun() -> void {
  // TODO: Remove this once we properly push and pop in the right places.
  context_.generic_region_stack().Pop();

  CheckRequiredDeclarations();