Skip to content

Commit 11c39ac

Browse files
committed
Link the docs of panic!() and compile_error!()
Fixes #47275. These two macros are similar, but different, and could do with documentation links to each other.
1 parent fe5c45b commit 11c39ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libstd/macros.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@
3838
/// The multi-argument form of this macro panics with a string and has the
3939
/// [`format!`] syntax for building a string.
4040
///
41+
/// See also the macro [`compile_error!`], for raising errors during compilation.
42+
///
4143
/// [runwrap]: ../std/result/enum.Result.html#method.unwrap
4244
/// [`Option`]: ../std/option/enum.Option.html#method.unwrap
4345
/// [`Result`]: ../std/result/enum.Result.html
4446
/// [`format!`]: ../std/macro.format.html
47+
/// [`compile_error!`]: ../std/macro.compile_error.html
4548
/// [book]: ../book/second-edition/ch09-01-unrecoverable-errors-with-panic.html
4649
///
4750
/// # Current implementation
@@ -286,7 +289,8 @@ pub mod builtin {
286289
/// Unconditionally causes compilation to fail with the given error message when encountered.
287290
///
288291
/// This macro should be used when a crate uses a conditional compilation strategy to provide
289-
/// better error messages for erroneous conditions.
292+
/// better error messages for erroneous conditions. It's the compiler-level form of [`panic!`],
293+
/// which emits an error at *runtime*, rather than during compilation.
290294
///
291295
/// # Examples
292296
///
@@ -313,6 +317,8 @@ pub mod builtin {
313317
/// #[cfg(not(any(feature = "foo", feature = "bar")))]
314318
/// compile_error!("Either feature \"foo\" or \"bar\" must be enabled for this crate.")
315319
/// ```
320+
///
321+
/// [`panic!`]: ../std/macro.panic.html
316322
#[stable(feature = "compile_error_macro", since = "1.20.0")]
317323
#[macro_export]
318324
macro_rules! compile_error {

0 commit comments

Comments
 (0)