about summary refs log tree commit diff
path: root/src/liblog/macros.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-03-02 14:51:24 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-03-05 14:51:38 -0800
commitd5d834551cd5a7e7d89ac9f2ae642a93409ed989 (patch)
tree8b6899fc59d1e34bd93cedf3ad15dafae37be8a9 /src/liblog/macros.rs
parent68740b405404a3f885e388c8d31722797d519c30 (diff)
downloadrust-d5d834551cd5a7e7d89ac9f2ae642a93409ed989.tar.gz
rust-d5d834551cd5a7e7d89ac9f2ae642a93409ed989.zip
rustc: Add a debug_assertions #[cfg] directive
This commit is an implementation of [RFC 563][rfc] which adds a new
`cfg(debug_assertions)` directive which is specially recognized and calculated
by the compiler. The flag is turned off at any optimization level greater than 1
and may also be explicitly controlled through the `-C debug-assertions`
flag.

[rfc]: https://github.com/rust-lang/rfcs/pull/563

The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of
the `ndebug` variable and `ndebug` no longer holds any meaning to the standard
library.

Code which was previously relying on `not(ndebug)` to gate expensive code should
be updated to rely on `debug_assertions` instead.

Closes #22492
[breaking-change]
Diffstat (limited to 'src/liblog/macros.rs')
-rw-r--r--src/liblog/macros.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs
index 4a9a9bd4060..f0f861a3831 100644
--- a/src/liblog/macros.rs
+++ b/src/liblog/macros.rs
@@ -157,7 +157,7 @@ macro_rules! info {
 /// ```
 #[macro_export]
 macro_rules! debug {
-    ($($arg:tt)*) => (if cfg!(not(ndebug)) { log!(::log::DEBUG, $($arg)*) })
+    ($($arg:tt)*) => (if cfg!(debug_assertions) { log!(::log::DEBUG, $($arg)*) })
 }
 
 /// A macro to test whether a log level is enabled for the current module.
@@ -192,7 +192,7 @@ macro_rules! debug {
 macro_rules! log_enabled {
     ($lvl:expr) => ({
         let lvl = $lvl;
-        (lvl != ::log::DEBUG || cfg!(not(ndebug))) &&
+        (lvl != ::log::DEBUG || cfg!(debug_assertions)) &&
         lvl <= ::log::log_level() &&
         ::log::mod_enabled(lvl, module_path!())
     })