]> git.lizzy.rs Git - rust.git/blob - src/libcore/macros.rs
Auto merge of #58972 - QuietMisdreavus:intra-doc-link-imports, r=GuillaumeGomez
[rust.git] / src / libcore / macros.rs
1 /// Panics the current thread.
2 ///
3 /// For details, see `std::macros`.
4 #[macro_export]
5 #[allow_internal_unstable(core_panic, __rust_unstable_column)]
6 #[stable(feature = "core", since = "1.6.0")]
7 macro_rules! panic {
8     () => (
9         panic!("explicit panic")
10     );
11     ($msg:expr) => ({
12         $crate::panicking::panic(&($msg, file!(), line!(), __rust_unstable_column!()))
13     });
14     ($msg:expr,) => (
15         panic!($msg)
16     );
17     ($fmt:expr, $($arg:tt)+) => ({
18         $crate::panicking::panic_fmt(format_args!($fmt, $($arg)*),
19                                      &(file!(), line!(), __rust_unstable_column!()))
20     });
21 }
22
23 /// Asserts that two expressions are equal to each other (using [`PartialEq`]).
24 ///
25 /// On panic, this macro will print the values of the expressions with their
26 /// debug representations.
27 ///
28 /// Like [`assert!`], this macro has a second form, where a custom
29 /// panic message can be provided.
30 ///
31 /// [`PartialEq`]: cmp/trait.PartialEq.html
32 /// [`assert!`]: macro.assert.html
33 ///
34 /// # Examples
35 ///
36 /// ```
37 /// let a = 3;
38 /// let b = 1 + 2;
39 /// assert_eq!(a, b);
40 ///
41 /// assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
42 /// ```
43 #[macro_export]
44 #[stable(feature = "rust1", since = "1.0.0")]
45 macro_rules! assert_eq {
46     ($left:expr, $right:expr) => ({
47         match (&$left, &$right) {
48             (left_val, right_val) => {
49                 if !(*left_val == *right_val) {
50                     // The reborrows below are intentional. Without them, the stack slot for the
51                     // borrow is initialized even before the values are compared, leading to a
52                     // noticeable slow down.
53                     panic!(r#"assertion failed: `(left == right)`
54   left: `{:?}`,
55  right: `{:?}`"#, &*left_val, &*right_val)
56                 }
57             }
58         }
59     });
60     ($left:expr, $right:expr,) => ({
61         assert_eq!($left, $right)
62     });
63     ($left:expr, $right:expr, $($arg:tt)+) => ({
64         match (&($left), &($right)) {
65             (left_val, right_val) => {
66                 if !(*left_val == *right_val) {
67                     // The reborrows below are intentional. Without them, the stack slot for the
68                     // borrow is initialized even before the values are compared, leading to a
69                     // noticeable slow down.
70                     panic!(r#"assertion failed: `(left == right)`
71   left: `{:?}`,
72  right: `{:?}`: {}"#, &*left_val, &*right_val,
73                            format_args!($($arg)+))
74                 }
75             }
76         }
77     });
78 }
79
80 /// Asserts that two expressions are not equal to each other (using [`PartialEq`]).
81 ///
82 /// On panic, this macro will print the values of the expressions with their
83 /// debug representations.
84 ///
85 /// Like [`assert!`], this macro has a second form, where a custom
86 /// panic message can be provided.
87 ///
88 /// [`PartialEq`]: cmp/trait.PartialEq.html
89 /// [`assert!`]: macro.assert.html
90 ///
91 /// # Examples
92 ///
93 /// ```
94 /// let a = 3;
95 /// let b = 2;
96 /// assert_ne!(a, b);
97 ///
98 /// assert_ne!(a, b, "we are testing that the values are not equal");
99 /// ```
100 #[macro_export]
101 #[stable(feature = "assert_ne", since = "1.13.0")]
102 macro_rules! assert_ne {
103     ($left:expr, $right:expr) => ({
104         match (&$left, &$right) {
105             (left_val, right_val) => {
106                 if *left_val == *right_val {
107                     // The reborrows below are intentional. Without them, the stack slot for the
108                     // borrow is initialized even before the values are compared, leading to a
109                     // noticeable slow down.
110                     panic!(r#"assertion failed: `(left != right)`
111   left: `{:?}`,
112  right: `{:?}`"#, &*left_val, &*right_val)
113                 }
114             }
115         }
116     });
117     ($left:expr, $right:expr,) => {
118         assert_ne!($left, $right)
119     };
120     ($left:expr, $right:expr, $($arg:tt)+) => ({
121         match (&($left), &($right)) {
122             (left_val, right_val) => {
123                 if *left_val == *right_val {
124                     // The reborrows below are intentional. Without them, the stack slot for the
125                     // borrow is initialized even before the values are compared, leading to a
126                     // noticeable slow down.
127                     panic!(r#"assertion failed: `(left != right)`
128   left: `{:?}`,
129  right: `{:?}`: {}"#, &*left_val, &*right_val,
130                            format_args!($($arg)+))
131                 }
132             }
133         }
134     });
135 }
136
137 /// Asserts that a boolean expression is `true` at runtime.
138 ///
139 /// This will invoke the [`panic!`] macro if the provided expression cannot be
140 /// evaluated to `true` at runtime.
141 ///
142 /// Like [`assert!`], this macro also has a second version, where a custom panic
143 /// message can be provided.
144 ///
145 /// # Uses
146 ///
147 /// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
148 /// optimized builds by default. An optimized build will omit all
149 /// `debug_assert!` statements unless `-C debug-assertions` is passed to the
150 /// compiler. This makes `debug_assert!` useful for checks that are too
151 /// expensive to be present in a release build but may be helpful during
152 /// development.
153 ///
154 /// An unchecked assertion allows a program in an inconsistent state to keep
155 /// running, which might have unexpected consequences but does not introduce
156 /// unsafety as long as this only happens in safe code. The performance cost
157 /// of assertions, is however, not measurable in general. Replacing [`assert!`]
158 /// with `debug_assert!` is thus only encouraged after thorough profiling, and
159 /// more importantly, only in safe code!
160 ///
161 /// [`panic!`]: macro.panic.html
162 /// [`assert!`]: macro.assert.html
163 ///
164 /// # Examples
165 ///
166 /// ```
167 /// // the panic message for these assertions is the stringified value of the
168 /// // expression given.
169 /// debug_assert!(true);
170 ///
171 /// fn some_expensive_computation() -> bool { true } // a very simple function
172 /// debug_assert!(some_expensive_computation());
173 ///
174 /// // assert with a custom message
175 /// let x = true;
176 /// debug_assert!(x, "x wasn't true!");
177 ///
178 /// let a = 3; let b = 27;
179 /// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
180 /// ```
181 #[macro_export]
182 #[stable(feature = "rust1", since = "1.0.0")]
183 macro_rules! debug_assert {
184     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); })
185 }
186
187 /// Asserts that two expressions are equal to each other.
188 ///
189 /// On panic, this macro will print the values of the expressions with their
190 /// debug representations.
191 ///
192 /// Unlike [`assert_eq!`], `debug_assert_eq!` statements are only enabled in non
193 /// optimized builds by default. An optimized build will omit all
194 /// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
195 /// compiler. This makes `debug_assert_eq!` useful for checks that are too
196 /// expensive to be present in a release build but may be helpful during
197 /// development.
198 ///
199 /// [`assert_eq!`]: ../std/macro.assert_eq.html
200 ///
201 /// # Examples
202 ///
203 /// ```
204 /// let a = 3;
205 /// let b = 1 + 2;
206 /// debug_assert_eq!(a, b);
207 /// ```
208 #[macro_export]
209 #[stable(feature = "rust1", since = "1.0.0")]
210 macro_rules! debug_assert_eq {
211     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
212 }
213
214 /// Asserts that two expressions are not equal to each other.
215 ///
216 /// On panic, this macro will print the values of the expressions with their
217 /// debug representations.
218 ///
219 /// Unlike [`assert_ne!`], `debug_assert_ne!` statements are only enabled in non
220 /// optimized builds by default. An optimized build will omit all
221 /// `debug_assert_ne!` statements unless `-C debug-assertions` is passed to the
222 /// compiler. This makes `debug_assert_ne!` useful for checks that are too
223 /// expensive to be present in a release build but may be helpful during
224 /// development.
225 ///
226 /// [`assert_ne!`]: ../std/macro.assert_ne.html
227 ///
228 /// # Examples
229 ///
230 /// ```
231 /// let a = 3;
232 /// let b = 2;
233 /// debug_assert_ne!(a, b);
234 /// ```
235 #[macro_export]
236 #[stable(feature = "assert_ne", since = "1.13.0")]
237 macro_rules! debug_assert_ne {
238     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); })
239 }
240
241 /// Unwraps a result or propagates its error.
242 ///
243 /// The `?` operator was added to replace `try!` and should be used instead.
244 /// Furthermore, `try` is a reserved word in Rust 2018, so if you must use
245 /// it, you will need to use the [raw-identifier syntax][ris]: `r#try`.
246 ///
247 /// [ris]: https://doc.rust-lang.org/nightly/rust-by-example/compatibility/raw_identifiers.html
248 ///
249 /// `try!` matches the given [`Result`]. In case of the `Ok` variant, the
250 /// expression has the value of the wrapped value.
251 ///
252 /// In case of the `Err` variant, it retrieves the inner error. `try!` then
253 /// performs conversion using `From`. This provides automatic conversion
254 /// between specialized errors and more general ones. The resulting
255 /// error is then immediately returned.
256 ///
257 /// Because of the early return, `try!` can only be used in functions that
258 /// return [`Result`].
259 ///
260 /// [`Result`]: ../std/result/enum.Result.html
261 ///
262 /// # Examples
263 ///
264 /// ```
265 /// use std::io;
266 /// use std::fs::File;
267 /// use std::io::prelude::*;
268 ///
269 /// enum MyError {
270 ///     FileWriteError
271 /// }
272 ///
273 /// impl From<io::Error> for MyError {
274 ///     fn from(e: io::Error) -> MyError {
275 ///         MyError::FileWriteError
276 ///     }
277 /// }
278 ///
279 /// // The preferred method of quick returning Errors
280 /// fn write_to_file_question() -> Result<(), MyError> {
281 ///     let mut file = File::create("my_best_friends.txt")?;
282 ///     file.write_all(b"This is a list of my best friends.")?;
283 ///     Ok(())
284 /// }
285 ///
286 /// // The previous method of quick returning Errors
287 /// fn write_to_file_using_try() -> Result<(), MyError> {
288 ///     let mut file = r#try!(File::create("my_best_friends.txt"));
289 ///     r#try!(file.write_all(b"This is a list of my best friends."));
290 ///     Ok(())
291 /// }
292 ///
293 /// // This is equivalent to:
294 /// fn write_to_file_using_match() -> Result<(), MyError> {
295 ///     let mut file = r#try!(File::create("my_best_friends.txt"));
296 ///     match file.write_all(b"This is a list of my best friends.") {
297 ///         Ok(v) => v,
298 ///         Err(e) => return Err(From::from(e)),
299 ///     }
300 ///     Ok(())
301 /// }
302 /// ```
303 #[macro_export]
304 #[stable(feature = "rust1", since = "1.0.0")]
305 #[doc(alias = "?")]
306 macro_rules! r#try {
307     ($expr:expr) => (match $expr {
308         $crate::result::Result::Ok(val) => val,
309         $crate::result::Result::Err(err) => {
310             return $crate::result::Result::Err($crate::convert::From::from(err))
311         }
312     });
313     ($expr:expr,) => (r#try!($expr));
314 }
315
316 /// Writes formatted data into a buffer.
317 ///
318 /// This macro accepts a format string, a list of arguments, and a 'writer'. Arguments will be
319 /// formatted according to the specified format string and the result will be passed to the writer.
320 /// The writer may be any value with a `write_fmt` method; generally this comes from an
321 /// implementation of either the [`std::fmt::Write`] or the [`std::io::Write`] trait. The macro
322 /// returns whatever the `write_fmt` method returns; commonly a [`std::fmt::Result`], or an
323 /// [`io::Result`].
324 ///
325 /// See [`std::fmt`] for more information on the format string syntax.
326 ///
327 /// [`std::fmt`]: ../std/fmt/index.html
328 /// [`std::fmt::Write`]: ../std/fmt/trait.Write.html
329 /// [`std::io::Write`]: ../std/io/trait.Write.html
330 /// [`std::fmt::Result`]: ../std/fmt/type.Result.html
331 /// [`io::Result`]: ../std/io/type.Result.html
332 ///
333 /// # Examples
334 ///
335 /// ```
336 /// use std::io::Write;
337 ///
338 /// let mut w = Vec::new();
339 /// write!(&mut w, "test").unwrap();
340 /// write!(&mut w, "formatted {}", "arguments").unwrap();
341 ///
342 /// assert_eq!(w, b"testformatted arguments");
343 /// ```
344 ///
345 /// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
346 /// implementing either, as objects do not typically implement both. However, the module must
347 /// import the traits qualified so their names do not conflict:
348 ///
349 /// ```
350 /// use std::fmt::Write as FmtWrite;
351 /// use std::io::Write as IoWrite;
352 ///
353 /// let mut s = String::new();
354 /// let mut v = Vec::new();
355 /// write!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
356 /// write!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
357 /// assert_eq!(v, b"s = \"abc 123\"");
358 /// ```
359 ///
360 /// Note: This macro can be used in `no_std` setups as well.
361 /// In a `no_std` setup you are responsible for the implementation details of the components.
362 ///
363 /// ```no_run
364 /// # extern crate core;
365 /// use core::fmt::Write;
366 ///
367 /// struct Example;
368 ///
369 /// impl Write for Example {
370 ///     fn write_str(&mut self, _s: &str) -> core::fmt::Result {
371 ///          unimplemented!();
372 ///     }
373 /// }
374 ///
375 /// let mut m = Example{};
376 /// write!(&mut m, "Hello World").expect("Not written");
377 /// ```
378 #[macro_export]
379 #[stable(feature = "rust1", since = "1.0.0")]
380 macro_rules! write {
381     ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
382 }
383
384 /// Write formatted data into a buffer, with a newline appended.
385 ///
386 /// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
387 /// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
388 ///
389 /// For more information, see [`write!`]. For information on the format string syntax, see
390 /// [`std::fmt`].
391 ///
392 /// [`write!`]: macro.write.html
393 /// [`std::fmt`]: ../std/fmt/index.html
394 ///
395 ///
396 /// # Examples
397 ///
398 /// ```
399 /// use std::io::Write;
400 ///
401 /// let mut w = Vec::new();
402 /// writeln!(&mut w).unwrap();
403 /// writeln!(&mut w, "test").unwrap();
404 /// writeln!(&mut w, "formatted {}", "arguments").unwrap();
405 ///
406 /// assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
407 /// ```
408 ///
409 /// A module can import both `std::fmt::Write` and `std::io::Write` and call `write!` on objects
410 /// implementing either, as objects do not typically implement both. However, the module must
411 /// import the traits qualified so their names do not conflict:
412 ///
413 /// ```
414 /// use std::fmt::Write as FmtWrite;
415 /// use std::io::Write as IoWrite;
416 ///
417 /// let mut s = String::new();
418 /// let mut v = Vec::new();
419 /// writeln!(&mut s, "{} {}", "abc", 123).unwrap(); // uses fmt::Write::write_fmt
420 /// writeln!(&mut v, "s = {:?}", s).unwrap(); // uses io::Write::write_fmt
421 /// assert_eq!(v, b"s = \"abc 123\\n\"\n");
422 /// ```
423 #[macro_export]
424 #[stable(feature = "rust1", since = "1.0.0")]
425 #[allow_internal_unstable(format_args_nl)]
426 macro_rules! writeln {
427     ($dst:expr) => (
428         write!($dst, "\n")
429     );
430     ($dst:expr,) => (
431         writeln!($dst)
432     );
433     ($dst:expr, $($arg:tt)*) => (
434         $dst.write_fmt(format_args_nl!($($arg)*))
435     );
436 }
437
438 /// Indicates unreachable code.
439 ///
440 /// This is useful any time that the compiler can't determine that some code is unreachable. For
441 /// example:
442 ///
443 /// * Match arms with guard conditions.
444 /// * Loops that dynamically terminate.
445 /// * Iterators that dynamically terminate.
446 ///
447 /// If the determination that the code is unreachable proves incorrect, the
448 /// program immediately terminates with a [`panic!`]. The function [`unreachable_unchecked`],
449 /// which belongs to the [`std::hint`] module, informs the compiler to
450 /// optimize the code out of the release version entirely.
451 ///
452 /// [`panic!`]:  ../std/macro.panic.html
453 /// [`unreachable_unchecked`]: ../std/hint/fn.unreachable_unchecked.html
454 /// [`std::hint`]: ../std/hint/index.html
455 ///
456 /// # Panics
457 ///
458 /// This will always [`panic!`]
459 ///
460 /// [`panic!`]: ../std/macro.panic.html
461 /// # Examples
462 ///
463 /// Match arms:
464 ///
465 /// ```
466 /// # #[allow(dead_code)]
467 /// fn foo(x: Option<i32>) {
468 ///     match x {
469 ///         Some(n) if n >= 0 => println!("Some(Non-negative)"),
470 ///         Some(n) if n <  0 => println!("Some(Negative)"),
471 ///         Some(_)           => unreachable!(), // compile error if commented out
472 ///         None              => println!("None")
473 ///     }
474 /// }
475 /// ```
476 ///
477 /// Iterators:
478 ///
479 /// ```
480 /// # #[allow(dead_code)]
481 /// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
482 ///     for i in 0.. {
483 ///         if 3*i < i { panic!("u32 overflow"); }
484 ///         if x < 3*i { return i-1; }
485 ///     }
486 ///     unreachable!();
487 /// }
488 /// ```
489 #[macro_export]
490 #[stable(feature = "rust1", since = "1.0.0")]
491 macro_rules! unreachable {
492     () => ({
493         panic!("internal error: entered unreachable code")
494     });
495     ($msg:expr) => ({
496         unreachable!("{}", $msg)
497     });
498     ($msg:expr,) => ({
499         unreachable!($msg)
500     });
501     ($fmt:expr, $($arg:tt)*) => ({
502         panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
503     });
504 }
505
506 /// Indicates unfinished code.
507 ///
508 /// This can be useful if you are prototyping and are just looking to have your
509 /// code type-check, or if you're implementing a trait that requires multiple
510 /// methods, and you're only planning on using one of them.
511 ///
512 /// # Panics
513 ///
514 /// This will always [panic!](macro.panic.html)
515 ///
516 /// # Examples
517 ///
518 /// Here's an example of some in-progress code. We have a trait `Foo`:
519 ///
520 /// ```
521 /// trait Foo {
522 ///     fn bar(&self);
523 ///     fn baz(&self);
524 /// }
525 /// ```
526 ///
527 /// We want to implement `Foo` on one of our types, but we also want to work on
528 /// just `bar()` first. In order for our code to compile, we need to implement
529 /// `baz()`, so we can use `unimplemented!`:
530 ///
531 /// ```
532 /// # trait Foo {
533 /// #     fn bar(&self);
534 /// #     fn baz(&self);
535 /// # }
536 /// struct MyStruct;
537 ///
538 /// impl Foo for MyStruct {
539 ///     fn bar(&self) {
540 ///         // implementation goes here
541 ///     }
542 ///
543 ///     fn baz(&self) {
544 ///         // let's not worry about implementing baz() for now
545 ///         unimplemented!();
546 ///     }
547 /// }
548 ///
549 /// fn main() {
550 ///     let s = MyStruct;
551 ///     s.bar();
552 ///
553 ///     // we aren't even using baz() yet, so this is fine.
554 /// }
555 /// ```
556 #[macro_export]
557 #[stable(feature = "rust1", since = "1.0.0")]
558 macro_rules! unimplemented {
559     () => (panic!("not yet implemented"));
560     ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
561 }
562
563 /// Indicates unfinished code.
564 ///
565 /// This can be useful if you are prototyping and are just looking to have your
566 /// code typecheck. `todo!` works exactly like `unimplemented!`. The only
567 /// difference between the two macros is the name.
568 ///
569 /// # Panics
570 ///
571 /// This will always [panic!](macro.panic.html)
572 ///
573 /// # Examples
574 ///
575 /// Here's an example of some in-progress code. We have a trait `Foo`:
576 ///
577 /// ```
578 /// trait Foo {
579 ///     fn bar(&self);
580 ///     fn baz(&self);
581 /// }
582 /// ```
583 ///
584 /// We want to implement `Foo` on one of our types, but we also want to work on
585 /// just `bar()` first. In order for our code to compile, we need to implement
586 /// `baz()`, so we can use `todo!`:
587 ///
588 /// ```
589 /// #![feature(todo_macro)]
590 ///
591 /// # trait Foo {
592 /// #     fn bar(&self);
593 /// #     fn baz(&self);
594 /// # }
595 /// struct MyStruct;
596 ///
597 /// impl Foo for MyStruct {
598 ///     fn bar(&self) {
599 ///         // implementation goes here
600 ///     }
601 ///
602 ///     fn baz(&self) {
603 ///         // let's not worry about implementing baz() for now
604 ///         todo!();
605 ///     }
606 /// }
607 ///
608 /// fn main() {
609 ///     let s = MyStruct;
610 ///     s.bar();
611 ///
612 ///     // we aren't even using baz() yet, so this is fine.
613 /// }
614 /// ```
615 #[macro_export]
616 #[unstable(feature = "todo_macro", issue = "59277")]
617 macro_rules! todo {
618     () => (panic!("not yet implemented"));
619     ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
620 }
621
622 /// Creates an array of [`MaybeUninit`].
623 ///
624 /// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
625 ///
626 /// [`MaybeUninit`]: mem/union.MaybeUninit.html
627 #[macro_export]
628 #[unstable(feature = "maybe_uninit_array", issue = "53491")]
629 macro_rules! uninitialized_array {
630     // This `assume_init` is safe because an array of `MaybeUninit` does not
631     // require initialization.
632     // FIXME(#49147): Could be replaced by an array initializer, once those can
633     // be any const expression.
634     ($t:ty; $size:expr) => (unsafe {
635         MaybeUninit::<[MaybeUninit<$t>; $size]>::uninit().assume_init()
636     });
637 }
638
639 /// Built-in macros to the compiler itself.
640 ///
641 /// These macros do not have any corresponding definition with a `macro_rules!`
642 /// macro, but are documented here. Their implementations can be found hardcoded
643 /// into libsyntax itself.
644 ///
645 /// For more information, see documentation for `std`'s macros.
646 #[cfg(rustdoc)]
647 mod builtin {
648
649     /// Causes compilation to fail with the given error message when encountered.
650     ///
651     /// For more information, see the documentation for [`std::compile_error!`].
652     ///
653     /// [`std::compile_error!`]: ../std/macro.compile_error.html
654     #[stable(feature = "compile_error_macro", since = "1.20.0")]
655     #[rustc_doc_only_macro]
656     macro_rules! compile_error {
657         ($msg:expr) => ({ /* compiler built-in */ });
658         ($msg:expr,) => ({ /* compiler built-in */ });
659     }
660
661     /// Constructs parameters for the other string-formatting macros.
662     ///
663     /// For more information, see the documentation for [`std::format_args!`].
664     ///
665     /// [`std::format_args!`]: ../std/macro.format_args.html
666     #[stable(feature = "rust1", since = "1.0.0")]
667     #[rustc_doc_only_macro]
668     macro_rules! format_args {
669         ($fmt:expr) => ({ /* compiler built-in */ });
670         ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
671     }
672
673     /// Inspects an environment variable at compile time.
674     ///
675     /// For more information, see the documentation for [`std::env!`].
676     ///
677     /// [`std::env!`]: ../std/macro.env.html
678     #[stable(feature = "rust1", since = "1.0.0")]
679     #[rustc_doc_only_macro]
680     macro_rules! env {
681         ($name:expr) => ({ /* compiler built-in */ });
682         ($name:expr,) => ({ /* compiler built-in */ });
683     }
684
685     /// Optionally inspects an environment variable at compile time.
686     ///
687     /// For more information, see the documentation for [`std::option_env!`].
688     ///
689     /// [`std::option_env!`]: ../std/macro.option_env.html
690     #[stable(feature = "rust1", since = "1.0.0")]
691     #[rustc_doc_only_macro]
692     macro_rules! option_env {
693         ($name:expr) => ({ /* compiler built-in */ });
694         ($name:expr,) => ({ /* compiler built-in */ });
695     }
696
697     /// Concatenates identifiers into one identifier.
698     ///
699     /// For more information, see the documentation for [`std::concat_idents!`].
700     ///
701     /// [`std::concat_idents!`]: ../std/macro.concat_idents.html
702     #[unstable(feature = "concat_idents_macro", issue = "29599")]
703     #[rustc_doc_only_macro]
704     macro_rules! concat_idents {
705         ($($e:ident),+) => ({ /* compiler built-in */ });
706         ($($e:ident,)+) => ({ /* compiler built-in */ });
707     }
708
709     /// Concatenates literals into a static string slice.
710     ///
711     /// For more information, see the documentation for [`std::concat!`].
712     ///
713     /// [`std::concat!`]: ../std/macro.concat.html
714     #[stable(feature = "rust1", since = "1.0.0")]
715     #[rustc_doc_only_macro]
716     macro_rules! concat {
717         ($($e:expr),*) => ({ /* compiler built-in */ });
718         ($($e:expr,)*) => ({ /* compiler built-in */ });
719     }
720
721     /// Expands to the line number on which it was invoked.
722     ///
723     /// For more information, see the documentation for [`std::line!`].
724     ///
725     /// [`std::line!`]: ../std/macro.line.html
726     #[stable(feature = "rust1", since = "1.0.0")]
727     #[rustc_doc_only_macro]
728     macro_rules! line { () => ({ /* compiler built-in */ }) }
729
730     /// Expands to the column number on which it was invoked.
731     ///
732     /// For more information, see the documentation for [`std::column!`].
733     ///
734     /// [`std::column!`]: ../std/macro.column.html
735     #[stable(feature = "rust1", since = "1.0.0")]
736     #[rustc_doc_only_macro]
737     macro_rules! column { () => ({ /* compiler built-in */ }) }
738
739     /// Expands to the file name from which it was invoked.
740     ///
741     /// For more information, see the documentation for [`std::file!`].
742     ///
743     /// [`std::file!`]: ../std/macro.file.html
744     #[stable(feature = "rust1", since = "1.0.0")]
745     #[rustc_doc_only_macro]
746     macro_rules! file { () => ({ /* compiler built-in */ }) }
747
748     /// Stringifies its arguments.
749     ///
750     /// For more information, see the documentation for [`std::stringify!`].
751     ///
752     /// [`std::stringify!`]: ../std/macro.stringify.html
753     #[stable(feature = "rust1", since = "1.0.0")]
754     #[rustc_doc_only_macro]
755     macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) }
756
757     /// Includes a utf8-encoded file as a string.
758     ///
759     /// For more information, see the documentation for [`std::include_str!`].
760     ///
761     /// [`std::include_str!`]: ../std/macro.include_str.html
762     #[stable(feature = "rust1", since = "1.0.0")]
763     #[rustc_doc_only_macro]
764     macro_rules! include_str {
765         ($file:expr) => ({ /* compiler built-in */ });
766         ($file:expr,) => ({ /* compiler built-in */ });
767     }
768
769     /// Includes a file as a reference to a byte array.
770     ///
771     /// For more information, see the documentation for [`std::include_bytes!`].
772     ///
773     /// [`std::include_bytes!`]: ../std/macro.include_bytes.html
774     #[stable(feature = "rust1", since = "1.0.0")]
775     #[rustc_doc_only_macro]
776     macro_rules! include_bytes {
777         ($file:expr) => ({ /* compiler built-in */ });
778         ($file:expr,) => ({ /* compiler built-in */ });
779     }
780
781     /// Expands to a string that represents the current module path.
782     ///
783     /// For more information, see the documentation for [`std::module_path!`].
784     ///
785     /// [`std::module_path!`]: ../std/macro.module_path.html
786     #[stable(feature = "rust1", since = "1.0.0")]
787     #[rustc_doc_only_macro]
788     macro_rules! module_path { () => ({ /* compiler built-in */ }) }
789
790     /// Evaluates boolean combinations of configuration flags, at compile-time.
791     ///
792     /// For more information, see the documentation for [`std::cfg!`].
793     ///
794     /// [`std::cfg!`]: ../std/macro.cfg.html
795     #[stable(feature = "rust1", since = "1.0.0")]
796     #[rustc_doc_only_macro]
797     macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
798
799     /// Parses a file as an expression or an item according to the context.
800     ///
801     /// For more information, see the documentation for [`std::include!`].
802     ///
803     /// [`std::include!`]: ../std/macro.include.html
804     #[stable(feature = "rust1", since = "1.0.0")]
805     #[rustc_doc_only_macro]
806     macro_rules! include {
807         ($file:expr) => ({ /* compiler built-in */ });
808         ($file:expr,) => ({ /* compiler built-in */ });
809     }
810
811     /// Asserts that a boolean expression is `true` at runtime.
812     ///
813     /// For more information, see the documentation for [`std::assert!`].
814     ///
815     /// [`std::assert!`]: ../std/macro.assert.html
816     #[rustc_doc_only_macro]
817     #[stable(feature = "rust1", since = "1.0.0")]
818     macro_rules! assert {
819         ($cond:expr) => ({ /* compiler built-in */ });
820         ($cond:expr,) => ({ /* compiler built-in */ });
821         ($cond:expr, $($arg:tt)+) => ({ /* compiler built-in */ });
822     }
823 }