diff --git a/src/lib.rs b/src/lib.rs index 4738fb965..732637801 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1504,34 +1504,59 @@ pub mod __private_api { /// [`logger`]: fn.logger.html pub const STATIC_MAX_LEVEL: LevelFilter = MAX_LEVEL_INNER; -#[rustfmt::skip] -const MAX_LEVEL_INNER: LevelFilter = { - if cfg!(all(not(debug_assertions), feature = "release_max_level_off")) { - LevelFilter::Off - } else if cfg!(all(not(debug_assertions), feature = "release_max_level_error")) { - LevelFilter::Error - } else if cfg!(all(not(debug_assertions), feature = "release_max_level_warn")) { - LevelFilter::Warn - } else if cfg!(all(not(debug_assertions), feature = "release_max_level_info")) { - LevelFilter::Info - } else if cfg!(all(not(debug_assertions), feature = "release_max_level_debug")) { - LevelFilter::Debug - } else if cfg!(all(not(debug_assertions), feature = "release_max_level_trace")) { - LevelFilter::Trace - } else if cfg!(feature = "max_level_off") { - LevelFilter::Off - } else if cfg!(feature = "max_level_error") { - LevelFilter::Error - } else if cfg!(feature = "max_level_warn") { - LevelFilter::Warn - } else if cfg!(feature = "max_level_info") { - LevelFilter::Info - } else if cfg!(feature = "max_level_debug") { - LevelFilter::Debug - } else { +const MAX_LEVEL_INNER: LevelFilter = get_max_level_inner(); + +const fn get_max_level_inner() -> LevelFilter { + #[allow(unreachable_code)] + { + #[cfg(all(not(debug_assertions), feature = "release_max_level_off"))] + { + return LevelFilter::Off; + } + #[cfg(all(not(debug_assertions), feature = "release_max_level_error"))] + { + return LevelFilter::Error; + } + #[cfg(all(not(debug_assertions), feature = "release_max_level_warn"))] + { + return LevelFilter::Warn; + } + #[cfg(all(not(debug_assertions), feature = "release_max_level_info"))] + { + return LevelFilter::Info; + } + #[cfg(all(not(debug_assertions), feature = "release_max_level_debug"))] + { + return LevelFilter::Debug; + } + #[cfg(all(not(debug_assertions), feature = "release_max_level_trace"))] + { + return LevelFilter::Trace; + } + #[cfg(feature = "max_level_off")] + { + return LevelFilter::Off; + } + #[cfg(feature = "max_level_error")] + { + return LevelFilter::Error; + } + #[cfg(feature = "max_level_warn")] + { + return LevelFilter::Warn; + } + #[cfg(feature = "max_level_info")] + { + return LevelFilter::Info; + } + #[cfg(feature = "max_level_debug")] + { + return LevelFilter::Debug; + } + LevelFilter::Trace } -}; +} #[cfg(test)] mod tests {