Use Session::diagnostic
in more places.
This commit is contained in:
parent
a179a53565
commit
31ac4efb31
7 changed files with 33 additions and 40 deletions
|
@ -247,11 +247,11 @@ impl<'a> Parser<'a> {
|
|||
sp: S,
|
||||
m: impl Into<DiagnosticMessage>,
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
self.sess.span_diagnostic.struct_span_err(sp, m)
|
||||
self.diagnostic().struct_span_err(sp, m)
|
||||
}
|
||||
|
||||
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: impl Into<String>) -> ! {
|
||||
self.sess.span_diagnostic.span_bug(sp, m)
|
||||
self.diagnostic().span_bug(sp, m)
|
||||
}
|
||||
|
||||
pub(super) fn diagnostic(&self) -> &'a Handler {
|
||||
|
@ -285,7 +285,7 @@ impl<'a> Parser<'a> {
|
|||
span: self.prev_token.span,
|
||||
missing_comma: None,
|
||||
}
|
||||
.into_diagnostic(&self.sess.span_diagnostic));
|
||||
.into_diagnostic(self.diagnostic()));
|
||||
}
|
||||
|
||||
let valid_follow = &[
|
||||
|
@ -348,7 +348,7 @@ impl<'a> Parser<'a> {
|
|||
suggest_remove_comma,
|
||||
help_cannot_start_number,
|
||||
};
|
||||
let mut err = err.into_diagnostic(&self.sess.span_diagnostic);
|
||||
let mut err = err.into_diagnostic(self.diagnostic());
|
||||
|
||||
// if the token we have is a `<`
|
||||
// it *might* be a misplaced generic
|
||||
|
@ -1426,7 +1426,7 @@ impl<'a> Parser<'a> {
|
|||
// Not entirely sure now, but we bubble the error up with the
|
||||
// suggestion.
|
||||
self.restore_snapshot(snapshot);
|
||||
Err(err.into_diagnostic(&self.sess.span_diagnostic))
|
||||
Err(err.into_diagnostic(self.diagnostic()))
|
||||
}
|
||||
}
|
||||
} else if token::OpenDelim(Delimiter::Parenthesis) == self.token.kind {
|
||||
|
@ -1441,7 +1441,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
// Consume the fn call arguments.
|
||||
match self.consume_fn_args() {
|
||||
Err(()) => Err(err.into_diagnostic(&self.sess.span_diagnostic)),
|
||||
Err(()) => Err(err.into_diagnostic(self.diagnostic())),
|
||||
Ok(()) => {
|
||||
self.sess.emit_err(err);
|
||||
// FIXME: actually check that the two expressions in the binop are
|
||||
|
@ -1467,7 +1467,7 @@ impl<'a> Parser<'a> {
|
|||
mk_err_expr(self, inner_op.span.to(self.prev_token.span))
|
||||
} else {
|
||||
// These cases cause too many knock-down errors, bail out (#61329).
|
||||
Err(err.into_diagnostic(&self.sess.span_diagnostic))
|
||||
Err(err.into_diagnostic(self.diagnostic()))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -2522,8 +2522,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(Some(GenericArg::Const(self.parse_const_arg()?)))
|
||||
} else {
|
||||
let after_kw_const = self.token.span;
|
||||
self.recover_const_arg(after_kw_const, err.into_diagnostic(&self.sess.span_diagnostic))
|
||||
.map(Some)
|
||||
self.recover_const_arg(after_kw_const, err.into_diagnostic(self.diagnostic())).map(Some)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2886,7 +2885,7 @@ impl<'a> Parser<'a> {
|
|||
span: path.span.shrink_to_hi(),
|
||||
between: between_span,
|
||||
}
|
||||
.into_diagnostic(&self.sess.span_diagnostic));
|
||||
.into_diagnostic(self.diagnostic()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue