Skip to content

Commit 635c6d0

Browse files
committed
Simplify bug! and span_bug!.
Three rules can be combined into one. I based this change on the definition of `print!`.
1 parent 6ac8878 commit 635c6d0

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

compiler/rustc_middle/src/macros.rs

+8-20
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
///
55
/// If you have a span available, you should use [`span_bug`] instead.
66
///
7-
/// If the bug should only be emitted when compilation didn't fail, [`DiagCtxtHandle::span_delayed_bug`]
8-
/// may be useful.
7+
/// If the bug should only be emitted when compilation didn't fail,
8+
/// [`DiagCtxtHandle::span_delayed_bug`] may be useful.
99
///
1010
/// [`DiagCtxtHandle::span_delayed_bug`]: rustc_errors::DiagCtxtHandle::span_delayed_bug
1111
/// [`span_bug`]: crate::span_bug
@@ -14,14 +14,8 @@ macro_rules! bug {
1414
() => (
1515
$crate::bug!("impossible case reached")
1616
);
17-
($msg:expr) => (
18-
$crate::util::bug::bug_fmt(::std::format_args!($msg))
19-
);
20-
($msg:expr,) => (
21-
$crate::bug!($msg)
22-
);
23-
($fmt:expr, $($arg:tt)+) => (
24-
$crate::util::bug::bug_fmt(::std::format_args!($fmt, $($arg)+))
17+
($($arg:tt)+) => (
18+
$crate::util::bug::bug_fmt(::std::format_args!($($arg)+))
2519
);
2620
}
2721

@@ -30,20 +24,14 @@ macro_rules! bug {
3024
/// at the code the compiler was compiling when it ICEd. This is the preferred way to trigger
3125
/// ICEs.
3226
///
33-
/// If the bug should only be emitted when compilation didn't fail, [`DiagCtxtHandle::span_delayed_bug`]
34-
/// may be useful.
27+
/// If the bug should only be emitted when compilation didn't fail,
28+
/// [`DiagCtxtHandle::span_delayed_bug`] may be useful.
3529
///
3630
/// [`DiagCtxtHandle::span_delayed_bug`]: rustc_errors::DiagCtxtHandle::span_delayed_bug
3731
#[macro_export]
3832
macro_rules! span_bug {
39-
($span:expr, $msg:expr) => (
40-
$crate::util::bug::span_bug_fmt($span, ::std::format_args!($msg))
41-
);
42-
($span:expr, $msg:expr,) => (
43-
$crate::span_bug!($span, $msg)
44-
);
45-
($span:expr, $fmt:expr, $($arg:tt)+) => (
46-
$crate::util::bug::span_bug_fmt($span, ::std::format_args!($fmt, $($arg)+))
33+
($span:expr, $($arg:tt)+) => (
34+
$crate::util::bug::span_bug_fmt($span, ::std::format_args!($($arg)+))
4735
);
4836
}
4937

0 commit comments

Comments
 (0)