Skip to content

Commit ceb4ccb

Browse files
authored
Fix clippy warnings (#951)
1 parent 2f6af3e commit ceb4ccb

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

rust-code-analysis-cli/src/formats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Format {
8787
let format_path = output_path.as_ref().unwrap().join(filename);
8888

8989
// Create directories
90-
create_dir_all(&format_path.parent().unwrap()).unwrap();
90+
create_dir_all(format_path.parent().unwrap()).unwrap();
9191

9292
let mut format_file = File::create(format_path)?;
9393
match self {

src/tools.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn read_file(path: &Path) -> std::io::Result<Vec<u8>> {
4545
/// read_file_with_eol(&path).unwrap();
4646
/// ```
4747
pub fn read_file_with_eol(path: &Path) -> std::io::Result<Option<Vec<u8>>> {
48-
let file_size = fs::metadata(&path).map_or(1024 * 1024, |m| m.len() as usize);
48+
let file_size = fs::metadata(path).map_or(1024 * 1024, |m| m.len() as usize);
4949
if file_size <= 3 {
5050
// this file is very likely almost empty... so nothing to do on it
5151
return Ok(None);
@@ -198,7 +198,7 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
198198
.unwrap_or_else(|| "".to_string());
199199
let from_ext = get_from_ext(&ext);
200200

201-
let mode = get_emacs_mode(buf).unwrap_or_else(|| "".to_string());
201+
let mode = get_emacs_mode(buf).unwrap_or_default();
202202

203203
let from_mode = get_from_emacs_mode(&mode);
204204

@@ -225,10 +225,7 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
225225
fake::get_true(&ext, &mode).unwrap_or_else(|| lang_mode.get_name().to_string()),
226226
)
227227
} else {
228-
(
229-
None,
230-
fake::get_true(&ext, &mode).unwrap_or_else(|| "".to_string()),
231-
)
228+
(None, fake::get_true(&ext, &mode).unwrap_or_default())
232229
}
233230
}
234231

@@ -317,7 +314,7 @@ pub(crate) fn guess_file<S: ::std::hash::BuildHasher>(
317314

318315
if let Some(parent) = current_path.parent() {
319316
for p in possibilities.iter() {
320-
if p.starts_with(&parent) && current_path != p {
317+
if p.starts_with(parent) && current_path != p {
321318
new_possibilities.push(p.clone());
322319
}
323320
}

tree-sitter-ccomment/bindings/rust/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
let src_dir = Path::new("src");
77

88
let mut c_config = cc::Build::new();
9-
c_config.include(&src_dir);
9+
c_config.include(src_dir);
1010
c_config
1111
.flag_if_supported("-Wno-unused-parameter")
1212
.flag_if_supported("-Wno-unused-but-set-variable")
@@ -18,7 +18,7 @@ fn main() {
1818

1919
let mut cpp_config = cc::Build::new();
2020
cpp_config.cpp(true);
21-
cpp_config.include(&src_dir);
21+
cpp_config.include(src_dir);
2222
cpp_config
2323
.flag_if_supported("-Wno-unused-parameter")
2424
.flag_if_supported("-Wno-unused-but-set-variable");

tree-sitter-mozcpp/bindings/rust/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
let src_dir = Path::new("src");
77

88
let mut c_config = cc::Build::new();
9-
c_config.include(&src_dir);
9+
c_config.include(src_dir);
1010
c_config
1111
.flag_if_supported("-Wno-unused-parameter")
1212
.flag_if_supported("-Wno-unused-but-set-variable")
@@ -18,7 +18,7 @@ fn main() {
1818

1919
let mut cpp_config = cc::Build::new();
2020
cpp_config.cpp(true);
21-
cpp_config.include(&src_dir);
21+
cpp_config.include(src_dir);
2222
cpp_config
2323
.flag_if_supported("-Wno-unused-parameter")
2424
.flag_if_supported("-Wno-unused-but-set-variable");

tree-sitter-mozjs/bindings/rust/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
let src_dir = Path::new("src");
77

88
let mut c_config = cc::Build::new();
9-
c_config.include(&src_dir);
9+
c_config.include(src_dir);
1010
c_config
1111
.flag_if_supported("-Wno-unused-parameter")
1212
.flag_if_supported("-Wno-unused-but-set-variable")

tree-sitter-preproc/bindings/rust/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
let src_dir = Path::new("src");
77

88
let mut c_config = cc::Build::new();
9-
c_config.include(&src_dir);
9+
c_config.include(src_dir);
1010
c_config
1111
.flag_if_supported("-Wno-unused-parameter")
1212
.flag_if_supported("-Wno-unused-but-set-variable")
@@ -18,7 +18,7 @@ fn main() {
1818

1919
let mut cpp_config = cc::Build::new();
2020
cpp_config.cpp(true);
21-
cpp_config.include(&src_dir);
21+
cpp_config.include(src_dir);
2222
cpp_config
2323
.flag_if_supported("-Wno-unused-parameter")
2424
.flag_if_supported("-Wno-unused-but-set-variable");

0 commit comments

Comments
 (0)