Skip to content

Commit f846b13

Browse files
committed
Fix unrelated clippy warnings
1 parent f75b3b9 commit f846b13

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

src/lib.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ impl Config {
136136
"release" | "bench" => RustProfile::Release,
137137
unknown => {
138138
eprintln!(
139-
"Warning: unknown Rust profile={}; defaulting to a release build.",
140-
unknown
139+
"Warning: unknown Rust profile={unknown}; defaulting to a release build."
141140
);
142141
RustProfile::Release
143142
}
@@ -153,8 +152,7 @@ impl Config {
153152
RustProfile::Release => OptLevel::Release,
154153
};
155154
eprintln!(
156-
"Warning: unknown opt-level={}; defaulting to a {:?} build.",
157-
unknown, default_opt_level
155+
"Warning: unknown opt-level={unknown}; defaulting to a {default_opt_level:?} build."
158156
);
159157
default_opt_level
160158
}
@@ -164,7 +162,7 @@ impl Config {
164162
"false" => false,
165163
"true" => true,
166164
unknown => {
167-
eprintln!("Warning: unknown debug={}; defaulting to `true`.", unknown);
165+
eprintln!("Warning: unknown debug={unknown}; defaulting to `true`.");
168166
true
169167
}
170168
};
@@ -562,7 +560,7 @@ impl Config {
562560
let mut cmake_prefix_path = Vec::new();
563561
for dep in &self.deps {
564562
let dep = dep.to_uppercase().replace('-', "_");
565-
if let Some(root) = env::var_os(format!("DEP_{}_ROOT", dep)) {
563+
if let Some(root) = env::var_os(format!("DEP_{dep}_ROOT")) {
566564
cmake_prefix_path.push(PathBuf::from(root));
567565
}
568566
}
@@ -667,7 +665,7 @@ impl Config {
667665
}
668666
cmd.arg("-AWin32");
669667
} else {
670-
panic!("unsupported msvc target: {}", target);
668+
panic!("unsupported msvc target: {target}");
671669
}
672670
}
673671
} else if target.contains("apple") {
@@ -689,7 +687,7 @@ impl Config {
689687
} else if target.contains("arm64_32") {
690688
cmd.arg("-DCMAKE_OSX_ARCHITECTURES=arm64_32");
691689
} else {
692-
panic!("unsupported apple target: {}", target);
690+
panic!("unsupported apple target: {target}");
693691
}
694692
}
695693

@@ -756,8 +754,8 @@ impl Config {
756754
None => false,
757755
};
758756
let mut set_compiler = |kind: &str, compiler: &cc::Tool, extra: &OsString| {
759-
let flag_var = format!("CMAKE_{}_FLAGS", kind);
760-
let tool_var = format!("CMAKE_{}_COMPILER", kind);
757+
let flag_var = format!("CMAKE_{kind}_FLAGS");
758+
let tool_var = format!("CMAKE_{kind}_COMPILER");
761759
if !self.defined(&flag_var) {
762760
let mut flagsflag = OsString::from("-D");
763761
flagsflag.push(&flag_var);
@@ -781,7 +779,7 @@ impl Config {
781779
// Note that for other generators, though, this *overrides*
782780
// things like the optimization flags, which is bad.
783781
if generator.is_none() && msvc {
784-
let flag_var_alt = format!("CMAKE_{}_FLAGS_{}", kind, build_type_upcase);
782+
let flag_var_alt = format!("CMAKE_{kind}_FLAGS_{build_type_upcase}");
785783
if !self.defined(&flag_var_alt) {
786784
let mut flagsflag = OsString::from("-D");
787785
flagsflag.push(&flag_var_alt);
@@ -843,7 +841,7 @@ impl Config {
843841
}
844842

845843
if !self.defined("CMAKE_BUILD_TYPE") {
846-
cmd.arg(format!("-DCMAKE_BUILD_TYPE={}", profile));
844+
cmd.arg(format!("-DCMAKE_BUILD_TYPE={profile}"));
847845
}
848846

849847
if self.verbose_make {
@@ -968,7 +966,7 @@ impl Config {
968966
return val.clone();
969967
}
970968
let r = env::var_os(v);
971-
println!("{} = {:?}", v, r);
969+
println!("{v} = {r:?}");
972970
self.env_cache.insert(v.to_string(), r.clone());
973971
r
974972
}
@@ -983,9 +981,9 @@ impl Config {
983981

984982
let kind = if host == target { "HOST" } else { "TARGET" };
985983
let target_u = target.replace('-', "_");
986-
self.getenv_os(&format!("{}_{}", var_base, target))
987-
.or_else(|| self.getenv_os(&format!("{}_{}", var_base, target_u)))
988-
.or_else(|| self.getenv_os(&format!("{}_{}", kind, var_base)))
984+
self.getenv_os(&format!("{var_base}_{target}"))
985+
.or_else(|| self.getenv_os(&format!("{var_base}_{target_u}")))
986+
.or_else(|| self.getenv_os(&format!("{kind}_{var_base}")))
989987
.or_else(|| self.getenv_os(var_base))
990988
}
991989

@@ -1013,7 +1011,7 @@ impl Config {
10131011
{
10141012
base.to_string()
10151013
} else {
1016-
panic!("unsupported msvc target: {}", target);
1014+
panic!("unsupported msvc target: {target}");
10171015
}
10181016
}
10191017

@@ -1114,27 +1112,24 @@ impl Default for Version {
11141112
}
11151113

11161114
fn run(cmd: &mut Command, program: &str) {
1117-
println!("running: {:?}", cmd);
1115+
println!("running: {cmd:?}");
11181116
let status = match cmd.status() {
11191117
Ok(status) => status,
11201118
Err(ref e) if e.kind() == ErrorKind::NotFound => {
11211119
fail(&format!(
1122-
"failed to execute command: {}\nis `{}` not installed?",
1123-
e, program
1120+
"failed to execute command: {e}\nis `{program}` not installed?"
11241121
));
11251122
}
1126-
Err(e) => fail(&format!("failed to execute command: {}", e)),
1123+
Err(e) => fail(&format!("failed to execute command: {e}")),
11271124
};
11281125
if !status.success() {
11291126
if status.code() == Some(127) {
11301127
fail(&format!(
1131-
"command did not execute successfully, got: {}, is `{}` not installed?",
1132-
status, program
1128+
"command did not execute successfully, got: {status}, is `{program}` not installed?"
11331129
));
11341130
}
11351131
fail(&format!(
1136-
"command did not execute successfully, got: {}",
1137-
status
1132+
"command did not execute successfully, got: {status}"
11381133
));
11391134
}
11401135
}
@@ -1149,12 +1144,12 @@ fn find_exe(path: &Path) -> PathBuf {
11491144
fn getenv_unwrap(v: &str) -> String {
11501145
match env::var(v) {
11511146
Ok(s) => s,
1152-
Err(..) => fail(&format!("environment variable `{}` not defined", v)),
1147+
Err(..) => fail(&format!("environment variable `{v}` not defined")),
11531148
}
11541149
}
11551150

11561151
fn fail(s: &str) -> ! {
1157-
panic!("\n{}\n\nbuild script failed, must exit now", s)
1152+
panic!("\n{s}\n\nbuild script failed, must exit now")
11581153
}
11591154

11601155
/// Returns whether the given MAKEFLAGS indicate that there is an available

0 commit comments

Comments
 (0)