From 2f6e06140156299b60265e61d12ef3ebeaa36629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 17 May 2022 11:22:38 +0200 Subject: [PATCH 1/3] Suppress unused variable error for debug_print macros --- crates/env/src/lib.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/env/src/lib.rs b/crates/env/src/lib.rs index 306b6ea774e..303550a02ee 100644 --- a/crates/env/src/lib.rs +++ b/crates/env/src/lib.rs @@ -152,14 +152,24 @@ cfg_if::cfg_if! { #[macro_export] /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging. macro_rules! debug_print { - ($($arg:tt)*) => (); + ($($arg:tt)*) => + { + { + let _ = || ($(&$arg)*); + } + }; } #[macro_export] /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging. macro_rules! debug_println { - () => (); - ($($arg:tt)*) => (); + () => {}; + ($($arg:tt)*) => + { + { + let _ = || ($(&$arg)*); + } + }; } } } From d6c2b1ac50f364b41825506a9e030905a916d304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 17 May 2022 11:54:06 +0200 Subject: [PATCH 2/3] Add explicit seperator --- crates/env/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/env/src/lib.rs b/crates/env/src/lib.rs index 303550a02ee..1aabb5b4730 100644 --- a/crates/env/src/lib.rs +++ b/crates/env/src/lib.rs @@ -131,7 +131,7 @@ cfg_if::cfg_if! { /// `"pallet-contracts/unstable-interface"` feature to be enabled in the target runtime. #[macro_export] macro_rules! debug_print { - ($($arg:tt)*) => ($crate::debug_message(&$crate::format!($($arg)*))); + ($($arg:tt),*) => ($crate::debug_message(&$crate::format!($($arg0,)*))); } /// Appends a formatted string to the `debug_message` buffer, as per [`debug_print`] but @@ -144,18 +144,18 @@ cfg_if::cfg_if! { #[macro_export] macro_rules! debug_println { () => ($crate::debug_print!("\n")); - ($($arg:tt)*) => ( - $crate::debug_print!("{}\n", $crate::format!($($arg)*)); + ($($arg:tt),*) => ( + $crate::debug_print!("{}\n", $crate::format!($($arg),*)); ) } } else { #[macro_export] /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging. macro_rules! debug_print { - ($($arg:tt)*) => + ($($arg:tt),*) => { { - let _ = || ($(&$arg)*); + let _ = || ($(&$arg),*); } }; } @@ -164,10 +164,10 @@ cfg_if::cfg_if! { /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging. macro_rules! debug_println { () => {}; - ($($arg:tt)*) => + ($($arg:tt),*) => { { - let _ = || ($(&$arg)*); + let _ = || ($(&$arg),*); } }; } From 2f15aebc6835b230fad7528f8af96e527051f0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Tue, 17 May 2022 12:17:22 +0200 Subject: [PATCH 3/3] Let's try to match expressions --- crates/env/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/env/src/lib.rs b/crates/env/src/lib.rs index 1aabb5b4730..23a51fecce3 100644 --- a/crates/env/src/lib.rs +++ b/crates/env/src/lib.rs @@ -131,7 +131,7 @@ cfg_if::cfg_if! { /// `"pallet-contracts/unstable-interface"` feature to be enabled in the target runtime. #[macro_export] macro_rules! debug_print { - ($($arg:tt),*) => ($crate::debug_message(&$crate::format!($($arg0,)*))); + ($($arg:expr),*) => ($crate::debug_message(&$crate::format!($($arg),*))); } /// Appends a formatted string to the `debug_message` buffer, as per [`debug_print`] but @@ -144,7 +144,7 @@ cfg_if::cfg_if! { #[macro_export] macro_rules! debug_println { () => ($crate::debug_print!("\n")); - ($($arg:tt),*) => ( + ($($arg:expr),*) => ( $crate::debug_print!("{}\n", $crate::format!($($arg),*)); ) } @@ -152,7 +152,7 @@ cfg_if::cfg_if! { #[macro_export] /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging. macro_rules! debug_print { - ($($arg:tt),*) => + ($($arg:expr),*) => { { let _ = || ($(&$arg),*); @@ -164,7 +164,7 @@ cfg_if::cfg_if! { /// Debug messages disabled. Enable the `ink-debug` feature for contract debugging. macro_rules! debug_println { () => {}; - ($($arg:tt),*) => + ($($arg:expr),*) => { { let _ = || ($(&$arg),*);