Skip to content

Commit 5025113

Browse files
committed
Hint that the unwrap should always succeed.
1 parent 0fcac14 commit 5025113

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/parser/src/lexer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,11 @@ where
11251125

11261126
fn eat_single_char(&mut self, ty: Tok) {
11271127
let tok_start = self.get_pos();
1128-
self.next_char();
1128+
self.next_char().unwrap_or_else(|| unsafe {
1129+
// SAFETY: eat_single_char has been called only after a character has been read
1130+
// from the window, so the window is guaranteed to be non-empty.
1131+
std::hint::unreachable_unchecked()
1132+
});
11291133
let tok_end = self.get_pos();
11301134
self.emit((tok_start, ty, tok_end));
11311135
}

0 commit comments

Comments
 (0)