diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-02 14:51:24 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-05 14:51:38 -0800 |
| commit | d5d834551cd5a7e7d89ac9f2ae642a93409ed989 (patch) | |
| tree | 8b6899fc59d1e34bd93cedf3ad15dafae37be8a9 /src/test/run-make/debug-assertions/Makefile | |
| parent | 68740b405404a3f885e388c8d31722797d519c30 (diff) | |
| download | rust-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/test/run-make/debug-assertions/Makefile')
| -rw-r--r-- | src/test/run-make/debug-assertions/Makefile | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/run-make/debug-assertions/Makefile b/src/test/run-make/debug-assertions/Makefile new file mode 100644 index 00000000000..71297562768 --- /dev/null +++ b/src/test/run-make/debug-assertions/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +all: + $(RUSTC) debug.rs -C debug-assertions=no + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=0 + $(call RUN,debug) bad + $(RUSTC) debug.rs -C opt-level=1 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=2 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=3 + $(call RUN,debug) good + $(RUSTC) debug.rs -O + $(call RUN,debug) good + $(RUSTC) debug.rs + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -O + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1 + $(call RUN,debug) bad |
