Skip to content

Commit 05c6db5

Browse files
authored
Fix Clippy warnings (#2490)
1 parent 06d27d4 commit 05c6db5

File tree

19 files changed

+81
-86
lines changed

19 files changed

+81
-86
lines changed

src/cache/cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ impl Storage for opendal::Operator {
507507
// can do, so we will print our the error here to make users know
508508
// about it.
509509
Err(err) if err.kind() == ErrorKind::RateLimited => {
510-
eprintln!("cache storage read check: {err:?}, but we decide to keep running")
510+
eprintln!("cache storage read check: {err:?}, but we decide to keep running");
511511
}
512512
Err(err) => bail!("cache storage failed to read: {:?}", err),
513-
};
513+
}
514514

515515
let can_write = match self.write(path, "Hello, World!").await {
516516
Ok(_) => true,

src/cmdline.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ use which::which_in;
2222

2323
const ENV_VAR_INTERNAL_START_SERVER: &str = "SCCACHE_START_SERVER";
2424

25-
#[derive(Debug, Clone, ValueEnum)]
25+
#[derive(Debug, Clone, ValueEnum, Default)]
2626
pub enum StatsFormat {
27+
#[default]
2728
Text,
2829
Json,
2930
}
@@ -49,12 +50,6 @@ impl FromStr for StatsFormat {
4950
}
5051
}
5152

52-
impl Default for StatsFormat {
53-
fn default() -> Self {
54-
Self::Text
55-
}
56-
}
57-
5853
/// A specific command to run.
5954
pub enum Command {
6055
/// Show cache statistics and exit.

src/commands.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn connect_or_start_server(
322322
}
323323
}
324324
ServerStartup::AddrInUse => {
325-
debug!("AddrInUse: possible parallel server bootstraps, retrying..")
325+
debug!("AddrInUse: possible parallel server bootstraps, retrying..");
326326
}
327327
ServerStartup::TimedOut => bail!(
328328
"Timed out waiting for server startup. Maybe the remote service is unreachable?\nRun with SCCACHE_LOG=debug SCCACHE_NO_DAEMON=1 to get more information"
@@ -558,7 +558,7 @@ where
558558
CompileResponse::UnhandledCompile => {
559559
debug!("Server sent UnhandledCompile");
560560
}
561-
};
561+
}
562562

563563
let mut cmd = creator.new_command_sync(exe);
564564
cmd.args(&cmdline).current_dir(cwd);
@@ -703,7 +703,7 @@ pub fn run_command(cmd: Command) -> Result<i32> {
703703

704704
match &config.dist.auth {
705705
config::DistAuth::Token { .. } => {
706-
info!("No authentication needed for type 'token'")
706+
info!("No authentication needed for type 'token'");
707707
}
708708
config::DistAuth::Oauth2CodeGrantPKCE {
709709
client_id,
@@ -725,7 +725,7 @@ pub fn run_command(cmd: Command) -> Result<i32> {
725725
c.dist.auth_tokens.insert(auth_url.to_owned(), token);
726726
})
727727
.context("Unable to save auth token")?;
728-
println!("Saved token")
728+
println!("Saved token");
729729
}
730730
config::DistAuth::Oauth2Implicit {
731731
client_id,
@@ -743,9 +743,9 @@ pub fn run_command(cmd: Command) -> Result<i32> {
743743
c.dist.auth_tokens.insert(auth_url.to_owned(), token);
744744
})
745745
.context("Unable to save auth token")?;
746-
println!("Saved token")
746+
println!("Saved token");
747747
}
748-
};
748+
}
749749
}
750750
#[cfg(not(feature = "dist-client"))]
751751
Command::DistAuth => bail!(
@@ -777,7 +777,7 @@ pub fn run_command(cmd: Command) -> Result<i32> {
777777
.await
778778
.map(|compiler| compiler.0.get_toolchain_packager())
779779
.and_then(|packager| packager.write_pkg(out_file))
780-
})?
780+
})?;
781781
}
782782
#[cfg(not(feature = "dist-client"))]
783783
Command::PackageToolchain(_executable, _out) => bail!(

src/compiler/c.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<T: CommandCreatorSync, I: CCompilerImpl> Compiler<T> for CCompiler<I> {
320320
// Handle SCCACHE_EXTRAFILES
321321
for (k, v) in env_vars.iter() {
322322
if k.as_os_str() == OsStr::new("SCCACHE_EXTRAFILES") {
323-
args.extra_hash_files.extend(std::env::split_paths(&v))
323+
args.extra_hash_files.extend(std::env::split_paths(&v));
324324
}
325325
}
326326

@@ -337,7 +337,7 @@ impl<T: CommandCreatorSync, I: CCompilerImpl> Compiler<T> for CCompiler<I> {
337337
// too much to handle on our side so we just hash every bitcode library we find.
338338
if args.language == Language::Hip {
339339
args.extra_hash_files
340-
.extend(Self::search_hip_device_libs(&args, env_vars))
340+
.extend(Self::search_hip_device_libs(&args, env_vars));
341341
}
342342

343343
CompilerArguments::Ok(Box::new(CCompilerHasher {
@@ -758,7 +758,7 @@ fn process_preprocessed_file(
758758
hash_start = h;
759759
continue;
760760
}
761-
};
761+
}
762762
} else if slice
763763
.strip_prefix(INCBIN_DIRECTIVE)
764764
.filter(|slice| {
@@ -924,7 +924,7 @@ fn process_preprocessor_line(
924924
fs_impl,
925925
)? {
926926
return Ok(ControlFlow::Break((start, hash_start, false)));
927-
};
927+
}
928928
// Everything of interest between hash_start and start has been hashed now.
929929
hash_start = start;
930930
Ok(ControlFlow::Continue((start, hash_start)))

src/compiler/cicc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ where
196196
args.extend(arg.iter_os_strings());
197197
}
198198
_ => continue,
199-
};
199+
}
200200
}
201201

