]> git.lizzy.rs Git - rust.git/blob - src/libcore/macros.rs
Rollup merge of #40241 - Sawyer47:fix-39997, r=alexcrichton
[rust.git] / src / libcore / macros.rs
1 // Copyright 2014 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 /// Entry point of thread panic, for details, see std::macros
12 #[macro_export]
13 #[allow_internal_unstable]
14 #[stable(feature = "core", since = "1.6.0")]
15 macro_rules! panic {
16     () => (
17         panic!("explicit panic")
18     );
19     ($msg:expr) => ({
20         static _MSG_FILE_LINE: (&'static str, &'static str, u32) = ($msg, file!(), line!());
21         $crate::panicking::panic(&_MSG_FILE_LINE)
22     });
23     ($fmt:expr, $($arg:tt)*) => ({
24         // The leading _'s are to avoid dead code warnings if this is
25         // used inside a dead function. Just `#[allow(dead_code)]` is
26         // insufficient, since the user may have
27         // `#[forbid(dead_code)]` and which cannot be overridden.
28         static _FILE_LINE: (&'static str, u32) = (file!(), line!());
29         $crate::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE)
30     });
31 }
32
33 /// Ensure that a boolean expression is `true` at runtime.
34 ///
35 /// This will invoke the [`panic!`] macro if the provided expression cannot be
36 /// evaluated to `true` at runtime.
37 ///
38 /// Assertions are always checked in both debug and release builds, and cannot
39 /// be disabled. See [`debug_assert!`] for assertions that are not enabled in
40 /// release builds by default.
41 ///
42 /// Unsafe code relies on `assert!` to enforce run-time invariants that, if
43 /// violated could lead to unsafety.
44 ///
45 /// Other use-cases of `assert!` include [testing] and enforcing run-time
46 /// invariants in safe code (whose violation cannot result in unsafety).
47 ///
48 /// This macro has a second version, where a custom panic message can
49 /// be provided with or without arguments for formatting.
50 ///
51 /// [`panic!`]: macro.panic.html
52 /// [`debug_assert!`]: macro.debug_assert.html
53 /// [testing]: ../book/testing.html
54 ///
55 /// # Examples
56 ///
57 /// ```
58 /// // the panic message for these assertions is the stringified value of the
59 /// // expression given.
60 /// assert!(true);
61 ///
62 /// fn some_computation() -> bool { true } // a very simple function
63 ///
64 /// assert!(some_computation());
65 ///
66 /// // assert with a custom message
67 /// let x = true;
68 /// assert!(x, "x wasn't true!");
69 ///
70 /// let a = 3; let b = 27;
71 /// assert!(a + b == 30, "a = {}, b = {}", a, b);
72 /// ```
73 #[macro_export]
74 #[stable(feature = "rust1", since = "1.0.0")]
75 macro_rules! assert {
76     ($cond:expr) => (
77         if !$cond {
78             panic!(concat!("assertion failed: ", stringify!($cond)))
79         }
80     );
81     ($cond:expr, $($arg:tt)+) => (
82         if !$cond {
83             panic!($($arg)+)
84         }
85     );
86 }
87
88 /// Asserts that two expressions are equal to each other.
89 ///
90 /// On panic, this macro will print the values of the expressions with their
91 /// debug representations.
92 ///
93 /// Like [`assert!`], this macro has a second version, where a custom
94 /// panic message can be provided.
95 ///
96 /// [`assert!`]: macro.assert.html
97 ///
98 /// # Examples
99 ///
100 /// ```
101 /// let a = 3;
102 /// let b = 1 + 2;
103 /// assert_eq!(a, b);
104 ///
105 /// assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
106 /// ```
107 #[macro_export]
108 #[stable(feature = "rust1", since = "1.0.0")]
109 macro_rules! assert_eq {
110     ($left:expr, $right:expr) => ({
111         match (&$left, &$right) {
112             (left_val, right_val) => {
113                 if !(*left_val == *right_val) {
114                     panic!("assertion failed: `(left == right)` \
115                            (left: `{:?}`, right: `{:?}`)", left_val, right_val)
116                 }
117             }
118         }
119     });
120     ($left:expr, $right:expr, $($arg:tt)+) => ({
121         match (&($left), &($right)) {
122             (left_val, right_val) => {
123                 if !(*left_val == *right_val) {
124                     panic!("assertion failed: `(left == right)` \
125                            (left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
126                            format_args!($($arg)+))
127                 }
128             }
129         }
130     });
131 }
132
133 /// Asserts that two expressions are not equal to each other.
134 ///
135 /// On panic, this macro will print the values of the expressions with their
136 /// debug representations.
137 ///
138 /// Like `assert!()`, this macro has a second version, where a custom
139 /// panic message can be provided.
140 ///
141 /// [`assert!`]: macro.assert.html
142 ///
143 /// # Examples
144 ///
145 /// ```
146 /// let a = 3;
147 /// let b = 2;
148 /// assert_ne!(a, b);
149 ///
150 /// assert_ne!(a, b, "we are testing that the values are not equal");
151 /// ```
152 #[macro_export]
153 #[stable(feature = "assert_ne", since = "1.12.0")]
154 macro_rules! assert_ne {
155     ($left:expr, $right:expr) => ({
156         match (&$left, &$right) {
157             (left_val, right_val) => {
158                 if *left_val == *right_val {
159                     panic!("assertion failed: `(left != right)` \
160                            (left: `{:?}`, right: `{:?}`)", left_val, right_val)
161                 }
162             }
163         }
164     });
165     ($left:expr, $right:expr, $($arg:tt)+) => ({
166         match (&($left), &($right)) {
167             (left_val, right_val) => {
168                 if *left_val == *right_val {
169                     panic!("assertion failed: `(left != right)` \
170                            (left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
171                            format_args!($($arg)+))
172                 }
173             }
174         }
175     });
176 }
177
178 /// Ensure that a boolean expression is `true` at runtime.
179 ///
180 /// This will invoke the [`panic!`] macro if the provided expression cannot be
181 /// evaluated to `true` at runtime.
182 ///
183 /// Like [`assert!`], this macro also has a second version, where a custom panic
184 /// message can be provided.
185 ///
186 /// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
187 /// optimized builds by default. An optimized build will omit all
188 /// `debug_assert!` statements unless `-C debug-assertions` is passed to the
189 /// compiler. This makes `debug_assert!` useful for checks that are too
190 /// expensive to be present in a release build but may be helpful during
191 /// development.
192 ///
193 /// An unchecked assertion allows a program in an inconsistent state to keep
194 /// running, which might have unexpected consequences but does not introduce
195 /// unsafety as long as this only happens in safe code. The performance cost
196 /// of assertions, is however, not measurable in general. Replacing [`assert!`]
197 /// with `debug_assert!` is thus only encouraged after thorough profiling, and
198 /// more importantly, only in safe code!
199 ///
200 /// [`panic!`]: macro.panic.html
201 /// [`assert!`]: macro.assert.html
202 ///
203 /// # Examples
204 ///
205 /// ```
206 /// // the panic message for these assertions is the stringified value of the
207 /// // expression given.
208 /// debug_assert!(true);
209 ///
210 /// fn some_expensive_computation() -> bool { true } // a very simple function
211 /// debug_assert!(some_expensive_computation());
212 ///
213 /// // assert with a custom message
214 /// let x = true;
215 /// debug_assert!(x, "x wasn't true!");
216 ///
217 /// let a = 3; let b = 27;
218 /// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
219 /// ```
220 #[macro_export]
221 #[stable(feature = "rust1", since = "1.0.0")]
222 macro_rules! debug_assert {
223     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); })
224 }
225
226 /// Asserts that two expressions are equal to each other.
227 ///
228 /// On panic, this macro will print the values of the expressions with their
229 /// debug representations.
230 ///
231 /// Unlike `assert_eq!`, `debug_assert_eq!` statements are only enabled in non
232 /// optimized builds by default. An optimized build will omit all
233 /// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
234 /// compiler. This makes `debug_assert_eq!` useful for checks that are too
235 /// expensive to be present in a release build but may be helpful during
236 /// development.
237 ///
238 /// # Examples
239 ///
240 /// ```
241 /// let a = 3;
242 /// let b = 1 + 2;
243 /// debug_assert_eq!(a, b);
244 /// ```
245 #[macro_export]
246 #[stable(feature = "rust1", since = "1.0.0")]
247 macro_rules! debug_assert_eq {
248     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
249 }
250
251 /// Asserts that two expressions are not equal to each other.
252 ///
253 /// On panic, this macro will print the values of the expressions with their
254 /// debug representations.
255 ///
256 /// Unlike `assert_ne!`, `debug_assert_ne!` statements are only enabled in non
257 /// optimized builds by default. An optimized build will omit all
258 /// `debug_assert_ne!` statements unless `-C debug-assertions` is passed to the
259 /// compiler. This makes `debug_assert_ne!` useful for checks that are too
260 /// expensive to be present in a release build but may be helpful during
261 /// development.
262 ///
263 /// # Examples
264 ///
265 /// ```
266 /// let a = 3;
267 /// let b = 2;
268 /// debug_assert_ne!(a, b);
269 /// ```
270 #[macro_export]
271 #[stable(feature = "assert_ne", since = "1.12.0")]
272 macro_rules! debug_assert_ne {
273     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); })
274 }
275
276 /// Helper macro for reducing boilerplate code for matching `Result` together
277 /// with converting downstream errors.
278 ///
279 /// Prefer using `?` syntax to `try!`. `?` is built in to the language and is
280 /// more succinct than `try!`. It is the standard method for error propagation.
281 ///
282 /// `try!` matches the given `Result`. In case of the `Ok` variant, the
283 /// expression has the value of the wrapped value.
284 ///
285 /// In case of the `Err` variant, it retrieves the inner error. `try!` then
286 /// performs conversion using `From`. This provides automatic conversion
287 /// between specialized errors and more general ones. The resulting
288 /// error is then immediately returned.
289 ///
290 /// Because of the early return, `try!` can only be used in functions that
291 /// return `Result`.
292 ///
293 /// # Examples
294 ///
295 /// ```
296 /// use std::io;
297 /// use std::fs::File;
298 /// use std::io::prelude::*;
299 ///
300 /// enum MyError {
301 ///     FileWriteError
302 /// }
303 ///
304 /// impl From<io::Error> for MyError {
305 ///     fn from(e: io::Error) -> MyError {
306 ///         MyError::FileWriteError
307 ///     }
308 /// }
309 ///
310 /// fn write_to_file_using_try() -> Result<(), MyError> {
311 ///     let mut file = try!(File::create("my_best_friends.txt"));
312 ///     try!(file.write_all(b"This is a list of my best friends."));
313 ///     println!("I wrote to the file");
314 ///     Ok(())
315 /// }
316 /// // This is equivalent to:
317 /// fn write_to_file_using_match() -> Result<(), MyError> {
318 ///     let mut file = try!(File::create("my_best_friends.txt"));
319 ///     match file.write_all(b"This is a list of my best friends.") {
320 ///         Ok(v) => v,
321 ///         Err(e) => return Err(From::from(e)),
322 ///     }
323 ///     println!("I wrote to the file");
324 ///     Ok(())
325 /// }
326 /// ```
327 #[macro_export]
328 #[stable(feature = "rust1", since = "1.0.0")]
329 macro_rules! try {
330     ($expr:expr) => (match $expr {
331         $crate::result::Result::Ok(val) => val,
332         $crate::result::Result::Err(err) => {
333             return $crate::result::Result::Err($crate::convert::From::from(err))
334         }
335     })
336 }
337
338 /// Write formatted data into a buffer
339 ///
340 /// This macro accepts a 'writer' (any value with a `write_fmt` method), a format string, and a
341 /// list of arguments to format.
342 ///
343 /// The `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write]
344 /// or [`std::io::Write`][io_write] traits. The term 'writer' refers to an implementation of one of
345 /// these two traits.
346 ///
347 /// Passed arguments will be formatted according to the specified format string and the resulting
348 /// string will be passed to the writer.
349 ///
350 /// See [`std::fmt`][fmt] for more information on format syntax.
351 ///
352 /// `write!` returns whatever the 'write_fmt' method returns.
353 ///
354 /// Common return values include: [`fmt::Result`][fmt_result], [`io::Result`][io_result]
355 ///
356 /// [fmt]: ../std/fmt/index.html
357 /// [fmt_write]: ../std/fmt/trait.Write.html
358 /// [io_write]: ../std/io/trait.Write.html
359 /// [fmt_result]: ../std/fmt/type.Result.html
360 /// [io_result]: ../std/io/type.Result.html
361 ///
362 /// # Examples
363 ///
364 /// ```
365 /// use std::io::Write;
366 ///
367 /// let mut w = Vec::new();
368 /// write!(&mut w, "test").unwrap();
369 /// write!(&mut w, "formatted {}", "arguments").unwrap();
370 ///
371 /// assert_eq!(w, b"testformatted arguments");
372 /// ```
373 ///
374 /// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
375 /// implementing either, as objects do not typically implement both. However, the module must
376 /// import the traits qualified so their names do not conflict:
377 ///
378 /// ```
379 /// use std::fmt::Write as FmtWrite;
380 /// use std::io::Write as IoWrite;
381 ///
382 /// let mut s = String::new();
383 /// let mut v = Vec::new();
384 /// write!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
385 /// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
386 /// assert_eq!(v, b"s = \"abc 123\"");
387 /// ```
388 #[macro_export]
389 #[stable(feature = "core", since = "1.6.0")]
390 macro_rules! write {
391     ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
392 }
393
394 /// Write formatted data into a buffer, with a newline appended.
395 ///
396 /// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
397 /// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
398 ///
399 /// This macro accepts a 'writer' (any value with a `write_fmt` method), a format string, and a
400 /// list of arguments to format.
401 ///
402 /// The `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write]
403 /// or [`std::io::Write`][io_write] traits. The term 'writer' refers to an implementation of one of
404 /// these two traits.
405 ///
406 /// Passed arguments will be formatted according to the specified format string and the resulting
407 /// string will be passed to the writer, along with the appended newline.
408 ///
409 /// See [`std::fmt`][fmt] for more information on format syntax.
410 ///
411 /// `write!` returns whatever the 'write_fmt' method returns.
412 ///
413 /// Common return values include: [`fmt::Result`][fmt_result], [`io::Result`][io_result]
414 ///
415 /// [fmt]: ../std/fmt/index.html
416 /// [fmt_write]: ../std/fmt/trait.Write.html
417 /// [io_write]: ../std/io/trait.Write.html
418 /// [fmt_result]: ../std/fmt/type.Result.html
419 /// [io_result]: ../std/io/type.Result.html
420 ///
421 /// # Examples
422 ///
423 /// ```
424 /// use std::io::Write;
425 ///
426 /// let mut w = Vec::new();
427 /// writeln!(&mut w).unwrap();
428 /// writeln!(&mut w, "test").unwrap();
429 /// writeln!(&mut w, "formatted {}", "arguments").unwrap();
430 ///
431 /// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
432 /// ```
433 ///
434 /// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
435 /// implementing either, as objects do not typically implement both. However, the module must
436 /// import the traits qualified so their names do not conflict:
437 ///
438 /// ```
439 /// use std::fmt::Write as FmtWrite;
440 /// use std::io::Write as IoWrite;
441 ///
442 /// let mut s = String::new();
443 /// let mut v = Vec::new();
444 /// writeln!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
445 /// writeln!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
446 /// assert_eq!(v, b"s = \"abc 123\\n\"\n");
447 /// ```
448 #[macro_export]
449 #[stable(feature = "rust1", since = "1.0.0")]
450 macro_rules! writeln {
451     ($dst:expr) => (
452         write!($dst, "\n")
453     );
454     ($dst:expr, $fmt:expr) => (
455         write!($dst, concat!($fmt, "\n"))
456     );
457     ($dst:expr, $fmt:expr, $($arg:tt)*) => (
458         write!($dst, concat!($fmt, "\n"), $($arg)*)
459     );
460 }
461
462 /// A utility macro for indicating unreachable code.
463 ///
464 /// This is useful any time that the compiler can't determine that some code is unreachable. For
465 /// example:
466 ///
467 /// * Match arms with guard conditions.
468 /// * Loops that dynamically terminate.
469 /// * Iterators that dynamically terminate.
470 ///
471 /// # Panics
472 ///
473 /// This will always panic.
474 ///
475 /// # Examples
476 ///
477 /// Match arms:
478 ///
479 /// ```
480 /// # #[allow(dead_code)]
481 /// fn foo(x: Option<i32>) {
482 ///     match x {
483 ///         Some(n) if n >= 0 => println!("Some(Non-negative)"),
484 ///         Some(n) if n <  0 => println!("Some(Negative)"),
485 ///         Some(_)           => unreachable!(), // compile error if commented out
486 ///         None              => println!("None")
487 ///     }
488 /// }
489 /// ```
490 ///
491 /// Iterators:
492 ///
493 /// ```
494 /// # #[allow(dead_code)]
495 /// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
496 ///     for i in 0.. {
497 ///         if 3*i < i { panic!("u32 overflow"); }
498 ///         if x < 3*i { return i-1; }
499 ///     }
500 ///     unreachable!();
501 /// }
502 /// ```
503 #[macro_export]
504 #[stable(feature = "core", since = "1.6.0")]
505 macro_rules! unreachable {
506     () => ({
507         panic!("internal error: entered unreachable code")
508     });
509     ($msg:expr) => ({
510         unreachable!("{}", $msg)
511     });
512     ($fmt:expr, $($arg:tt)*) => ({
513         panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
514     });
515 }
516
517 /// A standardized placeholder for marking unfinished code. It panics with the
518 /// message `"not yet implemented"` when executed.
519 ///
520 /// This can be useful if you are prototyping and are just looking to have your
521 /// code typecheck, or if you're implementing a trait that requires multiple
522 /// methods, and you're only planning on using one of them.
523 ///
524 /// # Examples
525 ///
526 /// Here's an example of some in-progress code. We have a trait `Foo`:
527 ///
528 /// ```
529 /// trait Foo {
530 ///     fn bar(&self);
531 ///     fn baz(&self);
532 /// }
533 /// ```
534 ///
535 /// We want to implement `Foo` on one of our types, but we also want to work on
536 /// just `bar()` first. In order for our code to compile, we need to implement
537 /// `baz()`, so we can use `unimplemented!`:
538 ///
539 /// ```
540 /// # trait Foo {
541 /// #     fn bar(&self);
542 /// #     fn baz(&self);
543 /// # }
544 /// struct MyStruct;
545 ///
546 /// impl Foo for MyStruct {
547 ///     fn bar(&self) {
548 ///         // implementation goes here
549 ///     }
550 ///
551 ///     fn baz(&self) {
552 ///         // let's not worry about implementing baz() for now
553 ///         unimplemented!();
554 ///     }
555 /// }
556 ///
557 /// fn main() {
558 ///     let s = MyStruct;
559 ///     s.bar();
560 ///
561 ///     // we aren't even using baz() yet, so this is fine.
562 /// }
563 /// ```
564 #[macro_export]
565 #[stable(feature = "core", since = "1.6.0")]
566 macro_rules! unimplemented {
567     () => (panic!("not yet implemented"))
568 }
569
570 /// Built-in macros to the compiler itself.
571 ///
572 /// These macros do not have any corresponding definition with a `macro_rules!`
573 /// macro, but are documented here. Their implementations can be found hardcoded
574 /// into libsyntax itself.
575 ///
576 /// For more information, see documentation for `std`'s macros.
577 mod builtin {
578     /// The core macro for formatted string creation & output.
579     ///
580     /// For more information, see the documentation for [`std::format_args!`].
581     ///
582     /// [`std::format_args!`]: ../std/macro.format_args.html
583     #[stable(feature = "rust1", since = "1.0.0")]
584     #[macro_export]
585     #[cfg(dox)]
586     macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
587         /* compiler built-in */
588     }) }
589
590     /// Inspect an environment variable at compile time.
591     ///
592     /// For more information, see the documentation for [`std::env!`].
593     ///
594     /// [`std::env!`]: ../std/macro.env.html
595     #[stable(feature = "rust1", since = "1.0.0")]
596     #[macro_export]
597     #[cfg(dox)]
598     macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }
599
600     /// Optionally inspect an environment variable at compile time.
601     ///
602     /// For more information, see the documentation for [`std::option_env!`].
603     ///
604     /// [`std::option_env!`]: ../std/macro.option_env.html
605     #[stable(feature = "rust1", since = "1.0.0")]
606     #[macro_export]
607     #[cfg(dox)]
608     macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
609
610     /// Concatenate identifiers into one identifier.
611     ///
612     /// For more information, see the documentation for [`std::concat_idents!`].
613     ///
614     /// [`std::concat_idents!`]: ../std/macro.concat_idents.html
615     #[unstable(feature = "concat_idents_macro", issue = "29599")]
616     #[macro_export]
617     #[cfg(dox)]
618     macro_rules! concat_idents {
619         ($($e:ident),*) => ({ /* compiler built-in */ })
620     }
621
622     /// Concatenates literals into a static string slice.
623     ///
624     /// For more information, see the documentation for [`std::concat!`].
625     ///
626     /// [`std::concat!`]: ../std/macro.concat.html
627     #[stable(feature = "rust1", since = "1.0.0")]
628     #[macro_export]
629     #[cfg(dox)]
630     macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) }
631
632     /// A macro which expands to the line number on which it was invoked.
633     ///
634     /// For more information, see the documentation for [`std::line!`].
635     ///
636     /// [`std::line!`]: ../std/macro.line.html
637     #[stable(feature = "rust1", since = "1.0.0")]
638     #[macro_export]
639     #[cfg(dox)]
640     macro_rules! line { () => ({ /* compiler built-in */ }) }
641
642     /// A macro which expands to the column number on which it was invoked.
643     ///
644     /// For more information, see the documentation for [`std::column!`].
645     ///
646     /// [`std::column!`]: ../std/macro.column.html
647     #[stable(feature = "rust1", since = "1.0.0")]
648     #[macro_export]
649     #[cfg(dox)]
650     macro_rules! column { () => ({ /* compiler built-in */ }) }
651
652     /// A macro which expands to the file name from which it was invoked.
653     ///
654     /// For more information, see the documentation for [`std::file!`].
655     ///
656     /// [`std::file!`]: ../std/macro.file.html
657     #[stable(feature = "rust1", since = "1.0.0")]
658     #[macro_export]
659     #[cfg(dox)]
660     macro_rules! file { () => ({ /* compiler built-in */ }) }
661
662     /// A macro which stringifies its argument.
663     ///
664     /// For more information, see the documentation for [`std::stringify!`].
665     ///
666     /// [`std::stringify!`]: ../std/macro.stringify.html
667     #[stable(feature = "rust1", since = "1.0.0")]
668     #[macro_export]
669     #[cfg(dox)]
670     macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) }
671
672     /// Includes a utf8-encoded file as a string.
673     ///
674     /// For more information, see the documentation for [`std::include_str!`].
675     ///
676     /// [`std::include_str!`]: ../std/macro.include_str.html
677     #[stable(feature = "rust1", since = "1.0.0")]
678     #[macro_export]
679     #[cfg(dox)]
680     macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) }
681
682     /// Includes a file as a reference to a byte array.
683     ///
684     /// For more information, see the documentation for [`std::include_bytes!`].
685     ///
686     /// [`std::include_bytes!`]: ../std/macro.include_bytes.html
687     #[stable(feature = "rust1", since = "1.0.0")]
688     #[macro_export]
689     #[cfg(dox)]
690     macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }
691
692     /// Expands to a string that represents the current module path.
693     ///
694     /// For more information, see the documentation for [`std::module_path!`].
695     ///
696     /// [`std::module_path!`]: ../std/macro.module_path.html
697     #[stable(feature = "rust1", since = "1.0.0")]
698     #[macro_export]
699     #[cfg(dox)]
700     macro_rules! module_path { () => ({ /* compiler built-in */ }) }
701
702     /// Boolean evaluation of configuration flags.
703     ///
704     /// For more information, see the documentation for [`std::cfg!`].
705     ///
706     /// [`std::cfg!`]: ../std/macro.cfg.html
707     #[stable(feature = "rust1", since = "1.0.0")]
708     #[macro_export]
709     #[cfg(dox)]
710     macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
711
712     /// Parse a file as an expression or an item according to the context.
713     ///
714     /// For more information, see the documentation for [`std::include!`].
715     ///
716     /// [`std::include!`]: ../std/macro.include.html
717     #[stable(feature = "rust1", since = "1.0.0")]
718     #[macro_export]
719     #[cfg(dox)]
720     macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) }
721 }