`macros`: match unused vars if logging is disabled
@@ -480,13 +480,11 @@ fn cfg_if_logging_enabled(level: Level) -> TokenStream2 {
let features_release = necessary_features_for_level(level, false);
quote!(
- cfg(
any(
all( debug_assertions, any(#( feature = #features_dev ),*)),
all(not(debug_assertions), any(#( feature = #features_release ),*))
)
)
- )
}
fn log_ts(level: Level, ts: TokenStream) -> TokenStream {
@@ -513,7 +511,7 @@ fn log(level: Level, log: FormatArgs) -> TokenStream2 {
let sym = mksym(&ls, level.as_str(), true);
let logging_enabled = cfg_if_logging_enabled(level);
quote!({
- #[#logging_enabled] {
+ #[cfg(#logging_enabled)] {
match (#(&(#args)),*) {
(#(#pats),*) => {
if let Some(mut _fmt_) = defmt::export::acquire() {
@@ -525,6 +523,11 @@ fn log(level: Level, log: FormatArgs) -> TokenStream2 {
}
}
}
+ // if logging is disabled match args, so they are not unused
+ #[cfg(not(#logging_enabled))]
+ match (#(&(#args)),*) {
+ _ => {}
+ }
})
}
