Cleanup pass over llvm::seq uses (#5185)

I was thinking about this after `seq` changes in #5182, and looked for
other uses that might be replaceable. Here's the resulting cleanup
around `seq`:

- Switch to `enumerate` or `zip` when possible.
- `int _` -> `auto _` (it's typically a `size_t`, but there's no reason
to cast when unused)
- Fix a case of cast style `(size_t)...` -> `static_cast<size_t>(...)`
- Switch `(void)close_children_count` to `[[maybe_unused]]`
This commit is contained in:
Jon Ross-Perkins
2025-03-26 19:25:03 +00:00
committed by GitHub
parent acbe6530c3
commit 0d3d829478
9 changed files with 37 additions and 40 deletions
+4 -4
View File
@@ -117,13 +117,13 @@ auto ImplWitnessStartDefinition(Context& context, SemIR::Impl& impl) -> void {
// Check we have a value for all non-function associated constants in the
// witness.
for (auto index : llvm::seq(assoc_entities.size())) {
auto decl_id = assoc_entities[index];
for (auto [assoc_entity, witness_value] :
llvm::zip(assoc_entities, witness_block)) {
auto decl_id = assoc_entity;
decl_id = context.constant_values().GetConstantInstId(decl_id);
CARBON_CHECK(decl_id.has_value(), "Non-constant associated entity");
if (auto decl =
context.insts().TryGetAs<SemIR::AssociatedConstantDecl>(decl_id)) {
auto& witness_value = witness_block[index];
if (!witness_value.has_value()) {
CARBON_DIAGNOSTIC(ImplAssociatedConstantNeedsValue, Error,
"associated constant {0} not given a value in impl "
@@ -137,7 +137,7 @@ auto ImplWitnessStartDefinition(Context& context, SemIR::Impl& impl) -> void {
.Get(decl->assoc_const_id)
.name_id,
interface.name_id)
.Note(assoc_entities[index], AssociatedConstantHere)
.Note(assoc_entity, AssociatedConstantHere)
.Emit();
witness_value = SemIR::ErrorInst::SingletonInstId;