Skip to content

Commit 4ab9c06

Browse files
committed
Make recent versions of clippy happy
1 parent 5f2b5c8 commit 4ab9c06

13 files changed

Lines changed: 33 additions & 43 deletions

File tree

src/compiler/c.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ where
275275
.map(|f| f.path())
276276
.collect()
277277
})
278-
.unwrap_or(Vec::default())
278+
.unwrap_or_default()
279279
}
280280
}
281281

@@ -485,16 +485,14 @@ where
485485
debug!("removing files {:?}", &outputs);
486486

487487
let v: std::result::Result<(), std::io::Error> =
488-
outputs.values().fold(Ok(()), |r, output| {
489-
r.and_then(|_| {
490-
let mut path = args_cwd.clone();
491-
path.push(&output.path);
492-
match fs::metadata(&path) {
493-
// File exists, remove it.
494-
Ok(_) => fs::remove_file(&path),
495-
_ => Ok(()),
496-
}
497-
})
488+
outputs.values().try_for_each(|output| {
489+
let mut path = args_cwd.clone();
490+
path.push(&output.path);
491+
match fs::metadata(&path) {
492+
// File exists, remove it.
493+
Ok(_) => fs::remove_file(&path),
494+
_ => Ok(()),
495+
}
498496
});
499497
if v.is_err() {
500498
warn!("Could not remove files after preprocessing failed!");
@@ -624,7 +622,7 @@ const INCBIN_DIRECTIVE: &[u8] = b".incbin";
624622
fn process_preprocessed_file(
625623
input_file: &Path,
626624
cwd: &Path,
627-
bytes: &mut Vec<u8>,
625+
bytes: &mut [u8],
628626
included_files: &mut HashMap<PathBuf, String>,
629627
config: PreprocessorCacheModeConfig,
630628
time_of_compilation: std::time::SystemTime,

src/compiler/compiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ where
554554
Some(ref client) => client.rewrite_includes_only(),
555555
_ => false,
556556
};
557-
let mut path_transformer = dist::PathTransformer::default();
557+
let mut path_transformer = dist::PathTransformer::new();
558558
let (compile_cmd, dist_compile_cmd, cacheable) = compilation
559559
.generate_compile_commands(&mut path_transformer, rewrite_includes_only)
560560
.context("Failed to generate compile commands")?;
@@ -1875,7 +1875,7 @@ LLVM version: 6.0",
18751875
let runtime = single_threaded_runtime();
18761876
let pool = runtime.handle();
18771877
let output = "compiler_id=clang\ncompiler_version=\"16.0.0\"";
1878-
let arguments = vec![
1878+
let arguments = [
18791879
ovec!["-c", "foo.c", "-o", "foo.o", "-DHELLO"],
18801880
ovec!["-c", "foo.c", "-o", "foo.o", "-DHI"],
18811881
ovec!["-c", "foo.c", "-o", "foo.o"],

src/compiler/diab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ mod test {
773773
let compiler = &f.bins[0];
774774
// Compiler invocation.
775775
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
776-
let mut path_transformer = dist::PathTransformer::default();
776+
let mut path_transformer = dist::PathTransformer::new();
777777
let (command, _, cacheable) = generate_compile_commands(
778778
&mut path_transformer,
779779
compiler,

src/compiler/gcc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ mod test {
20352035
let compiler = &f.bins[0];
20362036
// Compiler invocation.
20372037
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
2038-
let mut path_transformer = dist::PathTransformer::default();
2038+
let mut path_transformer = dist::PathTransformer::new();
20392039
let (command, dist_command, cacheable) = generate_compile_commands(
20402040
&mut path_transformer,
20412041
compiler,
@@ -2065,7 +2065,7 @@ mod test {
20652065
};
20662066
let f = TestFixture::new();
20672067
let compiler = &f.bins[0];
2068-
let mut path_transformer = dist::PathTransformer::default();
2068+
let mut path_transformer = dist::PathTransformer::new();
20692069
let (command, _, _) = generate_compile_commands(
20702070
&mut path_transformer,
20712071
compiler,

src/compiler/msvc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,7 @@ mod test {
24502450
let compiler = &f.bins[0];
24512451
// Compiler invocation.
24522452
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
2453-
let mut path_transformer = dist::PathTransformer::default();
2453+
let mut path_transformer = dist::PathTransformer::new();
24542454
let (command, dist_command, cacheable) = generate_compile_commands(
24552455
&mut path_transformer,
24562456
compiler,
@@ -2478,7 +2478,7 @@ mod test {
24782478
};
24792479
let f = TestFixture::new();
24802480
let compiler = &f.bins[0];
2481-
let mut path_transformer = dist::PathTransformer::default();
2481+
let mut path_transformer = dist::PathTransformer::new();
24822482
let (command, _, _) = generate_compile_commands(
24832483
&mut path_transformer,
24842484
compiler,
@@ -2535,7 +2535,7 @@ mod test {
25352535
let compiler = &f.bins[0];
25362536
// Compiler invocation.
25372537
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
2538-
let mut path_transformer = dist::PathTransformer::default();
2538+
let mut path_transformer = dist::PathTransformer::new();
25392539
let (command, dist_command, cacheable) = generate_compile_commands(
25402540
&mut path_transformer,
25412541
compiler,

src/compiler/tasking_vx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ mod test {
712712
let compiler = &f.bins[0];
713713
// Compiler invocation.
714714
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
715-
let mut path_transformer = dist::PathTransformer::default();
715+
let mut path_transformer = dist::PathTransformer::new();
716716
let (command, _, cacheable) = generate_compile_commands(
717717
&mut path_transformer,
718718
compiler,
@@ -761,7 +761,7 @@ mod test {
761761
let compiler = &f.bins[0];
762762
// Compiler invocation.
763763
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
764-
let mut path_transformer = dist::PathTransformer::default();
764+
let mut path_transformer = dist::PathTransformer::new();
765765
let (command, _, cacheable) = generate_compile_commands(
766766
&mut path_transformer,
767767
compiler,

src/dist/http.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ mod common {
3535
pub trait ReqwestRequestBuilderExt: Sized {
3636
fn bincode<T: serde::Serialize + ?Sized>(self, bincode: &T) -> Result<Self>;
3737
fn bytes(self, bytes: Vec<u8>) -> Self;
38-
fn bearer_auth(self, token: String) -> Self;
3938
}
4039
impl ReqwestRequestBuilderExt for reqwest::blocking::RequestBuilder {
4140
fn bincode<T: serde::Serialize + ?Sized>(self, bincode: &T) -> Result<Self> {
@@ -51,9 +50,6 @@ mod common {
5150
.header(header::CONTENT_LENGTH, bytes.len())
5251
.body(bytes)
5352
}
54-
fn bearer_auth(self, token: String) -> Self {
55-
self.bearer_auth(token)
56-
}
5753
}
5854
impl ReqwestRequestBuilderExt for reqwest::RequestBuilder {
5955
fn bincode<T: serde::Serialize + ?Sized>(self, bincode: &T) -> Result<Self> {
@@ -69,9 +65,6 @@ mod common {
6965
.header(header::CONTENT_LENGTH, bytes.len())
7066
.body(bytes)
7167
}
72-
fn bearer_auth(self, token: String) -> Self {
73-
self.bearer_auth(token)
74-
}
7568
}
7669

7770
#[cfg(feature = "dist-client")]

src/dist/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ mod path_transform {
9292
}
9393
}
9494

95-
#[derive(Debug, Default)]
95+
#[derive(Debug)]
9696
pub struct PathTransformer {
9797
dist_to_local_path: HashMap<String, PathBuf>,
9898
}
@@ -269,10 +269,13 @@ mod path_transform {
269269
use std::iter;
270270
use std::path::{Path, PathBuf};
271271

272-
#[derive(Debug, Default)]
272+
#[derive(Debug)]
273273
pub struct PathTransformer;
274274

275275
impl PathTransformer {
276+
pub fn new() -> Self {
277+
PathTransformer
278+
}
276279
pub fn as_dist_abs(&mut self, p: &Path) -> Option<String> {
277280
if !p.is_absolute() {
278281
return None;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
#![deny(rust_2018_idioms)]
16-
#![allow(clippy::type_complexity, clippy::new_without_default)]
16+
#![allow(clippy::type_complexity, clippy::new_without_default, clippy::blocks_in_conditions)]
1717
#![recursion_limit = "256"]
1818

1919
#[macro_use]

src/lru_disk_cache/lru_cache.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,9 @@ impl<K: Eq + Hash, V, S: BuildHasher> LruCache<K, V, S, Count> {
285285
/// assert_eq!(cache.get_mut(&1), None);
286286
/// assert_eq!(cache.get_mut(&2), Some(&mut "c"));
287287
/// ```
288-
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
288+
pub fn get_mut<Q: Hash + Eq + ?Sized>(&mut self, k: &Q) -> Option<&mut V>
289289
where
290290
K: Borrow<Q>,
291-
Q: Hash + Eq,
292291
{
293292
self.map.get_refresh(k)
294293
}
@@ -367,18 +366,16 @@ impl<K: Eq + Hash, V, S: BuildHasher, M: CountableMeter<K, V>> LruCache<K, V, S,
367366
/// cache.insert(1, "a");
368367
/// assert!(cache.contains_key(&1));
369368
/// ```
370-
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
369+
pub fn contains_key<Q: Hash + Eq + ?Sized>(&self, key: &Q) -> bool
371370
where
372371
K: Borrow<Q>,
373-
Q: Hash + Eq,
374372
{
375373
self.map.contains_key(key)
376374
}
377375

378-
pub fn get<Q: ?Sized>(&mut self, k: &Q) -> Option<&V>
376+
pub fn get<Q: Hash + Eq + ?Sized>(&mut self, k: &Q) -> Option<&V>
379377
where
380378
K: Borrow<Q>,
381-
Q: Hash + Eq,
382379
{
383380
self.map.get_refresh(k).map(|v| v as &V)
384381
}
@@ -429,10 +426,9 @@ impl<K: Eq + Hash, V, S: BuildHasher, M: CountableMeter<K, V>> LruCache<K, V, S,
429426
/// assert_eq!(cache.remove(&2), None);
430427
/// assert_eq!(cache.len(), 0);
431428
/// ```
432-
pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
429+
pub fn remove<Q: Hash + Eq + ?Sized>(&mut self, k: &Q) -> Option<V>
433430
where
434431
K: Borrow<Q>,
435-
Q: Hash + Eq,
436432
{
437433
self.map.remove(k).map(|v| {
438434
self.current_measure = self

0 commit comments

Comments
 (0)