mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:24:46 +01:00
Support CARBON_KIND with Any types (#6828)
This uses the `CARBON_KIND_ANY(AnyImportRef, auto import_ref):` syntax that seemed to be favored [on Discord](https://discord.com/channels/655572317891461132/655578254970716160/1478486848207720478). This converted uses in the `sem_ir` directory to show it works initially, then added `check` for full coverage plus validating the `SemIR::` namespace discard. Note in inst_namer.cpp, AnyBindingPattern includes FormBindingPattern which wasn't previously handled. I'm disabling clang-format because I think it formats with readability issues, e.g.: ``` #define CARBON_KIND_ANY_EXPAND_AnyBinding(X, SEP) \ X(::Carbon::SemIR::AliasBinding) \ SEP X(::Carbon::SemIR::FormBinding) SEP X(::Carbon::SemIR::RefBinding) \ SEP X(::Carbon::SemIR::SymbolicBinding) \ SEP X(::Carbon::SemIR::ValueBinding) ``` Since `SEP` is typically a comma, it's also a nuisance to treat as an argument to `X` (which could get better results). Assisted-by: Google Antigravity with Gemini 3 Flash
This commit is contained in:
@@ -602,18 +602,11 @@ static auto CheckUnusedBindingsInPattern(Context& context,
|
||||
auto current_id = work_list.pop_back_val();
|
||||
auto inst = context.insts().Get(current_id);
|
||||
CARBON_KIND_SWITCH(inst) {
|
||||
case SemIR::OutParamPattern::Kind:
|
||||
case SemIR::RefParamPattern::Kind:
|
||||
case SemIR::ValueParamPattern::Kind:
|
||||
case SemIR::VarParamPattern::Kind: {
|
||||
auto param = inst.As<SemIR::AnyParamPattern>();
|
||||
case CARBON_KIND_ANY(SemIR::AnyParamPattern, param): {
|
||||
work_list.push_back(param.subpattern_id);
|
||||
break;
|
||||
}
|
||||
case SemIR::RefBindingPattern::Kind:
|
||||
case SemIR::SymbolicBindingPattern::Kind:
|
||||
case SemIR::ValueBindingPattern::Kind: {
|
||||
auto bind = inst.As<SemIR::AnyBindingPattern>();
|
||||
case CARBON_KIND_ANY(SemIR::AnyBindingPattern, bind): {
|
||||
auto& entity_name = context.entity_names().Get(bind.entity_name_id);
|
||||
// We need special treatment for the name "_" which is implicitly
|
||||
// unused but actually permitted in declarations.
|
||||
|
||||
Reference in New Issue
Block a user