Skip to content

Commit a02c18a

Browse files
committed
Fix token::Eof spans.
1 parent f6eaaf3 commit a02c18a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libsyntax/parse/parser.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl TokenCursor {
223223
self.frame = frame;
224224
continue
225225
} else {
226-
return TokenAndSpan { tok: token::Eof, sp: self.frame.span }
226+
return TokenAndSpan { tok: token::Eof, sp: syntax_pos::DUMMY_SP }
227227
};
228228

229229
match tree {
@@ -448,10 +448,14 @@ impl<'a> Parser<'a> {
448448
}
449449

450450
fn next_tok(&mut self) -> TokenAndSpan {
451-
match self.desugar_doc_comments {
451+
let mut next = match self.desugar_doc_comments {
452452
true => self.token_cursor.next_desugared(),
453453
false => self.token_cursor.next(),
454+
};
455+
if next.sp == syntax_pos::DUMMY_SP {
456+
next.sp = self.prev_span;
454457
}
458+
next
455459
}
456460

457461
/// Convert a token to a string using self's reader

0 commit comments

Comments
 (0)