Skip to content

Commit 678736c

Browse files
committed
Clarify some dead code
next_token has this code: if is_ident_start(tokenizer) { IDHash(consume_name(tokenizer)) } else if !tokenizer.is_eof() && match tokenizer.next_byte_unchecked() { b'a'...b'z' | b'A'...b'Z' | b'0'...b'9' | b'-' | b'_' => true, b'\\' => !tokenizer.has_newline_at(1), _ => !b.is_ascii(), } { Hash(consume_name(tokenizer)) } I noticed that the `_` case incorrectly checks whether `b` is ASCII, rather than the current byte. However, on further inspection, it turns out that this can't be run, because all such cases would have been filtered out by is_ident_start. This patch clarifies this code by removing the dead cases and adding a comment.
1 parent 17d2a1d commit 678736c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/tokenizer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ fn next_token<'a>(tokenizer: &mut Tokenizer<'a>) -> Result<Token<'a>, ()> {
493493
tokenizer.advance(1);
494494
if is_ident_start(tokenizer) { IDHash(consume_name(tokenizer)) }
495495
else if !tokenizer.is_eof() && match tokenizer.next_byte_unchecked() {
496-
b'a'...b'z' | b'A'...b'Z' | b'0'...b'9' | b'-' | b'_' => true,
497-
b'\\' => !tokenizer.has_newline_at(1),
498-
_ => !b.is_ascii(),
496+
// Any other valid case here already resulted in IDHash.
497+
b'0'...b'9' | b'-' => true,
498+
_ => false,
499499
} { Hash(consume_name(tokenizer)) }
500500
else { Delim('#') }
501501
},

0 commit comments

Comments
 (0)