From 0df335f6e89518fb7fa61ff8ffed91d62414020b Mon Sep 17 00:00:00 2001 From: Luni-4 Date: Fri, 2 Dec 2022 09:48:08 +0100 Subject: [PATCH] Fix clippy warnings --- rust-code-analysis-cli/src/formats.rs | 2 +- src/tools.rs | 11 ++++------- tree-sitter-ccomment/bindings/rust/build.rs | 4 ++-- tree-sitter-mozcpp/bindings/rust/build.rs | 4 ++-- tree-sitter-mozjs/bindings/rust/build.rs | 2 +- tree-sitter-preproc/bindings/rust/build.rs | 4 ++-- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/rust-code-analysis-cli/src/formats.rs b/rust-code-analysis-cli/src/formats.rs index 4ffc189f2..16f8cdaf9 100644 --- a/rust-code-analysis-cli/src/formats.rs +++ b/rust-code-analysis-cli/src/formats.rs @@ -87,7 +87,7 @@ impl Format { let format_path = output_path.as_ref().unwrap().join(filename); // Create directories - create_dir_all(&format_path.parent().unwrap()).unwrap(); + create_dir_all(format_path.parent().unwrap()).unwrap(); let mut format_file = File::create(format_path)?; match self { diff --git a/src/tools.rs b/src/tools.rs index 2043432e5..be3629452 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -45,7 +45,7 @@ pub fn read_file(path: &Path) -> std::io::Result> { /// read_file_with_eol(&path).unwrap(); /// ``` pub fn read_file_with_eol(path: &Path) -> std::io::Result>> { - let file_size = fs::metadata(&path).map_or(1024 * 1024, |m| m.len() as usize); + let file_size = fs::metadata(path).map_or(1024 * 1024, |m| m.len() as usize); if file_size <= 3 { // this file is very likely almost empty... so nothing to do on it return Ok(None); @@ -198,7 +198,7 @@ pub fn guess_language>(buf: &[u8], path: P) -> (Option, Str .unwrap_or_else(|| "".to_string()); let from_ext = get_from_ext(&ext); - let mode = get_emacs_mode(buf).unwrap_or_else(|| "".to_string()); + let mode = get_emacs_mode(buf).unwrap_or_default(); let from_mode = get_from_emacs_mode(&mode); @@ -225,10 +225,7 @@ pub fn guess_language>(buf: &[u8], path: P) -> (Option, Str fake::get_true(&ext, &mode).unwrap_or_else(|| lang_mode.get_name().to_string()), ) } else { - ( - None, - fake::get_true(&ext, &mode).unwrap_or_else(|| "".to_string()), - ) + (None, fake::get_true(&ext, &mode).unwrap_or_default()) } } @@ -317,7 +314,7 @@ pub(crate) fn guess_file( if let Some(parent) = current_path.parent() { for p in possibilities.iter() { - if p.starts_with(&parent) && current_path != p { + if p.starts_with(parent) && current_path != p { new_possibilities.push(p.clone()); } } diff --git a/tree-sitter-ccomment/bindings/rust/build.rs b/tree-sitter-ccomment/bindings/rust/build.rs index 19e7949a0..150725089 100644 --- a/tree-sitter-ccomment/bindings/rust/build.rs +++ b/tree-sitter-ccomment/bindings/rust/build.rs @@ -6,7 +6,7 @@ fn main() { let src_dir = Path::new("src"); let mut c_config = cc::Build::new(); - c_config.include(&src_dir); + c_config.include(src_dir); c_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable") @@ -18,7 +18,7 @@ fn main() { let mut cpp_config = cc::Build::new(); cpp_config.cpp(true); - cpp_config.include(&src_dir); + cpp_config.include(src_dir); cpp_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable"); diff --git a/tree-sitter-mozcpp/bindings/rust/build.rs b/tree-sitter-mozcpp/bindings/rust/build.rs index 19e7949a0..150725089 100644 --- a/tree-sitter-mozcpp/bindings/rust/build.rs +++ b/tree-sitter-mozcpp/bindings/rust/build.rs @@ -6,7 +6,7 @@ fn main() { let src_dir = Path::new("src"); let mut c_config = cc::Build::new(); - c_config.include(&src_dir); + c_config.include(src_dir); c_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable") @@ -18,7 +18,7 @@ fn main() { let mut cpp_config = cc::Build::new(); cpp_config.cpp(true); - cpp_config.include(&src_dir); + cpp_config.include(src_dir); cpp_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable"); diff --git a/tree-sitter-mozjs/bindings/rust/build.rs b/tree-sitter-mozjs/bindings/rust/build.rs index a727142cb..f5f4f72f0 100644 --- a/tree-sitter-mozjs/bindings/rust/build.rs +++ b/tree-sitter-mozjs/bindings/rust/build.rs @@ -6,7 +6,7 @@ fn main() { let src_dir = Path::new("src"); let mut c_config = cc::Build::new(); - c_config.include(&src_dir); + c_config.include(src_dir); c_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable") diff --git a/tree-sitter-preproc/bindings/rust/build.rs b/tree-sitter-preproc/bindings/rust/build.rs index 19e7949a0..150725089 100644 --- a/tree-sitter-preproc/bindings/rust/build.rs +++ b/tree-sitter-preproc/bindings/rust/build.rs @@ -6,7 +6,7 @@ fn main() { let src_dir = Path::new("src"); let mut c_config = cc::Build::new(); - c_config.include(&src_dir); + c_config.include(src_dir); c_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable") @@ -18,7 +18,7 @@ fn main() { let mut cpp_config = cc::Build::new(); cpp_config.cpp(true); - cpp_config.include(&src_dir); + cpp_config.include(src_dir); cpp_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable");