Skip to content

Commit 65180a7

Browse files
authored
Use designated initializers in import.cpp (#4883)
From https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/cpp_style_guide.md#syntax-and-formatting: "Use designated initializers (`{.a = 1}`) when possible for structs".
1 parent e257051 commit 65180a7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

toolchain/check/import.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ static auto AddNamespace(Context& context, SemIR::TypeId namespace_type_id,
119119
CARBON_CHECK(import_id.has_value());
120120
context.DiagnoseDuplicateName(import_id, prev_inst_id);
121121
}
122-
return {namespace_inst->name_scope_id, prev_inst_id, true};
122+
return {.name_scope_id = namespace_inst->name_scope_id,
123+
.inst_id = prev_inst_id,
124+
.is_duplicate_of_namespace_in_current_package = true};
123125
}
124126
}
125127
}
@@ -129,7 +131,9 @@ static auto AddNamespace(Context& context, SemIR::TypeId namespace_type_id,
129131
auto import_loc_id = context.insts().GetLocId(import_id);
130132

131133
auto namespace_inst =
132-
SemIR::Namespace{namespace_type_id, SemIR::NameScopeId::None, import_id};
134+
SemIR::Namespace{.type_id = namespace_type_id,
135+
.name_scope_id = SemIR::NameScopeId::None,
136+
.import_id = import_id};
133137
auto namespace_inst_and_loc =
134138
import_loc_id.is_import_ir_inst_id()
135139
? context.MakeImportedLocAndInst(import_loc_id.import_ir_inst_id(),
@@ -158,7 +162,9 @@ static auto AddNamespace(Context& context, SemIR::TypeId namespace_type_id,
158162
}
159163
result = SemIR::ScopeLookupResult::MakeFound(namespace_id,
160164
SemIR::AccessKind::Public);
161-
return {namespace_inst.name_scope_id, namespace_id, false};
165+
return {.name_scope_id = namespace_inst.name_scope_id,
166+
.inst_id = namespace_id,
167+
.is_duplicate_of_namespace_in_current_package = false};
162168
}
163169

164170
// Adds a copied namespace to the cache.

0 commit comments

Comments
 (0)