From 5806e16dd4b64f0966b559070676c3fc268b3c96 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 18 May 2022 09:38:35 -0500 Subject: [PATCH] refactor(derive): Don't alias arg matches Right now, the aliasing is safe (the compiler says so!) but we're going to be switching to a `&mut` and need to ensure we don't alias. --- clap_derive/src/derives/subcommand.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clap_derive/src/derives/subcommand.rs b/clap_derive/src/derives/subcommand.rs index ac7a8a1d..7ed36484 100644 --- a/clap_derive/src/derives/subcommand.rs +++ b/clap_derive/src/derives/subcommand.rs @@ -604,7 +604,7 @@ fn gen_update_from_arg_matches( quote!((ref mut __clap_arg)), quote!(clap::FromArgMatches::update_from_arg_matches( __clap_arg, - __clap_sub_arg_matches + __clap_arg_matches )?), ) } else { @@ -615,7 +615,7 @@ fn gen_update_from_arg_matches( quote! { #name :: #variant_name #pattern if #sub_name == __clap_name => { - let __clap_arg_matches = __clap_sub_arg_matches; + let (_, __clap_arg_matches) = __clap_arg_matches.subcommand().unwrap(); #updater } } @@ -647,7 +647,7 @@ fn gen_update_from_arg_matches( &mut self, __clap_arg_matches: &clap::ArgMatches, ) -> ::std::result::Result<(), clap::Error> { - if let Some((__clap_name, __clap_sub_arg_matches)) = __clap_arg_matches.subcommand() { + if let Some(__clap_name) = __clap_arg_matches.subcommand_name() { match self { #( #subcommands ),* s => {