Skip to content

Commit

Permalink
Suppress unused variable warning for debug_print macros (#1258)
Browse files Browse the repository at this point in the history
* Suppress unused variable error for debug_print macros

* Add explicit seperator

* Let's try to match expressions
  • Loading branch information
athei committed May 18, 2022
1 parent 57741b5 commit b6dd935
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions crates/env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:expr),*) => ($crate::debug_message(&$crate::format!($($arg),*)));
}

/// Appends a formatted string to the `debug_message` buffer, as per [`debug_print`] but
Expand All @@ -144,22 +144,32 @@ cfg_if::cfg_if! {
#[macro_export]
macro_rules! debug_println {
() => ($crate::debug_print!("\n"));
($($arg:tt)*) => (
$crate::debug_print!("{}\n", $crate::format!($($arg)*));
($($arg:expr),*) => (
$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:expr),*) =>
{
{
let _ = || ($(&$arg),*);
}
};
}

#[macro_export]
/// Debug messages disabled. Enable the `ink-debug` feature for contract debugging.
macro_rules! debug_println {
() => ();
($($arg:tt)*) => ();
() => {};
($($arg:expr),*) =>
{
{
let _ = || ($(&$arg),*);
}
};
}
}
}

0 comments on commit b6dd935

Please sign in to comment.