track caller for delay_span_bug
This commit is contained in:
parent
268decbac8
commit
e855b90a8e
|
@ -5,6 +5,7 @@
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
|
#![feature(track_caller)]
|
||||||
|
|
||||||
pub use emitter::ColorConfig;
|
pub use emitter::ColorConfig;
|
||||||
|
|
||||||
|
@ -621,6 +622,7 @@ impl Handler {
|
||||||
self.inner.borrow_mut().span_bug(span, msg)
|
self.inner.borrow_mut().span_bug(span, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
pub fn delay_span_bug(&self, span: impl Into<MultiSpan>, msg: &str) {
|
pub fn delay_span_bug(&self, span: impl Into<MultiSpan>, msg: &str) {
|
||||||
self.inner.borrow_mut().delay_span_bug(span, msg)
|
self.inner.borrow_mut().delay_span_bug(span, msg)
|
||||||
}
|
}
|
||||||
|
@ -873,6 +875,7 @@ impl HandlerInner {
|
||||||
self.emit_diagnostic(diag.set_span(sp));
|
self.emit_diagnostic(diag.set_span(sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
fn delay_span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) {
|
fn delay_span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) {
|
||||||
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
|
// This is technically `self.treat_err_as_bug()` but `delay_span_bug` is called before
|
||||||
// incrementing `err_count` by one, so we need to +1 the comparing.
|
// incrementing `err_count` by one, so we need to +1 the comparing.
|
||||||
|
@ -883,6 +886,7 @@ impl HandlerInner {
|
||||||
}
|
}
|
||||||
let mut diagnostic = Diagnostic::new(Level::Bug, msg);
|
let mut diagnostic = Diagnostic::new(Level::Bug, msg);
|
||||||
diagnostic.set_span(sp.into());
|
diagnostic.set_span(sp.into());
|
||||||
|
diagnostic.note(&format!("delayed at {}", std::panic::Location::caller()));
|
||||||
self.delay_as_bug(diagnostic)
|
self.delay_as_bug(diagnostic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1144,40 +1144,22 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
|
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn ty_error(self) -> Ty<'tcx> {
|
pub fn ty_error(self) -> Ty<'tcx> {
|
||||||
self.err_with_message_and_location(
|
self.ty_error_with_message(DUMMY_SP, "TyKind::Error constructed but no error reported")
|
||||||
DUMMY_SP,
|
|
||||||
"TyKind::Error constructed but no error reported",
|
|
||||||
std::panic::Location::caller(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to
|
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to
|
||||||
/// ensure it gets used.
|
/// ensure it gets used.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn ty_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Ty<'tcx> {
|
pub fn ty_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Ty<'tcx> {
|
||||||
self.err_with_message_and_location(span, msg, std::panic::Location::caller())
|
self.sess.delay_span_bug(span, msg);
|
||||||
}
|
|
||||||
|
|
||||||
pub fn err_with_message_and_location<S: Into<MultiSpan>>(
|
|
||||||
self,
|
|
||||||
span: S,
|
|
||||||
msg: &str,
|
|
||||||
loc: &'static std::panic::Location<'static>,
|
|
||||||
) -> Ty<'tcx> {
|
|
||||||
self.sess.delay_span_bug(span, &format!("{}: {}", loc, msg));
|
|
||||||
self.mk_ty(Error(super::sty::DelaySpanBugEmitted(())))
|
self.mk_ty(Error(super::sty::DelaySpanBugEmitted(())))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `err` but for constants.
|
/// Like `err` but for constants.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn const_error(self, ty: Ty<'tcx>) -> &'tcx Const<'tcx> {
|
pub fn const_error(self, ty: Ty<'tcx>) -> &'tcx Const<'tcx> {
|
||||||
self.sess.delay_span_bug(
|
self.sess
|
||||||
DUMMY_SP,
|
.delay_span_bug(DUMMY_SP, "ty::ConstKind::Error constructed but no error reported.");
|
||||||
&format!(
|
|
||||||
"ty::ConstKind::Error constructed but no error reported. {}",
|
|
||||||
std::panic::Location::caller()
|
|
||||||
),
|
|
||||||
);
|
|
||||||
self.mk_const(ty::Const {
|
self.mk_const(ty::Const {
|
||||||
val: ty::ConstKind::Error(super::sty::DelaySpanBugEmitted(())),
|
val: ty::ConstKind::Error(super::sty::DelaySpanBugEmitted(())),
|
||||||
ty,
|
ty,
|
||||||
|
|
Loading…
Reference in New Issue