Skip to content

Commit 22d53ad

Browse files
Rollup merge of #142118 - hkBst:lexer-patch1, r=oli-obk
rustc_lexer: typo fix + small cleanups
2 parents 6bbef98 + 2a5225a commit 22d53ad

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

compiler/rustc_lexer/src/cursor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a> Cursor<'a> {
6868

6969
/// Peeks the third symbol from the input stream without consuming it.
7070
pub fn third(&self) -> char {
71-
// `.next()` optimizes better than `.nth(1)`
71+
// `.next()` optimizes better than `.nth(2)`
7272
let mut iter = self.chars.clone();
7373
iter.next();
7474
iter.next();

compiler/rustc_lexer/src/lib.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ mod cursor;
3030
#[cfg(test)]
3131
mod tests;
3232

33+
use LiteralKind::*;
34+
use TokenKind::*;
35+
use cursor::EOF_CHAR;
36+
pub use cursor::{Cursor, FrontmatterAllowed};
3337
use unicode_properties::UnicodeEmoji;
3438
pub use unicode_xid::UNICODE_VERSION as UNICODE_XID_VERSION;
3539

36-
use self::LiteralKind::*;
37-
use self::TokenKind::*;
38-
use crate::cursor::EOF_CHAR;
39-
pub use crate::cursor::{Cursor, FrontmatterAllowed};
40-
4140
/// Parsed token.
4241
/// It doesn't contain information about data that has been parsed,
4342
/// only the type of the token and its size.
@@ -372,9 +371,8 @@ pub fn is_ident(string: &str) -> bool {
372371
impl Cursor<'_> {
373372
/// Parses a token from the input string.
374373
pub fn advance_token(&mut self) -> Token {
375-
let first_char = match self.bump() {
376-
Some(c) => c,
377-
None => return Token::new(TokenKind::Eof, 0),
374+
let Some(first_char) = self.bump() else {
375+
return Token::new(TokenKind::Eof, 0);
378376
};
379377

380378
let token_kind = match first_char {
@@ -788,7 +786,7 @@ impl Cursor<'_> {
788786
} else {
789787
// No base prefix, parse number in the usual way.
790788
self.eat_decimal_digits();
791-
};
789+
}
792790

793791
match self.first() {
794792
// Don't be greedy if this is actually an

0 commit comments

Comments
 (0)