parser: bug -> span_bug

This commit is contained in:
Mazdak Farrokhzad 2019-12-31 04:30:55 +01:00
parent 4ae9c1c3ec
commit 2e7806146c
4 changed files with 6 additions and 7 deletions

View file

@ -165,10 +165,6 @@ impl<'a> Parser<'a> {
err.span_err(sp, self.diagnostic())
}
pub(super) fn bug(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_bug(self.token.span, m)
}
pub fn struct_span_err<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> {
self.sess.span_diagnostic.struct_span_err(sp, m)
}

View file

@ -283,7 +283,7 @@ impl<'a> Parser<'a> {
self.mk_expr(span, aopexpr, AttrVec::new())
}
AssocOp::As | AssocOp::Colon | AssocOp::DotDot | AssocOp::DotDotEq => {
self.bug("AssocOp should have been handled by special case")
self.span_bug(span, "AssocOp should have been handled by special case")
}
};

View file

@ -884,7 +884,8 @@ impl<'a> Parser<'a> {
pub fn bump(&mut self) {
if self.prev_token_kind == PrevTokenKind::Eof {
// Bumping after EOF is a bad sign, usually an infinite loop.
self.bug("attempted to bump the parser past EOF (may be stuck in a loop)");
let msg = "attempted to bump the parser past EOF (may be stuck in a loop)";
self.span_bug(self.token.span, msg);
}
self.prev_span = self.meta_var_span.take().unwrap_or(self.token.span);

View file

@ -175,7 +175,9 @@ impl<'a> Parser<'a> {
{
let path = match bounds.remove(0) {
GenericBound::Trait(pt, ..) => pt.trait_ref.path,
GenericBound::Outlives(..) => self.bug("unexpected lifetime bound"),
GenericBound::Outlives(..) => {
self.span_bug(ty.span, "unexpected lifetime bound")
}
};
self.parse_remaining_bounds(Vec::new(), path, lo, true)
}