Skip to content

Commit 30d8f1d

Browse files
committed
fix clippy warnings
1 parent 9d87eb6 commit 30d8f1d

File tree

55 files changed

+245
-303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+245
-303
lines changed

tools/bottlerocket-variant/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl Variant {
157157
/// This can be used in a `build.rs` file to tell cargo that the crate needs to be rebuilt if
158158
/// the variant changes.
159159
pub fn rerun_if_changed() {
160-
println!("cargo:rerun-if-env-changed={}", VARIANT_ENV);
160+
println!("cargo:rerun-if-env-changed={VARIANT_ENV}");
161161
}
162162

163163
/// This can be used in a `build.rs` file to emit `cfg` values that can be used for conditional
@@ -177,7 +177,7 @@ impl Variant {
177177
/// `#[cfg(variant_flavor = "none")]`
178178
pub fn emit_cfgs(&self) {
179179
Self::rerun_if_changed();
180-
println!("cargo:rustc-cfg=variant=\"{}\"", self);
180+
println!("cargo:rustc-cfg=variant=\"{self}\"");
181181
println!("cargo:rustc-cfg=variant_platform=\"{}\"", self.platform());
182182
println!("cargo:rustc-cfg=variant_runtime=\"{}\"", self.runtime());
183183
println!("cargo:rustc-cfg=variant_family=\"{}\"", self.family());
@@ -222,7 +222,7 @@ impl Variant {
222222
variant: variant.clone()
223223
}
224224
);
225-
let variant_family = format!("{}-{}", platform, runtime);
225+
let variant_family = format!("{platform}-{runtime}");
226226
let variant_version = parts.next().map(|s| s.to_string());
227227
if let Some(value) = variant_version.as_ref() {
228228
ensure!(
@@ -293,7 +293,7 @@ impl<'de> Deserialize<'de> for Variant {
293293
D: Deserializer<'de>,
294294
{
295295
let value = String::deserialize(deserializer)?;
296-
Variant::new(value).map_err(|e| D::Error::custom(format!("Error parsing variant: {}", e)))
296+
Variant::new(value).map_err(|e| D::Error::custom(format!("Error parsing variant: {e}")))
297297
}
298298
}
299299

tools/buildsys/src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn sensitive_env_vars(build_type: BuildFlags) -> impl Iterator<Item = &'static s
206206
pub(crate) fn rerun_for_envs(build_type: BuildType) {
207207
let build_flags: BuildFlags = build_type.into();
208208
for var in sensitive_env_vars(build_flags) {
209-
println!("cargo:rerun-if-env-changed={}", var)
209+
println!("cargo:rerun-if-env-changed={var}")
210210
}
211211
}
212212

tools/buildsys/src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl VariantBuildArgs {
262262
args.build_arg("VERSION_ID", &self.version_image);
263263

264264
for image_feature in self.image_features.iter() {
265-
args.build_arg(format!("{}", image_feature), "1");
265+
args.build_arg(format!("{image_feature}"), "1");
266266
}
267267

268268
args
@@ -303,7 +303,7 @@ impl RepackVariantBuildArgs {
303303
args.build_arg("VERSION_ID", &self.version_image);
304304

305305
for image_feature in self.image_features.iter() {
306-
args.build_arg(format!("{}", image_feature), "1");
306+
args.build_arg(format!("{image_feature}"), "1");
307307
}
308308

309309
args

tools/buildsys/src/cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ impl LookasideCache {
6363
match Self::verify_file(path, hash) {
6464
Ok(_) => continue,
6565
Err(e) => {
66-
println!("{}", e);
66+
println!("{e}");
6767
fs::remove_file(path).context(error::ExternalFileDeleteSnafu { path })?;
6868
}
6969
}
7070
}
7171

7272
let name = &path.display().to_string();
73-
let tmp = PathBuf::from(format!(".{}", name));
73+
let tmp = PathBuf::from(format!(".{name}"));
7474

7575
// first check the lookaside cache
7676
let mut url = self.lookaside_cache.clone();
@@ -93,7 +93,7 @@ impl LookasideCache {
9393
Err(e) => {
9494
// next check with upstream, if permitted
9595
if f.force_upstream.unwrap_or(false) || self.upstream_fallback {
96-
println!("Source not found in lookaside-cache. Fetching {:?} from upstream source", url_file_name);
96+
println!("Source not found in lookaside-cache. Fetching {url_file_name:?} from upstream source");
9797
self.fetch_file(&f.url, &tmp, hash)?;
9898
fs::rename(&tmp, path)
9999
.context(error::ExternalFileRenameSnafu { path: &tmp })?;

tools/buildsys/src/gomod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl GoMod {
117117
module_path: package_dir,
118118
sdk_image: sdk.to_string(),
119119
go_mod_cache: &root_dir.join(".gomodcache"),
120-
command: format!("./{}", GO_MOD_DOCKER_SCRIPT_NAME),
120+
command: format!("./{GO_MOD_DOCKER_SCRIPT_NAME}"),
121121
};
122122

123123
// Create and/or write the temporary script file to the package directory

tools/buildsys/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ type Result<T> = std::result::Result<T, error::Error>;
101101
fn main() {
102102
let args = Buildsys::parse();
103103
if let Err(e) = run(args) {
104-
eprintln!("{}", e);
104+
eprintln!("{e}");
105105
process::exit(1);
106106
}
107107
}
@@ -119,7 +119,7 @@ fn run(args: Buildsys) -> Result<()> {
119119
fn build_package(args: BuildPackageArgs) -> Result<()> {
120120
let manifest_file = "Cargo.toml";
121121
let manifest_path = args.common.cargo_manifest_dir.join(manifest_file);
122-
println!("cargo:rerun-if-changed={}", manifest_file);
122+
println!("cargo:rerun-if-changed={manifest_file}");
123123
println!(
124124
"cargo:rerun-if-changed={}",
125125
args.common.root_dir.join(EXTERNAL_KIT_METADATA).display()
@@ -184,8 +184,8 @@ fn build_package(args: BuildPackageArgs) -> Result<()> {
184184
// Package developer can override name of package if desired, e.g. to name package with
185185
// characters invalid in Cargo crate names
186186
let package = manifest.info().package_name();
187-
let spec = format!("{}.spec", package);
188-
println!("cargo:rerun-if-changed={}", spec);
187+
let spec = format!("{package}.spec");
188+
println!("cargo:rerun-if-changed={spec}");
189189

190190
let info = SpecInfo::new(PathBuf::from(&spec)).context(error::SpecParseSnafu)?;
191191

@@ -209,7 +209,7 @@ fn build_package(args: BuildPackageArgs) -> Result<()> {
209209

210210
fn build_kit(args: BuildKitArgs) -> Result<()> {
211211
let manifest_file = "Cargo.toml";
212-
println!("cargo:rerun-if-changed={}", manifest_file);
212+
println!("cargo:rerun-if-changed={manifest_file}");
213213
println!(
214214
"cargo:rerun-if-changed={}",
215215
args.common.root_dir.join(EXTERNAL_KIT_METADATA).display()
@@ -233,7 +233,7 @@ fn build_kit(args: BuildKitArgs) -> Result<()> {
233233

234234
fn build_variant(args: BuildVariantArgs) -> Result<()> {
235235
let manifest_file = "Cargo.toml";
236-
println!("cargo:rerun-if-changed={}", manifest_file);
236+
println!("cargo:rerun-if-changed={manifest_file}");
237237
println!(
238238
"cargo:rerun-if-changed={}",
239239
args.common.root_dir.join(EXTERNAL_KIT_METADATA).display()

tools/include-env-compressed/include-env-compressed-macro/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ trait IncludedArchive {
9494
impl IncludedArchive for MacroArgs<Zstd> {
9595
fn emit_archive(&self) -> Result<TokenStream, IncludeError> {
9696
let env_var = &self.env_var;
97-
let path = std::env::var(&env_var).context(EnvVarSnafu { env_var })?;
97+
let path = std::env::var(env_var).context(EnvVarSnafu { env_var })?;
9898

9999
let data = std::fs::read(&path).context(ReadArchiveSnafu { path })?;
100100

101101
let compressed = zstd::encode_all(data.as_slice(), self.level).unwrap();
102102
let literal = Literal::byte_string(&compressed);
103103

104-
Ok(TokenStream::from(quote! {
104+
Ok(quote! {
105105
::include_env_compressed::Archive::zstd(#literal)
106-
}))
106+
})
107107
}
108108
}
109109

@@ -131,9 +131,9 @@ impl<Compression> Parse for MacroArgs<Compression> {
131131
impl IncludedArchive for MacroArgs<Uncompressed> {
132132
fn emit_archive(&self) -> Result<TokenStream, IncludeError> {
133133
let env_var = &self.env_var;
134-
Ok(TokenStream::from(quote! {
134+
Ok(quote! {
135135
::include_env_compressed::Archive::uncompressed(include_bytes!(env!(#env_var)))
136-
}))
136+
})
137137
}
138138
}
139139

tools/krane/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn get_goos() -> &'static str {
9898
"windows" => "windows",
9999
"macos" => "darwin",
100100
// Add more mappings as needed
101-
other => panic!("Unsupported target OS: {}", other),
101+
other => panic!("Unsupported target OS: {other}"),
102102
}
103103
}
104104

@@ -112,6 +112,6 @@ fn get_goarch() -> &'static str {
112112
"arm" => "arm",
113113
"wasm32" => "wasm",
114114
// Add more mappings as needed
115-
other => panic!("Unsupported target architecture: {}", other),
115+
other => panic!("Unsupported target architecture: {other}"),
116116
}
117117
}

tools/oci-cli-wrapper/src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl CommandLine {
1414
let debug_cmd = [
1515
vec![format!("{}", self.path.display())],
1616
args.iter()
17-
.map(|arg| format!("'{}'", arg))
17+
.map(|arg| format!("'{arg}'"))
1818
.collect::<Vec<_>>(),
1919
]
2020
.concat()
@@ -58,7 +58,7 @@ impl CommandLine {
5858
"Executing '{}' with args [{}]",
5959
self.path.display(),
6060
args.iter()
61-
.map(|arg| format!("'{}'", arg))
61+
.map(|arg| format!("'{arg}'"))
6262
.collect::<Vec<_>>()
6363
.join(", ")
6464
);

tools/oci-cli-wrapper/src/crane.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ImageToolImpl for CraneCLI {
3333
self.cli
3434
.spawn(
3535
&Self::crane_cmd(&["pull", "--format", "oci", uri, archive_path.as_ref()]),
36-
format!("failed to pull image archive from {}", uri),
36+
format!("failed to pull image archive from {uri}"),
3737
)
3838
.await?;
3939
Ok(())
@@ -43,7 +43,7 @@ impl ImageToolImpl for CraneCLI {
4343
self.cli
4444
.output(
4545
&Self::crane_cmd(&["manifest", uri]),
46-
format!("failed to fetch manifest for resource at {}", uri),
46+
format!("failed to fetch manifest for resource at {uri}"),
4747
)
4848
.await
4949
}
@@ -53,7 +53,7 @@ impl ImageToolImpl for CraneCLI {
5353
.cli
5454
.output(
5555
&Self::crane_cmd(&["config", uri]),
56-
format!("failed to fetch image config from {}", uri),
56+
format!("failed to fetch image config from {uri}"),
5757
)
5858
.await?;
5959
let image_view: ImageView =
@@ -73,7 +73,7 @@ impl ImageToolImpl for CraneCLI {
7373
self.cli
7474
.spawn(
7575
&Self::crane_cmd(&["push", &temp_dir.path().to_string_lossy(), uri]),
76-
format!("failed to push image {}", uri),
76+
format!("failed to push image {uri}"),
7777
)
7878
.await
7979
}
@@ -96,7 +96,7 @@ impl ImageToolImpl for CraneCLI {
9696
self.cli
9797
.output(
9898
&Self::crane_cmd(&manifest_create_args),
99-
format!("could not push multi-platform manifest to {}", uri),
99+
format!("could not push multi-platform manifest to {uri}"),
100100
)
101101
.await?;
102102

0 commit comments

Comments
 (0)