Fix the bug of next_point in span
This commit is contained in:
parent
11432fe952
commit
0af255a5aa
7 changed files with 13 additions and 13 deletions
|
@ -1461,7 +1461,7 @@ impl<'a> Parser<'a> {
|
|||
let (prev_sp, sp) = match (&self.token.kind, self.subparser_name) {
|
||||
// Point at the end of the macro call when reaching end of macro arguments.
|
||||
(token::Eof, Some(_)) => {
|
||||
let sp = self.sess.source_map().next_point(self.prev_token.span);
|
||||
let sp = self.prev_token.span.shrink_to_hi();
|
||||
(sp, sp)
|
||||
}
|
||||
// We don't want to point at the following span after DUMMY_SP.
|
||||
|
@ -2039,7 +2039,7 @@ impl<'a> Parser<'a> {
|
|||
pub(super) fn expected_expression_found(&self) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let (span, msg) = match (&self.token.kind, self.subparser_name) {
|
||||
(&token::Eof, Some(origin)) => {
|
||||
let sp = self.sess.source_map().next_point(self.prev_token.span);
|
||||
let sp = self.prev_token.span.shrink_to_hi();
|
||||
(sp, format!("expected expression, found end of {origin}"))
|
||||
}
|
||||
_ => (
|
||||
|
|
|
@ -2172,7 +2172,7 @@ impl<'a> Parser<'a> {
|
|||
},
|
||||
ExprKind::Block(_, None) => {
|
||||
self.sess.emit_err(IfExpressionMissingCondition {
|
||||
if_span: self.sess.source_map().next_point(lo),
|
||||
if_span: lo.shrink_to_hi(),
|
||||
block_span: self.sess.source_map().start_point(cond_span),
|
||||
});
|
||||
std::mem::replace(&mut cond, this.mk_expr_err(cond_span.shrink_to_hi()))
|
||||
|
|
|
@ -1601,7 +1601,7 @@ impl<'a> Parser<'a> {
|
|||
self.sess.emit_err(err);
|
||||
} else {
|
||||
if !seen_comma {
|
||||
let sp = self.sess.source_map().next_point(previous_span);
|
||||
let sp = previous_span.shrink_to_hi();
|
||||
err.missing_comma = Some(sp);
|
||||
}
|
||||
return Err(err.into_diagnostic(&self.sess.span_diagnostic));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue