Implement clippy hint.

This commit is contained in:
Windel Bouwman committed 2019-08-11 09:57:40 +02:00
1 parent a400f6631c
commit dbc562c613
2 files changed
+10 -10

No files matched your search

+7 -7
View File
@@ -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<PathBuf>,
code: String,
// filename: Box<PathBuf>,
// code: String,
num_lines: usize,
result: ParseResult,
}
+3 -3
View File
@@ -416,7 +416,7 @@ where
loop {
if let Some(c) = self.take_number(radix) {
value_text.push(c);
} else if self.chr0 == Some('_') && Lexer::<T>::is_digit_of_radix(&self.chr1, radix) {
} else if self.chr0 == Some('_') && Lexer::<T>::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<char> {
let take_char = Lexer::<T>::is_digit_of_radix(&self.chr0, radix);
let take_char = Lexer::<T>::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<char>, radix: u32) -> bool {
fn is_digit_of_radix(c: Option<char>, radix: u32) -> bool {
match radix {
2 => match c {
Some('0'..='1') => true,