b48e37e8ee
Macros can be conditionally defined because stripping occurs before macro expansion, but, the built-in macros were only added as part of the actual expansion process and so couldn't be stripped to have definitions conditional on cfg flags. debug! is defined conditionally in terms of the debug config, expanding to nothing unless the --cfg debug flag is passed (to be precise it expands to `if false { normal_debug!(...) }` so that they are still type checked, and to avoid unused variable lints).
21 lines
771 B
Rust
21 lines
771 B
Rust
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution and at
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
// xfail-fast compile-flags directive doesn't work for check-fast
|
|
// compile-flags: --cfg debug
|
|
// exec-env:RUST_LOG=conditional-debug-macro-on=4
|
|
|
|
fn main() {
|
|
// exits early if debug! evaluates its arguments, otherwise it
|
|
// will hit the fail.
|
|
debug!({ if true { return; } });
|
|
|
|
fail!();
|
|
} |