diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2018-06-26 11:35:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-26 11:35:34 +0200 |
| commit | 756b69492b9cd4c3a3ee16514ed32764e0a059d3 (patch) | |
| tree | 2181194209148f6fdd461d66f2ea06d1ff0fa5ee /src/libstd | |
| parent | d72a67f3bbf48cec735de85ec9c4200b842a80f6 (diff) | |
| parent | f85ddfbc3f25b73d41aa9db332dcd72bf70cd985 (diff) | |
| download | rust-756b69492b9cd4c3a3ee16514ed32764e0a059d3.tar.gz rust-756b69492b9cd4c3a3ee16514ed32764e0a059d3.zip | |
Rollup merge of #51153 - ogham:panic-and-compile_error-docs, r=GuillaumeGomez
Link panic and compile_error docs This adds documentation links between `panic!()` and `compile_error!()` as per #47275, which points out that they’re similar. It also adds a sentence to the `compile_error()` docs I thought could be added.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index a856e7736fb..75f038407c1 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -38,10 +38,13 @@ /// The multi-argument form of this macro panics with a string and has the /// [`format!`] syntax for building a string. /// +/// See also the macro [`compile_error!`], for raising errors during compilation. +/// /// [runwrap]: ../std/result/enum.Result.html#method.unwrap /// [`Option`]: ../std/option/enum.Option.html#method.unwrap /// [`Result`]: ../std/result/enum.Result.html /// [`format!`]: ../std/macro.format.html +/// [`compile_error!`]: ../std/macro.compile_error.html /// [book]: ../book/second-edition/ch09-01-unrecoverable-errors-with-panic.html /// /// # Current implementation @@ -305,13 +308,16 @@ pub mod builtin { /// Unconditionally causes compilation to fail with the given error message when encountered. /// /// This macro should be used when a crate uses a conditional compilation strategy to provide - /// better error messages for erroneous conditions. + /// better error messages for erroneous conditions. It's the compiler-level form of [`panic!`], + /// which emits an error at *runtime*, rather than during compilation. /// /// # Examples /// /// Two such examples are macros and `#[cfg]` environments. /// - /// Emit better compiler error if a macro is passed invalid values. + /// Emit better compiler error if a macro is passed invalid values. Without the final branch, + /// the compiler would still emit an error, but the error's message would not mention the two + /// valid values. /// /// ```compile_fail /// macro_rules! give_me_foo_or_bar { @@ -332,6 +338,8 @@ pub mod builtin { /// #[cfg(not(any(feature = "foo", feature = "bar")))] /// compile_error!("Either feature \"foo\" or \"bar\" must be enabled for this crate.") /// ``` + /// + /// [`panic!`]: ../std/macro.panic.html #[stable(feature = "compile_error_macro", since = "1.20.0")] #[macro_export] macro_rules! compile_error { |