202202
if let Some(module_id_path) = module_id_file_name {

src/compiler/clang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl CCompilerImpl for Clang {
128128

129129
// Clang 14 and later support -fminimize-whitespace, which normalizes away non-semantic whitespace which in turn increases cache hit rate.
130130
if self.is_minversion(14) {
131-
ignorable_whitespace_flags.push("-fminimize-whitespace".to_string())
131+
ignorable_whitespace_flags.push("-fminimize-whitespace".to_string());
132132
}
133133

134134
gcc::preprocess(

src/compiler/gcc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ where
421421
)
422422
}
423423
_ => {}
424-
};
424+
}
425425
seen_arch = Some(arch.clone());
426426
}
427427
Some(XClang(s)) => xclangs.push(s.clone()),
@@ -566,7 +566,7 @@ where
566566
};
567567
for arg in arg.normalize(norm).iter_os_strings() {
568568
args.push("-Xclang".into());
569-
args.push(arg)
569+
args.push(arg);
570570
}
571571
}
572572

@@ -868,7 +868,7 @@ where
868868
let language = language_to_arg(parsed_args.language);
869869
let mut arguments: Vec<OsString> = vec![];
870870
if let Some(lang) = &language {
871-
arguments.extend(vec!["-x".into(), lang.into()])
871+
arguments.extend(vec!["-x".into(), lang.into()]);
872872
}
873873
arguments.extend(vec![
874874
parsed_args.compilation_flag.clone(),
@@ -927,7 +927,7 @@ where
927927
let mut arguments: Vec<String> = vec![];
928928
// Language needs to be before input
929929
if let Some(lang) = &language {
930-
arguments.extend(vec!["-x".into(), lang.into()])
930+
arguments.extend(vec!["-x".into(), lang.into()]);
931931
}
932932
arguments.extend(vec![
933933
parsed_args.compilation_flag.clone().into_string().ok()?,

src/compiler/msvc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ pub fn parse_arguments(
610610
common_args.extend(
611611
arg.normalize(NormalizedDisposition::Concatenated)
612612
.iter_os_strings(),
613-
)
613+
);
614614
}
615615
Some(ExternalIncludePath(_)) => common_args.extend(
616616
arg.normalize(NormalizedDisposition::Separated)

src/compiler/nvcc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn generate_compile_commands(
328328
keep = true;
329329
unhashed_args.splice(idx..(idx + 1), []);
330330
if keep_dir.is_none() {
331-
keep_dir = Some(cwd.to_path_buf())
331+
keep_dir = Some(cwd.to_path_buf());
332332
}
333333
continue;
334334
}
@@ -391,7 +391,7 @@ pub fn generate_compile_commands(
391391
let mut arguments = vec![];
392392

393393
if let Some(lang) = gcc::language_to_gcc_arg(parsed_args.language) {
394-
arguments.extend(vec!["-x".into(), lang.into()])
394+
arguments.extend(vec!["-x".into(), lang.into()]);
395395
}
396396

397397
let output = &parsed_args

src/compiler/preprocessor_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl PreprocessorCacheEntry {
163163
self.number_of_entries += includes.len();
164164
vacant.insert(includes);
165165
}
166-
};
166+
}
167167
debug!("Added result key {result_key} to preprocessor cache entry");
168168
}
169169
Err(e) => {
@@ -310,7 +310,7 @@ impl PreprocessorCacheEntry {
310310
// SOURCE_DATE_EPOCH and the current date since we can't be sure that the
311311
// compiler honors SOURCE_DATE_EPOCH.
312312
if let Ok(source_date_epoch) = std::env::var("SOURCE_DATE_EPOCH") {
313-
new_digest.update(source_date_epoch.as_bytes())
313+
new_digest.update(source_date_epoch.as_bytes());
314314
}
315315
}
316316

0 commit comments

Comments
 (0)