lexer: fix clippy warnings

This commit is contained in:
Theis Pieter Hollebeek 2023-02-08 09:03:20 +01:00
parent cf78869a9e
commit ad6bf8932a

View File

@ -197,9 +197,7 @@ fn make_comment<T: Iterator<Item = char>>(
line: &mut usize, line: &mut usize,
) -> Result<Token, TokenError> { ) -> Result<Token, TokenError> {
let first_slash = iter.next().expect(NO_MUT_PEEK_NEXT_MESSAGE); let first_slash = iter.next().expect(NO_MUT_PEEK_NEXT_MESSAGE);
let second_character = if let Some(c) = iter.next() { let Some(second_character) = iter.next() else {
c
} else {
return Err(TokenError { return Err(TokenError {
error: "unexpected EOF".to_string(), error: "unexpected EOF".to_string(),
col: *col, col: *col,
@ -217,9 +215,7 @@ fn make_comment<T: Iterator<Item = char>>(
} }
}, },
'*' => { '*' => {
let mut current = if let Some(c) = iter.next() { let Some(mut current) = iter.next() else {
c
} else {
return Err(TokenError { return Err(TokenError {
error: "unexpected EOF".to_string(), error: "unexpected EOF".to_string(),
col: *col, col: *col,
@ -287,9 +283,7 @@ pub fn lexer(code: &str) -> Vec<Token> {
let mut col = 0; let mut col = 0;
let mut line = 0; let mut line = 0;
loop { loop {
let char = if let Some(c) = iter.peek() { let Some(char) = iter.peek() else {
c
} else {
break tokens; break tokens;
}; };