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

Code before:
                eval_context.constant_values().GetConstantInstId(
                    impls->rhs_id));
            const auto& more_info =
                eval_context.facet_types().Get(facet_type.facet_type_id);
            // The way to prevent lookup into the interface requirements of a
            // facet type is to put it to the right of a `.Self impls`, which we
            // accomplish by putting them into `self_impls_constraints`.
            llvm::append_range(info.self_impls_constraints,
                               more_info.extend_constraints);
            llvm::append_range(info.self_impls_constraints,
                               more_info.self_impls_constraints);
            // Other requirements are copied in.
            llvm::append_range(info.rewrite_constraints,
                               more_info.rewrite_constraints);
            info.other_requirements |= more_info.other_requirements;
          }
          continue;
        }

        // TODO: Handle `impls` constraints beyond `.Self impls`.
        info.other_requirements = true;
        continue;
      }

      // TODO: Handle other requirements
      info.other_requirements = true;
    }
  }

  auto const_info = GetConstantFacetTypeInfo(
      eval_context, SemIR::LocId(inst_id), info, &phase);
  return MakeFacetTypeResult(eval_context.context(), const_info, phase);
}

// Implementation for `TryEvalInst`, wrapping `Context` with `EvalContext`.
static auto TryEvalInstInContext(EvalContext& eval_context,
                                 SemIR::InstId inst_id, SemIR::Inst inst)
    -> SemIR::ConstantId {
  using EvalInstFn =
      auto(EvalContext & eval_context, SemIR::InstId inst_id, SemIR::Inst inst)
          ->SemIR::ConstantId;
  static constexpr EvalInstFn* EvalInstFns[] = {
#define CARBON_SEM_IR_INST_KIND(Kind) &TryEvalTypedInst<SemIR::Kind>,
#include "toolchain/sem_ir/inst_kind.def"
  };
  [[clang::musttail]] return EvalInstFns[inst.kind().AsInt()](eval_context,
                                                              inst_id, inst);
}

auto TryEvalInstUnsafe(Context& context, SemIR::InstId inst_id,
                       SemIR::Inst inst) -> SemIR::ConstantId {

Review comment (suggestion):
```suggestion
```

If this goes out, won't the addition of `info.other_requirements` on 2053 handle this?

Note, it may be good to shift the flow a little -- there's a lot of nesting going on, and particularly with the nested `continue` it gets a little difficult to track interactions.

Code after:
            // `.Self impls type` -> nothing to do.
            continue;
          } else {
            auto facet_type = eval_context.insts().GetAs<SemIR::FacetType>(
                eval_context.constant_values().GetConstantInstId(
                    impls->rhs_id));
            const auto& more_info =
                eval_context.facet_types().Get(facet_type.facet_type_id);
            // The way to prevent lookup into the interface requirements of a
            // facet type is to put it to the right of a `.Self impls`, which we
            // accomplish by putting them into `self_impls_constraints`.
            llvm::append_range(info.self_impls_constraints,
                               more_info.extend_constraints);
            llvm::append_range(info.self_impls_constraints,
                               more_info.self_impls_constraints);
            // Other requirements are copied in.
            llvm::append_range(info.rewrite_constraints,
                               more_info.rewrite_constraints);
            info.other_requirements |= more_info.other_requirements;
          }
          continue;
        }

        // TODO: Handle `impls` constraints beyond `.Self impls`.
        info.other_requirements = true;
        continue;
      }

      // TODO: Handle other requirements
      info.other_requirements = true;
    }
  }

  auto const_info = GetConstantFacetTypeInfo(
      eval_context, SemIR::LocId(inst_id), info, &phase);
  return MakeFacetTypeResult(eval_context.context(), const_info, phase);
}

// Implementation for `TryEvalInst`, wrapping `Context` with `EvalContext`.
static auto TryEvalInstInContext(EvalContext& eval_context,
                                 SemIR::InstId inst_id, SemIR::Inst inst)
    -> SemIR::ConstantId {
  using EvalInstFn =
      auto(EvalContext & eval_context, SemIR::InstId inst_id, SemIR::Inst inst)
          ->SemIR::ConstantId;
  static constexpr EvalInstFn* EvalInstFns[] = {
#define CARBON_SEM_IR_INST_KIND(Kind) &TryEvalTypedInst<SemIR::Kind>,
#include "toolchain/sem_ir/inst_kind.def"
  };
  [[clang::musttail]] return EvalInstFns[inst.kind().AsInt()](eval_context,
                                                              inst_id, inst);