Skip to content

Commit

Permalink
Rollup merge of rust-lang#122827 - compiler-errors:span-bugs, r=Waffl…
Browse files Browse the repository at this point in the history
…eLapkin

Remove unnecessary braces from `bug`/`span_bug`

They make never fallback weird and are unnecessary

r? `@WaffleLapkin`
  • Loading branch information
matthiaskrgr authored Mar 21, 2024
2 parents 55a9165 + abb59b2 commit 6ae51a5
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions compiler/rustc_middle/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@
/// [`span_bug`]: crate::span_bug
#[macro_export]
macro_rules! bug {
() => ( $crate::bug!("impossible case reached") );
($msg:expr) => ({ $crate::util::bug::bug_fmt(::std::format_args!($msg)) });
($msg:expr,) => ({ $crate::bug!($msg) });
($fmt:expr, $($arg:tt)+) => ({
() => (
$crate::bug!("impossible case reached")
);
($msg:expr) => (
$crate::util::bug::bug_fmt(::std::format_args!($msg))
);
($msg:expr,) => (
$crate::bug!($msg)
);
($fmt:expr, $($arg:tt)+) => (
$crate::util::bug::bug_fmt(::std::format_args!($fmt, $($arg)+))
});
);
}

/// A macro for triggering an ICE with a span.
Expand All @@ -30,11 +36,15 @@ macro_rules! bug {
/// [`DiagCtxt::span_delayed_bug`]: rustc_errors::DiagCtxt::span_delayed_bug
#[macro_export]
macro_rules! span_bug {
($span:expr, $msg:expr) => ({ $crate::util::bug::span_bug_fmt($span, ::std::format_args!($msg)) });
($span:expr, $msg:expr,) => ({ $crate::span_bug!($span, $msg) });
($span:expr, $fmt:expr, $($arg:tt)+) => ({
($span:expr, $msg:expr) => (
$crate::util::bug::span_bug_fmt($span, ::std::format_args!($msg))
);
($span:expr, $msg:expr,) => (
$crate::span_bug!($span, $msg)
);
($span:expr, $fmt:expr, $($arg:tt)+) => (
$crate::util::bug::span_bug_fmt($span, ::std::format_args!($fmt, $($arg)+))
});
);
}

///////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 6ae51a5

Please sign in to comment.