diff options
| author | mark <markm@cs.wisc.edu> | 2020-05-26 12:49:11 -0500 |
|---|---|---|
| committer | mark <markm@cs.wisc.edu> | 2020-06-15 18:25:58 -0500 |
| commit | e855b90a8e159d27e014847ef50d9536aa1249d0 (patch) | |
| tree | 0d005058016fdbc1add5bb925d7e8c9c7b502249 /src | |
| parent | 268decbac8bad298299702a0d17c9213f0a14f2e (diff) | |
| download | rust-e855b90a8e159d27e014847ef50d9536aa1249d0.tar.gz rust-e855b90a8e159d27e014847ef50d9536aa1249d0.zip | |
track caller for delay_span_bug
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_errors/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustc_middle/ty/context.rs | 26 |
2 files changed, 8 insertions, 22 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 7261c638ce0..0c1418d3cad 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -5,6 +5,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(crate_visibility_modifier)] #![feature(nll)] +#![feature(track_caller)] pub use emitter::ColorConfig; @@ -621,6 +622,7 @@ impl Handler { self.inner.borrow_mut().span_bug(span, msg) } + #[track_caller] pub fn delay_span_bug(&self, span: impl Into<MultiSpan>, msg: &str) { self.inner.borrow_mut().delay_span_bug(span, msg) } @@ -873,6 +875,7 @@ impl HandlerInner { self.emit_diagnostic(diag.set_span(sp)); } + #[track_caller] 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 // 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); diagnostic.set_span(sp.into()); + diagnostic.note(&format!("delayed at {}", std::panic::Location::caller())); self.delay_as_bug(diagnostic) } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index 4fe8173becf..1715b545662 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -1144,40 +1144,22 @@ impl<'tcx> TyCtxt<'tcx> { /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used. #[track_caller] pub fn ty_error(self) -> Ty<'tcx> { - self.err_with_message_and_location( - DUMMY_SP, - "TyKind::Error constructed but no error reported", - std::panic::Location::caller(), - ) + self.ty_error_with_message(DUMMY_SP, "TyKind::Error constructed but no error reported") } /// Constructs a `TyKind::Error` type and registers a `delay_span_bug` with the given `msg to /// ensure it gets used. #[track_caller] 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()) - } - - 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.sess.delay_span_bug(span, msg); self.mk_ty(Error(super::sty::DelaySpanBugEmitted(()))) } /// Like `err` but for constants. #[track_caller] pub fn const_error(self, ty: Ty<'tcx>) -> &'tcx Const<'tcx> { - self.sess.delay_span_bug( - DUMMY_SP, - &format!( - "ty::ConstKind::Error constructed but no error reported. {}", - std::panic::Location::caller() - ), - ); + self.sess + .delay_span_bug(DUMMY_SP, "ty::ConstKind::Error constructed but no error reported."); self.mk_const(ty::Const { val: ty::ConstKind::Error(super::sty::DelaySpanBugEmitted(())), ty, |
