From f931c3d1e40307a1707d965dff60074c4274486c Mon Sep 17 00:00:00 2001 From: CreepySkeleton Date: Thu, 16 Apr 2020 04:32:17 +0300 Subject: [PATCH] Suppress `unused_valiables` lint in non-debug builds --- src/macros.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 3bb48e82..47af7d37 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -740,15 +740,31 @@ mod debug_macros { mod debug_macros { macro_rules! debugln { ($fmt:expr) => {}; - ($fmt:expr, $($arg:tt)*) => {}; + ($fmt:expr, $($arg:tt)*) => { ignore_fmt_args!($($arg)*); }; } macro_rules! sdebugln { ($fmt:expr) => {}; - ($fmt:expr, $($arg:tt)*) => {}; + ($fmt:expr, $($arg:tt)*) => { ignore_fmt_args!($($arg)*); }; } macro_rules! debug { ($fmt:expr) => {}; - ($fmt:expr, $($arg:tt)*) => {}; + ($fmt:expr, $($arg:tt)*) => { ignore_fmt_args!($($arg)*); }; + } + + macro_rules! ignore_fmt_args { + () => {}; + + // name = expr + ($name:ident = $val:expr $( , $($ts:tt)* )?) => { + let _ = $val; + ignore_fmt_args!($($($ts)*)*); + }; + + // expr + ($val:expr $( , $($ts:tt)* )?) => { + let _ = $val; + ignore_fmt_args!($($($ts)*)*); + }; } }