From 5253ced2af75acf67eaca3545dbeaf750e86b609 Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Sat, 5 Dec 2020 15:54:36 +0100 Subject: [PATCH] Fix warnings --- src/lexer/cursor.rs | 10 ++-------- src/lexer/mod.rs | 7 +++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/lexer/cursor.rs b/src/lexer/cursor.rs index 0fe1914..025100e 100644 --- a/src/lexer/cursor.rs +++ b/src/lexer/cursor.rs @@ -6,7 +6,6 @@ use std::str::Chars; /// Next characters can be peeked via `nth_char` method, /// and position can be shifted forward via `bump` method. pub(crate) struct Cursor<'a> { - initial_length: usize, pos: &'a mut Position, len: usize, chars: Chars<'a>, @@ -16,13 +15,8 @@ pub(crate) struct Cursor<'a> { pub(crate) const EOF_CHAR: char = '\0'; impl<'a> Cursor<'a> { - pub(crate) fn new( - input: &'a str, - initial_len: usize, - position: &'a mut Position, - ) -> Cursor<'a> { + pub(crate) fn new(input: &'a str, position: &'a mut Position) -> Cursor<'a> { Cursor { - initial_length: initial_len, len: input.len(), chars: input.chars(), #[cfg(debug_assertions)] @@ -74,7 +68,7 @@ impl<'a> Cursor<'a> { } pub(crate) fn pos(&self) -> Position { - let mut p = self.pos.clone(); + let p = self.pos.clone(); p } diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index 5af627f..a1f563b 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -102,7 +102,6 @@ pub enum Keyword { /// Creates an iterator that produces tokens from the input string. pub fn tokenize(mut input: &str) -> Vec { - let initial_length = input.len(); let mut pos = Position { raw: usize::MAX, line: 1, @@ -112,7 +111,7 @@ pub fn tokenize(mut input: &str) -> Vec { if input.is_empty() { return None; } - let token = first_token(input, initial_length, &mut pos); + let token = first_token(input, &mut pos); input = &input[token.len..]; Some(token) }) @@ -120,9 +119,9 @@ pub fn tokenize(mut input: &str) -> Vec { } /// Parses the first token from the provided input string. -pub fn first_token(input: &str, initial_len: usize, pos: &mut Position) -> Token { +pub fn first_token(input: &str, pos: &mut Position) -> Token { debug_assert!(!input.is_empty()); - Cursor::new(input, initial_len, pos).advance_token() + Cursor::new(input, pos).advance_token() } pub fn is_whitespace(c: char) -> bool {