]>
git.proxmox.com Git - rustc.git/blob - src/librustc/util/bug.rs
1 // These functions are used by macro expansion for bug! and span_bug!
5 use syntax_pos
::{Span, MultiSpan}
;
9 pub fn bug_fmt(file
: &'
static str, line
: u32, args
: fmt
::Arguments
<'_
>) -> ! {
10 // this wrapper mostly exists so I don't have to write a fully
11 // qualified path of None::<Span> inside the bug!() macro definition
12 opt_span_bug_fmt(file
, line
, None
::<Span
>, args
);
17 pub fn span_bug_fmt
<S
: Into
<MultiSpan
>>(
21 args
: fmt
::Arguments
<'_
>,
23 opt_span_bug_fmt(file
, line
, Some(span
), args
);
26 fn opt_span_bug_fmt
<S
: Into
<MultiSpan
>>(
30 args
: fmt
::Arguments
<'_
>,
32 tls
::with_opt(move |tcx
| {
33 let msg
= format
!("{}:{}: {}", file
, line
, args
);
35 (Some(tcx
), Some(span
)) => tcx
.sess
.diagnostic().span_bug(span
, &msg
),
36 (Some(tcx
), None
) => tcx
.sess
.diagnostic().bug(&msg
),
37 (None
, _
) => panic
!(msg
),