diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-12-30 13:38:34 +0100 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-12-30 16:47:56 +0100 |
| commit | 0047e250909dd4739fcd20e77a49685f45490987 (patch) | |
| tree | 0d8d558e4ad845bf20ed47600c417a8c0a7c5be2 /compiler/rustc_middle/src/macros.rs | |
| parent | e5e5fcb0b758fcf7f149cc9206155dcfa18ec909 (diff) | |
| download | rust-0047e250909dd4739fcd20e77a49685f45490987.tar.gz rust-0047e250909dd4739fcd20e77a49685f45490987.zip | |
Add some docs to `bug`, `span_bug` and `delay_span_bug`
Diffstat (limited to 'compiler/rustc_middle/src/macros.rs')
| -rw-r--r-- | compiler/rustc_middle/src/macros.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/macros.rs b/compiler/rustc_middle/src/macros.rs index 01fe72de612..5ca4d260179 100644 --- a/compiler/rustc_middle/src/macros.rs +++ b/compiler/rustc_middle/src/macros.rs @@ -1,3 +1,13 @@ +/// A macro for triggering an ICE. +/// Calling `bug` instead of panicking will result in a nicer error message and should +/// therefore be prefered over `panic`/`unreachable` or others. +/// +/// If you have a span available, you should use [`span_bug`] instead. +/// +/// If the bug should only be emitted when compilation didn't fail, [`Session::delay_span_bug`] may be useful. +/// +/// [`Session::delay_span_bug`]: rustc_session::Session::delay_span_bug +/// [`span_bug`]: crate::span_bug #[macro_export] macro_rules! bug { () => ( $crate::bug!("impossible case reached") ); @@ -8,6 +18,14 @@ macro_rules! bug { }); } +/// A macro for triggering an ICE with a span. +/// Calling `span_bug!` instead of panicking will result in a nicer error message and point +/// at the code the compiler was compiling when it ICEd. This is the preferred way to trigger +/// ICEs. +/// +/// If the bug should only be emitted when compilation didn't fail, [`Session::delay_span_bug`] may be useful. +/// +/// [`Session::delay_span_bug`]: rustc_session::Session::delay_span_bug #[macro_export] macro_rules! span_bug { ($span:expr, $msg:expr) => ({ $crate::util::bug::span_bug_fmt($span, ::std::format_args!($msg)) }); |
