From bd23d68b4133fdf849544e8cbd866d86b535934d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 27 Jul 2022 12:50:22 +1000 Subject: [PATCH] Remove `StringReader::end_src_index`. It not needed, always being set to the end of the text. --- compiler/rustc_parse/src/lexer/mod.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 90df8dbd445..5868036c737 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -37,8 +37,7 @@ pub(crate) fn parse_token_trees<'a>( start_pos: BytePos, override_span: Option, ) -> (PResult<'a, TokenStream>, Vec) { - StringReader { sess, start_pos, pos: start_pos, end_src_index: src.len(), src, override_span } - .into_token_trees() + StringReader { sess, start_pos, pos: start_pos, src, override_span }.into_token_trees() } struct StringReader<'a> { @@ -47,8 +46,6 @@ struct StringReader<'a> { start_pos: BytePos, /// The absolute offset within the source_map of the current character. pos: BytePos, - /// Stop reading src at this index. - end_src_index: usize, /// Source text to tokenize. src: &'a str, override_span: Option, @@ -74,7 +71,7 @@ impl<'a> StringReader<'a> { // Skip trivial (whitespace & comments) tokens loop { let start_src_index = self.src_index(self.pos); - let text: &str = &self.src[start_src_index..self.end_src_index]; + let text: &str = &self.src[start_src_index..]; if text.is_empty() { let span = self.mk_sp(self.pos, self.pos);