diff --git a/crates/ra_syntax/src/parser_impl/event.rs b/crates/ra_syntax/src/parser_impl/event.rs index 48f37c57c71..4e6e25cfba2 100644 --- a/crates/ra_syntax/src/parser_impl/event.rs +++ b/crates/ra_syntax/src/parser_impl/event.rs @@ -148,14 +148,15 @@ fn tombstone() -> Event { } Event::Token { kind, - mut n_raw_tokens, + n_raw_tokens, } => { self.eat_ws(); - let mut len = 0.into(); - for _ in 0..n_raw_tokens { - len += self.tokens[self.token_pos].len; - } - self.leaf(kind, len, n_raw_tokens as usize); + let n_raw_tokens = n_raw_tokens as usize; + let len = self.tokens[self.token_pos..self.token_pos + n_raw_tokens] + .iter() + .map(|it| it.len) + .sum::(); + self.leaf(kind, len, n_raw_tokens); } Event::Error { msg } => self.sink.error(msg, self.text_pos), }