[PATCH 3/4] rust: macros: prefix variable `span` with underscore

Jesung Yang posted 4 patches 3 months, 2 weeks ago
[PATCH 3/4] rust: macros: prefix variable `span` with underscore
Posted by Jesung Yang 3 months, 2 weeks ago
Prefix the variable `span` in `quote_spanned!` macro with an underscore
to silence unused variable warnings.

The warning occurs when the macro is used without any uninterpolated
identifiers. For example:

    // Triggers a warning: "unused variable: `span`"
    quote! { #foo }

    // This is fine
    quote! { Some(#foo) }

There is no good reason to disallow such quoting patterns, so fix the
warning instead.

Signed-off-by: Jesung Yang <y.j3ms.n@gmail.com>
---
 rust/macros/quote.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/macros/quote.rs b/rust/macros/quote.rs
index d05f60f55623..e6c36bd7f925 100644
--- a/rust/macros/quote.rs
+++ b/rust/macros/quote.rs
@@ -63,8 +63,8 @@ macro_rules! quote_spanned {
         #[allow(clippy::vec_init_then_push)]
         {
             tokens = ::std::vec::Vec::new();
-            let span = $span;
-            quote_spanned!(@proc tokens span $($tt)*);
+            let _span = $span;
+            quote_spanned!(@proc tokens _span $($tt)*);
         }
         ::proc_macro::TokenStream::from_iter(tokens)
     }};
-- 
2.39.5