]> git.lizzy.rs Git - rust.git/blob - src/libcore/macros.rs
Rollup merge of #58595 - stjepang:make-duration-consts-associated, r=oli-obk
[rust.git] / src / libcore / macros.rs
1 /// Entry point of thread panic. For details, see `std::macros`.
2 #[macro_export]
3 #[cfg_attr(not(stage0), allow_internal_unstable(core_panic, __rust_unstable_column))]
4 #[cfg_attr(stage0, allow_internal_unstable)]
5 #[stable(feature = "core", since = "1.6.0")]
6 macro_rules! panic {
7     () => (
8         panic!("explicit panic")
9     );
10     ($msg:expr) => ({
11         $crate::panicking::panic(&($msg, file!(), line!(), __rust_unstable_column!()))
12     });
13     ($msg:expr,) => (
14         panic!($msg)
15     );
16     ($fmt:expr, $($arg:tt)+) => ({
17         $crate::panicking::panic_fmt(format_args!($fmt, $($arg)*),
18                                      &(file!(), line!(), __rust_unstable_column!()))
19     });
20 }
21
22 /// Asserts that two expressions are equal to each other (using [`PartialEq`]).
23 ///
24 /// On panic, this macro will print the values of the expressions with their
25 /// debug representations.
26 ///
27 /// Like [`assert!`], this macro has a second form, where a custom
28 /// panic message can be provided.
29 ///
30 /// [`PartialEq`]: cmp/trait.PartialEq.html
31 /// [`assert!`]: macro.assert.html
32 ///
33 /// # Examples
34 ///
35 /// ```
36 /// let a = 3;
37 /// let b = 1 + 2;
38 /// assert_eq!(a, b);
39 ///
40 /// assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
41 /// ```
42 #[macro_export]
43 #[stable(feature = "rust1", since = "1.0.0")]
44 macro_rules! assert_eq {
45     ($left:expr, $right:expr) => ({
46         match (&$left, &$right) {
47             (left_val, right_val) => {
48                 if !(*left_val == *right_val) {
49                     // The reborrows below are intentional. Without them, the stack slot for the
50                     // borrow is initialized even before the values are compared, leading to a
51                     // noticeable slow down.
52                     panic!(r#"assertion failed: `(left == right)`
53   left: `{:?}`,
54  right: `{:?}`"#, &*left_val, &*right_val)
55                 }
56             }
57         }
58     });
59     ($left:expr, $right:expr,) => ({
60         assert_eq!($left, $right)
61     });
62     ($left:expr, $right:expr, $($arg:tt)+) => ({
63         match (&($left), &($right)) {
64             (left_val, right_val) => {
65                 if !(*left_val == *right_val) {
66                     // The reborrows below are intentional. Without them, the stack slot for the
67                     // borrow is initialized even before the values are compared, leading to a
68                     // noticeable slow down.
69                     panic!(r#"assertion failed: `(left == right)`
70   left: `{:?}`,
71  right: `{:?}`: {}"#, &*left_val, &*right_val,
72                            format_args!($($arg)+))
73                 }
74             }
75         }
76     });
77 }
78
79 /// Asserts that two expressions are not equal to each other (using [`PartialEq`]).
80 ///
81 /// On panic, this macro will print the values of the expressions with their
82 /// debug representations.
83 ///
84 /// Like [`assert!`], this macro has a second form, where a custom
85 /// panic message can be provided.
86 ///
87 /// [`PartialEq`]: cmp/trait.PartialEq.html
88 /// [`assert!`]: macro.assert.html
89 ///
90 /// # Examples
91 ///
92 /// ```
93 /// let a = 3;
94 /// let b = 2;
95 /// assert_ne!(a, b);
96 ///
97 /// assert_ne!(a, b, "we are testing that the values are not equal");
98 /// ```
99 #[macro_export]
100 #[stable(feature = "assert_ne", since = "1.13.0")]
101 macro_rules! assert_ne {
102     ($left:expr, $right:expr) => ({
103         match (&$left, &$right) {
104             (left_val, right_val) => {
105                 if *left_val == *right_val {
106                     // The reborrows below are intentional. Without them, the stack slot for the
107                     // borrow is initialized even before the values are compared, leading to a
108                     // noticeable slow down.
109                     panic!(r#"assertion failed: `(left != right)`
110   left: `{:?}`,
111  right: `{:?}`"#, &*left_val, &*right_val)
112                 }
113             }
114         }
115     });
116     ($left:expr, $right:expr,) => {
117         assert_ne!($left, $right)
118     };
119     ($left:expr, $right:expr, $($arg:tt)+) => ({
120         match (&($left), &($right)) {
121             (left_val, right_val) => {
122                 if *left_val == *right_val {
123                     // The reborrows below are intentional. Without them, the stack slot for the
124                     // borrow is initialized even before the values are compared, leading to a
125                     // noticeable slow down.
126                     panic!(r#"assertion failed: `(left != right)`
127   left: `{:?}`,
128  right: `{:?}`: {}"#, &*left_val, &*right_val,
129                            format_args!($($arg)+))
130                 }
131             }
132         }
133     });
134 }
135
136 /// Ensure that a boolean expression is `true` at runtime.
137 ///
138 /// This will invoke the [`panic!`] macro if the provided expression cannot be
139 /// evaluated to `true` at runtime.
140 ///
141 /// Like [`assert!`], this macro also has a second version, where a custom panic
142 /// message can be provided.
143 ///
144 /// # Uses
145 ///
146 /// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
147 /// optimized builds by default. An optimized build will omit all
148 /// `debug_assert!` statements unless `-C debug-assertions` is passed to the
149 /// compiler. This makes `debug_assert!` useful for checks that are too
150 /// expensive to be present in a release build but may be helpful during
151 /// development.
152 ///
153 /// An unchecked assertion allows a program in an inconsistent state to keep
154 /// running, which might have unexpected consequences but does not introduce
155 /// unsafety as long as this only happens in safe code. The performance cost
156 /// of assertions, is however, not measurable in general. Replacing [`assert!`]
157 /// with `debug_assert!` is thus only encouraged after thorough profiling, and
158 /// more importantly, only in safe code!
159 ///
160 /// [`panic!`]: macro.panic.html
161 /// [`assert!`]: macro.assert.html
162 ///
163 /// # Examples
164 ///
165 /// ```
166 /// // the panic message for these assertions is the stringified value of the
167 /// // expression given.
168 /// debug_assert!(true);
169 ///
170 /// fn some_expensive_computation() -> bool { true } // a very simple function
171 /// debug_assert!(some_expensive_computation());
172 ///
173 /// // assert with a custom message
174 /// let x = true;
175 /// debug_assert!(x, "x wasn't true!");
176 ///
177 /// let a = 3; let b = 27;
178 /// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
179 /// ```
180 #[macro_export]
181 #[stable(feature = "rust1", since = "1.0.0")]
182 macro_rules! debug_assert {
183     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); })
184 }
185
186 /// Asserts that two expressions are equal to each other.
187 ///
188 /// On panic, this macro will print the values of the expressions with their
189 /// debug representations.
190 ///
191 /// Unlike [`assert_eq!`], `debug_assert_eq!` statements are only enabled in non
192 /// optimized builds by default. An optimized build will omit all
193 /// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
194 /// compiler. This makes `debug_assert_eq!` useful for checks that are too
195 /// expensive to be present in a release build but may be helpful during
196 /// development.
197 ///
198 /// [`assert_eq!`]: ../std/macro.assert_eq.html
199 ///
200 /// # Examples
201 ///
202 /// ```
203 /// let a = 3;
204 /// let b = 1 + 2;
205 /// debug_assert_eq!(a, b);
206 /// ```
207 #[macro_export]
208 #[stable(feature = "rust1", since = "1.0.0")]
209 macro_rules! debug_assert_eq {
210     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
211 }
212
213 /// Asserts that two expressions are not equal to each other.
214 ///
215 /// On panic, this macro will print the values of the expressions with their
216 /// debug representations.
217 ///
218 /// Unlike [`assert_ne!`], `debug_assert_ne!` statements are only enabled in non
219 /// optimized builds by default. An optimized build will omit all
220 /// `debug_assert_ne!` statements unless `-C debug-assertions` is passed to the
221 /// compiler. This makes `debug_assert_ne!` useful for checks that are too
222 /// expensive to be present in a release build but may be helpful during
223 /// development.
224 ///
225 /// [`assert_ne!`]: ../std/macro.assert_ne.html
226 ///
227 /// # Examples
228 ///
229 /// ```
230 /// let a = 3;
231 /// let b = 2;
232 /// debug_assert_ne!(a, b);
233 /// ```
234 #[macro_export]
235 #[stable(feature = "assert_ne", since = "1.13.0")]
236 macro_rules! debug_assert_ne {
237     ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); })
238 }
239
240 /// Helper macro for reducing boilerplate code for matching `Result` together
241 /// with converting downstream errors.
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 /// Write 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 #[cfg_attr(stage0, allow_internal_unstable)]
426 #[cfg_attr(not(stage0), allow_internal_unstable(format_args_nl))]
427 macro_rules! writeln {
428     ($dst:expr) => (
429         write!($dst, "\n")
430     );
431     ($dst:expr,) => (
432         writeln!($dst)
433     );
434     ($dst:expr, $($arg:tt)*) => (
435         $dst.write_fmt(format_args_nl!($($arg)*))
436     );
437 }
438
439 /// A utility macro for indicating unreachable code.
440 ///
441 /// This is useful any time that the compiler can't determine that some code is unreachable. For
442 /// example:
443 ///
444 /// * Match arms with guard conditions.
445 /// * Loops that dynamically terminate.
446 /// * Iterators that dynamically terminate.
447 ///
448 /// If the determination that the code is unreachable proves incorrect, the
449 /// program immediately terminates with a [`panic!`]. The function [`unreachable_unchecked`],
450 /// which belongs to the [`std::hint`] module, informs the compiler to
451 /// optimize the code out of the release version entirely.
452 ///
453 /// [`panic!`]:  ../std/macro.panic.html
454 /// [`unreachable_unchecked`]: ../std/hint/fn.unreachable_unchecked.html
455 /// [`std::hint`]: ../std/hint/index.html
456 ///
457 /// # Panics
458 ///
459 /// This will always [`panic!`]
460 ///
461 /// [`panic!`]: ../std/macro.panic.html
462 /// # Examples
463 ///
464 /// Match arms:
465 ///
466 /// ```
467 /// # #[allow(dead_code)]
468 /// fn foo(x: Option<i32>) {
469 ///     match x {
470 ///         Some(n) if n >= 0 => println!("Some(Non-negative)"),
471 ///         Some(n) if n <  0 => println!("Some(Negative)"),
472 ///         Some(_)           => unreachable!(), // compile error if commented out
473 ///         None              => println!("None")
474 ///     }
475 /// }
476 /// ```
477 ///
478 /// Iterators:
479 ///
480 /// ```
481 /// # #[allow(dead_code)]
482 /// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
483 ///     for i in 0.. {
484 ///         if 3*i < i { panic!("u32 overflow"); }
485 ///         if x < 3*i { return i-1; }
486 ///     }
487 ///     unreachable!();
488 /// }
489 /// ```
490 #[macro_export]
491 #[stable(feature = "rust1", since = "1.0.0")]
492 macro_rules! unreachable {
493     () => ({
494         panic!("internal error: entered unreachable code")
495     });
496     ($msg:expr) => ({
497         unreachable!("{}", $msg)
498     });
499     ($msg:expr,) => ({
500         unreachable!($msg)
501     });
502     ($fmt:expr, $($arg:tt)*) => ({
503         panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
504     });
505 }
506
507 /// A standardized placeholder for marking unfinished code.
508 ///
509 /// This can be useful if you are prototyping and are just looking to have your
510 /// code type-check, or if you're implementing a trait that requires multiple
511 /// methods, and you're only planning on using one of them.
512 ///
513 /// # Panics
514 ///
515 /// This will always [panic!](macro.panic.html)
516 ///
517 /// # Examples
518 ///
519 /// Here's an example of some in-progress code. We have a trait `Foo`:
520 ///
521 /// ```
522 /// trait Foo {
523 ///     fn bar(&self);
524 ///     fn baz(&self);
525 /// }
526 /// ```
527 ///
528 /// We want to implement `Foo` on one of our types, but we also want to work on
529 /// just `bar()` first. In order for our code to compile, we need to implement
530 /// `baz()`, so we can use `unimplemented!`:
531 ///
532 /// ```
533 /// # trait Foo {
534 /// #     fn bar(&self);
535 /// #     fn baz(&self);
536 /// # }
537 /// struct MyStruct;
538 ///
539 /// impl Foo for MyStruct {
540 ///     fn bar(&self) {
541 ///         // implementation goes here
542 ///     }
543 ///
544 ///     fn baz(&self) {
545 ///         // let's not worry about implementing baz() for now
546 ///         unimplemented!();
547 ///     }
548 /// }
549 ///
550 /// fn main() {
551 ///     let s = MyStruct;
552 ///     s.bar();
553 ///
554 ///     // we aren't even using baz() yet, so this is fine.
555 /// }
556 /// ```
557 #[macro_export]
558 #[stable(feature = "rust1", since = "1.0.0")]
559 macro_rules! unimplemented {
560     () => (panic!("not yet implemented"));
561     ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
562 }
563
564 /// A macro to create an array of [`MaybeUninit`]
565 ///
566 /// This macro constructs an uninitialized array of the type `[MaybeUninit<K>; N]`.
567 ///
568 /// [`MaybeUninit`]: mem/union.MaybeUninit.html
569 #[macro_export]
570 #[unstable(feature = "maybe_uninit_array", issue = "53491")]
571 macro_rules! uninitialized_array {
572     // This `into_initialized` is safe because an array of `MaybeUninit` does not
573     // require initialization.
574     // FIXME(#49147): Could be replaced by an array initializer, once those can
575     // be any const expression.
576     ($t:ty; $size:expr) => (unsafe {
577         MaybeUninit::<[MaybeUninit<$t>; $size]>::uninitialized().into_initialized()
578     });
579 }
580
581 /// Built-in macros to the compiler itself.
582 ///
583 /// These macros do not have any corresponding definition with a `macro_rules!`
584 /// macro, but are documented here. Their implementations can be found hardcoded
585 /// into libsyntax itself.
586 ///
587 /// For more information, see documentation for `std`'s macros.
588 #[cfg(rustdoc)]
589 mod builtin {
590
591     /// Unconditionally causes compilation to fail with the given error message when encountered.
592     ///
593     /// For more information, see the documentation for [`std::compile_error!`].
594     ///
595     /// [`std::compile_error!`]: ../std/macro.compile_error.html
596     #[stable(feature = "compile_error_macro", since = "1.20.0")]
597     #[rustc_doc_only_macro]
598     macro_rules! compile_error {
599         ($msg:expr) => ({ /* compiler built-in */ });
600         ($msg:expr,) => ({ /* compiler built-in */ });
601     }
602
603     /// The core macro for formatted string creation & output.
604     ///
605     /// For more information, see the documentation for [`std::format_args!`].
606     ///
607     /// [`std::format_args!`]: ../std/macro.format_args.html
608     #[stable(feature = "rust1", since = "1.0.0")]
609     #[rustc_doc_only_macro]
610     macro_rules! format_args {
611         ($fmt:expr) => ({ /* compiler built-in */ });
612         ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
613     }
614
615     /// Inspect an environment variable at compile time.
616     ///
617     /// For more information, see the documentation for [`std::env!`].
618     ///
619     /// [`std::env!`]: ../std/macro.env.html
620     #[stable(feature = "rust1", since = "1.0.0")]
621     #[rustc_doc_only_macro]
622     macro_rules! env {
623         ($name:expr) => ({ /* compiler built-in */ });
624         ($name:expr,) => ({ /* compiler built-in */ });
625     }
626
627     /// Optionally inspect an environment variable at compile time.
628     ///
629     /// For more information, see the documentation for [`std::option_env!`].
630     ///
631     /// [`std::option_env!`]: ../std/macro.option_env.html
632     #[stable(feature = "rust1", since = "1.0.0")]
633     #[rustc_doc_only_macro]
634     macro_rules! option_env {
635         ($name:expr) => ({ /* compiler built-in */ });
636         ($name:expr,) => ({ /* compiler built-in */ });
637     }
638
639     /// Concatenate identifiers into one identifier.
640     ///
641     /// For more information, see the documentation for [`std::concat_idents!`].
642     ///
643     /// [`std::concat_idents!`]: ../std/macro.concat_idents.html
644     #[unstable(feature = "concat_idents_macro", issue = "29599")]
645     #[rustc_doc_only_macro]
646     macro_rules! concat_idents {
647         ($($e:ident),+) => ({ /* compiler built-in */ });
648         ($($e:ident,)+) => ({ /* compiler built-in */ });
649     }
650
651     /// Concatenates literals into a static string slice.
652     ///
653     /// For more information, see the documentation for [`std::concat!`].
654     ///
655     /// [`std::concat!`]: ../std/macro.concat.html
656     #[stable(feature = "rust1", since = "1.0.0")]
657     #[rustc_doc_only_macro]
658     macro_rules! concat {
659         ($($e:expr),*) => ({ /* compiler built-in */ });
660         ($($e:expr,)*) => ({ /* compiler built-in */ });
661     }
662
663     /// A macro which expands to the line number on which it was invoked.
664     ///
665     /// For more information, see the documentation for [`std::line!`].
666     ///
667     /// [`std::line!`]: ../std/macro.line.html
668     #[stable(feature = "rust1", since = "1.0.0")]
669     #[rustc_doc_only_macro]
670     macro_rules! line { () => ({ /* compiler built-in */ }) }
671
672     /// A macro which expands to the column number on which it was invoked.
673     ///
674     /// For more information, see the documentation for [`std::column!`].
675     ///
676     /// [`std::column!`]: ../std/macro.column.html
677     #[stable(feature = "rust1", since = "1.0.0")]
678     #[rustc_doc_only_macro]
679     macro_rules! column { () => ({ /* compiler built-in */ }) }
680
681     /// A macro which expands to the file name from which it was invoked.
682     ///
683     /// For more information, see the documentation for [`std::file!`].
684     ///
685     /// [`std::file!`]: ../std/macro.file.html
686     #[stable(feature = "rust1", since = "1.0.0")]
687     #[rustc_doc_only_macro]
688     macro_rules! file { () => ({ /* compiler built-in */ }) }
689
690     /// A macro which stringifies its arguments.
691     ///
692     /// For more information, see the documentation for [`std::stringify!`].
693     ///
694     /// [`std::stringify!`]: ../std/macro.stringify.html
695     #[stable(feature = "rust1", since = "1.0.0")]
696     #[rustc_doc_only_macro]
697     macro_rules! stringify { ($($t:tt)*) => ({ /* compiler built-in */ }) }
698
699     /// Includes a utf8-encoded file as a string.
700     ///
701     /// For more information, see the documentation for [`std::include_str!`].
702     ///
703     /// [`std::include_str!`]: ../std/macro.include_str.html
704     #[stable(feature = "rust1", since = "1.0.0")]
705     #[rustc_doc_only_macro]
706     macro_rules! include_str {
707         ($file:expr) => ({ /* compiler built-in */ });
708         ($file:expr,) => ({ /* compiler built-in */ });
709     }
710
711     /// Includes a file as a reference to a byte array.
712     ///
713     /// For more information, see the documentation for [`std::include_bytes!`].
714     ///
715     /// [`std::include_bytes!`]: ../std/macro.include_bytes.html
716     #[stable(feature = "rust1", since = "1.0.0")]
717     #[rustc_doc_only_macro]
718     macro_rules! include_bytes {
719         ($file:expr) => ({ /* compiler built-in */ });
720         ($file:expr,) => ({ /* compiler built-in */ });
721     }
722
723     /// Expands to a string that represents the current module path.
724     ///
725     /// For more information, see the documentation for [`std::module_path!`].
726     ///
727     /// [`std::module_path!`]: ../std/macro.module_path.html
728     #[stable(feature = "rust1", since = "1.0.0")]
729     #[rustc_doc_only_macro]
730     macro_rules! module_path { () => ({ /* compiler built-in */ }) }
731
732     /// Boolean evaluation of configuration flags, at compile-time.
733     ///
734     /// For more information, see the documentation for [`std::cfg!`].
735     ///
736     /// [`std::cfg!`]: ../std/macro.cfg.html
737     #[stable(feature = "rust1", since = "1.0.0")]
738     #[rustc_doc_only_macro]
739     macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
740
741     /// Parse a file as an expression or an item according to the context.
742     ///
743     /// For more information, see the documentation for [`std::include!`].
744     ///
745     /// [`std::include!`]: ../std/macro.include.html
746     #[stable(feature = "rust1", since = "1.0.0")]
747     #[rustc_doc_only_macro]
748     macro_rules! include {
749         ($file:expr) => ({ /* compiler built-in */ });
750         ($file:expr,) => ({ /* compiler built-in */ });
751     }
752
753     /// Ensure that a boolean expression is `true` at runtime.
754     ///
755     /// For more information, see the documentation for [`std::assert!`].
756     ///
757     /// [`std::assert!`]: ../std/macro.assert.html
758     #[rustc_doc_only_macro]
759     #[stable(feature = "rust1", since = "1.0.0")]
760     macro_rules! assert {
761         ($cond:expr) => ({ /* compiler built-in */ });
762         ($cond:expr,) => ({ /* compiler built-in */ });
763         ($cond:expr, $($arg:tt)+) => ({ /* compiler built-in */ });
764     }
765 }