diff --git a/common/command_line.cpp b/common/command_line.cpp index fd6eede5770c..a2e8b039f68d 100644 --- a/common/command_line.cpp +++ b/common/command_line.cpp @@ -1218,8 +1218,7 @@ auto Parser::ParsePositionalSuffix( // arguments. bool empty_positional = false; while (!unparsed_args.empty()) { - llvm::StringRef unparsed_arg = unparsed_args.front(); - unparsed_args = unparsed_args.drop_front(); + llvm::StringRef unparsed_arg = unparsed_args.consume_front(); if (unparsed_arg != "--") { CARBON_RETURN_IF_ERROR(ParsePositionalArg(unparsed_arg)); @@ -1260,11 +1259,9 @@ auto Parser::Parse(llvm::ArrayRef unparsed_args) PopulateMaps(*command_); while (!unparsed_args.empty()) { - llvm::StringRef unparsed_arg = unparsed_args.front(); - // Peak at the front for an exact `--` argument that switches to a // positional suffix parsing without dropping this argument. - if (unparsed_arg == "--") { + if (unparsed_args.front() == "--") { if (command_->positional_args.empty()) { return Error( "cannot meaningfully end option and subcommand arguments with a " @@ -1284,7 +1281,7 @@ auto Parser::Parse(llvm::ArrayRef unparsed_args) // Now that we're not switching parse modes, drop the current unparsed // argument and parse it. - unparsed_args = unparsed_args.drop_front(); + llvm::StringRef unparsed_arg = unparsed_args.consume_front(); if (unparsed_arg.starts_with("--")) { // Note that the exact argument "--" has been handled above already. diff --git a/testing/file_test/file_test_base.cpp b/testing/file_test/file_test_base.cpp index 7068f3e9519a..2ac8d5e06807 100644 --- a/testing/file_test/file_test_base.cpp +++ b/testing/file_test/file_test_base.cpp @@ -179,7 +179,7 @@ static auto RunAutoupdater(FileTestBase* test_base, const TestFile& test_file, llvm::ArrayRef expected_filenames = filenames; if (filenames.size() > 1) { - expected_filenames = expected_filenames.drop_front(); + expected_filenames.consume_front(); } return FileTestAutoupdater( diff --git a/testing/file_test/file_test_base_test.cpp b/testing/file_test/file_test_base_test.cpp index 4af016bdcdab..707bb647eb8a 100644 --- a/testing/file_test/file_test_base_test.cpp +++ b/testing/file_test/file_test_base_test.cpp @@ -76,7 +76,7 @@ static auto GetFilesFromArgs(llvm::ArrayRef args, if (args.empty() || args.front() != "default_args") { return ErrorBuilder() << "missing `default_args` argument"; } - args = args.drop_front(); + args.consume_front(); for (auto arg : args) { if (!fs.exists(arg)) { diff --git a/toolchain/check/function.cpp b/toolchain/check/function.cpp index a8638450f772..3e7c7dee42b7 100644 --- a/toolchain/check/function.cpp +++ b/toolchain/check/function.cpp @@ -140,7 +140,7 @@ auto CheckFunctionDefinitionSignature(Context& context, SemIR::LocId(function.return_slot_pattern_id), function, SemIR::SpecificId::None); // Don't re-check the return type below. - params_to_complete = params_to_complete.drop_back(); + params_to_complete.consume_back(); } // Check the parameter types are complete. diff --git a/toolchain/check/handle_function.cpp b/toolchain/check/handle_function.cpp index f6a38f11b149..a2b4bd912961 100644 --- a/toolchain/check/handle_function.cpp +++ b/toolchain/check/handle_function.cpp @@ -694,7 +694,7 @@ static auto IsValidBuiltinDeclaration(Context& context, // Find the list of call parameters other than the implicit return slot. auto call_params = context.inst_blocks().Get(function.call_params_id); if (function.return_slot_pattern_id.has_value()) { - call_params = call_params.drop_back(); + call_params.consume_back(); } // Form the list of parameter types for the declaration. diff --git a/toolchain/lower/handle_call.cpp b/toolchain/lower/handle_call.cpp index 04575f67b92c..2e525a32ccc3 100644 --- a/toolchain/lower/handle_call.cpp +++ b/toolchain/lower/handle_call.cpp @@ -516,8 +516,7 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, auto inst_type = context.GetTypeIdOfInst(inst_id); if (context.GetReturnTypeInfo(inst_type).info.has_return_slot()) { - args.push_back(context.GetValue(arg_ids.back())); - arg_ids = arg_ids.drop_back(); + args.push_back(context.GetValue(arg_ids.consume_back())); } for (auto arg_id : arg_ids) { diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index 544e85e7f656..ba49b098a15f 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -1189,8 +1189,7 @@ auto Formatter::FormatCallRhs(Call inst) -> void { bool has_return_slot = return_info.has_return_slot(); InstId return_slot_arg_id = InstId::None; if (has_return_slot) { - return_slot_arg_id = args.back(); - args = args.drop_back(); + return_slot_arg_id = args.consume_back(); } llvm::ListSeparator sep;