From dbc562c61311b1d99ccfd8f17125089e2b400867 Mon Sep 17 00:00:00 2001 From: Windel Bouwman Date: Sun, 11 Aug 2019 09:57:40 +0200 Subject: [PATCH] Implement clippy hint. --- examples/parse_folder.rs | 14 +++++++------- parser/src/lexer.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/parse_folder.rs b/examples/parse_folder.rs index 33530708d..ad0c5f859 100644 --- a/examples/parse_folder.rs +++ b/examples/parse_folder.rs @@ -14,7 +14,7 @@ extern crate log; use clap::{App, Arg}; use rustpython_parser::{ast, parser}; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::time::{Duration, Instant}; fn main() { @@ -77,8 +77,8 @@ fn parse_python_file(filename: &Path) -> ParsedFile { info!("Parsing file {:?}", filename); match std::fs::read_to_string(filename) { Err(e) => ParsedFile { - filename: Box::new(filename.to_path_buf()), - code: "".to_string(), + // filename: Box::new(filename.to_path_buf()), + // code: "".to_string(), num_lines: 0, result: Err(e.to_string()), }, @@ -86,8 +86,8 @@ fn parse_python_file(filename: &Path) -> ParsedFile { let num_lines = source.to_string().lines().count(); let result = parser::parse_program(&source).map_err(|e| e.to_string()); ParsedFile { - filename: Box::new(filename.to_path_buf()), - code: source.to_string(), + // filename: Box::new(filename.to_path_buf()), + // code: source.to_string(), num_lines, result, } @@ -140,8 +140,8 @@ struct ScanResult { } struct ParsedFile { - filename: Box, - code: String, + // filename: Box, + // code: String, num_lines: usize, result: ParseResult, } diff --git a/parser/src/lexer.rs b/parser/src/lexer.rs index 405162104..0f2e28bd2 100644 --- a/parser/src/lexer.rs +++ b/parser/src/lexer.rs @@ -416,7 +416,7 @@ where loop { if let Some(c) = self.take_number(radix) { value_text.push(c); - } else if self.chr0 == Some('_') && Lexer::::is_digit_of_radix(&self.chr1, radix) { + } else if self.chr0 == Some('_') && Lexer::::is_digit_of_radix(self.chr1, radix) { self.next_char(); } else { break; @@ -427,7 +427,7 @@ where /// Consume a single character with the given radix. fn take_number(&mut self, radix: u32) -> Option { - let take_char = Lexer::::is_digit_of_radix(&self.chr0, radix); + let take_char = Lexer::::is_digit_of_radix(self.chr0, radix); if take_char { Some(self.next_char().unwrap()) @@ -437,7 +437,7 @@ where } /// Test if a digit is of a certain radix. - fn is_digit_of_radix(c: &Option, radix: u32) -> bool { + fn is_digit_of_radix(c: Option, radix: u32) -> bool { match radix { 2 => match c { Some('0'..='1') => true,