]> git.lizzy.rs Git - rust.git/blob - src/libstd/rt/macros.rs
rollup merge of #20482: kmcallister/macro-reform
[rust.git] / src / libstd / rt / macros.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Macros used by the runtime.
12 //!
13 //! These macros call functions which are only accessible in the `rt` module, so
14 //! they aren't defined anywhere outside of the `rt` module.
15
16 macro_rules! rterrln {
17     ($fmt:expr $($arg:tt)*) => ( {
18         ::rt::util::dumb_print(format_args!(concat!($fmt, "\n") $($arg)*))
19     } )
20 }
21
22 // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build.
23 macro_rules! rtdebug {
24     ($($arg:tt)*) => ( {
25         if cfg!(rtdebug) {
26             rterrln!($($arg)*)
27         }
28     })
29 }
30
31 macro_rules! rtassert {
32     ( $arg:expr ) => ( {
33         if ::rt::util::ENFORCE_SANITY {
34             if !$arg {
35                 rtabort!(" assertion failed: {}", stringify!($arg));
36             }
37         }
38     } )
39 }
40
41 macro_rules! rtabort {
42     ($($arg:tt)*) => (::rt::util::abort(format_args!($($arg)*)))
43 }