[PATCH 03/12] rust/qemu-macros: Fix Clippy's complaints about lambda parameter naming

Zhao Liu posted 12 patches 1 week, 5 days ago
There is a newer version of this series
[PATCH 03/12] rust/qemu-macros: Fix Clippy's complaints about lambda parameter naming
Posted by Zhao Liu 1 week, 5 days ago
error: `rename` shadows a previous, unrelated binding
   --> qemu-macros/src/lib.rs:265:14
    |
265 |             |rename| -> Result<proc_macro2::TokenStream, Error> {
    |              ^^^^^^
    |
note: previous binding is here
   --> qemu-macros/src/lib.rs:245:30
    |
245 |         let DeviceProperty { rename, defval } = prop;
    |                              ^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#shadow_unrelated
    = note: requested on the command line with `-D clippy::shadow-unrelated`

Rename the lambda parameter to "prop_rename" to fix the above clippy
error.

Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 rust/qemu-macros/src/lib.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/qemu-macros/src/lib.rs b/rust/qemu-macros/src/lib.rs
index 830b4326985b..ed4064d6e110 100644
--- a/rust/qemu-macros/src/lib.rs
+++ b/rust/qemu-macros/src/lib.rs
@@ -262,8 +262,8 @@ macro_rules! str_to_c_str {
 
         let prop_name = rename.map_or_else(
             || str_to_c_str!(field_name.to_string(), field_name.span()),
-            |rename| -> Result<proc_macro2::TokenStream, Error> {
-                match rename {
+            |prop_rename| -> Result<proc_macro2::TokenStream, Error> {
+                match prop_rename {
                     DevicePropertyName::CStr(cstr_lit) => Ok(quote! { #cstr_lit }),
                     DevicePropertyName::Str(str_lit) => {
                         str_to_c_str!(str_lit.value(), str_lit.span())
-- 
2.34.1
Re: [PATCH 03/12] rust/qemu-macros: Fix Clippy's complaints about lambda parameter naming
Posted by Manos Pitsidianakis 1 week, 5 days ago
On Tue, Sep 16, 2025 at 11:34 AM Zhao Liu <zhao1.liu@intel.com> wrote:
>
> error: `rename` shadows a previous, unrelated binding
>    --> qemu-macros/src/lib.rs:265:14
>     |
> 265 |             |rename| -> Result<proc_macro2::TokenStream, Error> {
>     |              ^^^^^^
>     |
> note: previous binding is here
>    --> qemu-macros/src/lib.rs:245:30
>     |
> 245 |         let DeviceProperty { rename, defval } = prop;
>     |                              ^^^^^^
>     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#shadow_unrelated
>     = note: requested on the command line with `-D clippy::shadow-unrelated`
>
> Rename the lambda parameter to "prop_rename" to fix the above clippy
> error.
>
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>

>  rust/qemu-macros/src/lib.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/rust/qemu-macros/src/lib.rs b/rust/qemu-macros/src/lib.rs
> index 830b4326985b..ed4064d6e110 100644
> --- a/rust/qemu-macros/src/lib.rs
> +++ b/rust/qemu-macros/src/lib.rs
> @@ -262,8 +262,8 @@ macro_rules! str_to_c_str {
>
>          let prop_name = rename.map_or_else(
>              || str_to_c_str!(field_name.to_string(), field_name.span()),
> -            |rename| -> Result<proc_macro2::TokenStream, Error> {
> -                match rename {
> +            |prop_rename| -> Result<proc_macro2::TokenStream, Error> {
> +                match prop_rename {
>                      DevicePropertyName::CStr(cstr_lit) => Ok(quote! { #cstr_lit }),
>                      DevicePropertyName::Str(str_lit) => {
>                          str_to_c_str!(str_lit.value(), str_lit.span())
> --
> 2.34.1
>