fix(parse): Don't assume boundary characters are one byte

This was inspired by heck.  They have an invariant to ensure this isn't
a problem (only accept `_` as boundary) while on the other hand we
accept a lot of things as boundaries.
This commit is contained in:
Ed Page 2019-07-06 21:54:43 -06:00
parent 60372effa1
commit 166e2630c0

View file

@ -176,13 +176,12 @@ fn split_ident(ident: &str, offset: usize) -> impl Iterator<Item = Word<'_>> {
while let Some((i, c)) = char_indices.next() { while let Some((i, c)) = char_indices.next() {
let cur_mode = WordMode::classify(c); let cur_mode = WordMode::classify(c);
if cur_mode == WordMode::Boundary { if cur_mode == WordMode::Boundary {
if start == i { assert!(start_mode == WordMode::Boundary);
start += 1;
}
continue; continue;
} }
if start_mode == WordMode::Boundary { if start_mode == WordMode::Boundary {
start_mode = cur_mode; start_mode = cur_mode;
start = i;
} }
if let Some(&(next_i, next)) = char_indices.peek() { if let Some(&(next_i, next)) = char_indices.peek() {