Skip to content

Commit 79871bd

Browse files
authored
Merge pull request #555 from cbgbt/with-hints
cargo: enable profile-hint-mostly-unused for AWS SDKs
2 parents 3bc08f3 + 30d8f1d commit 79871bd

File tree

58 files changed

+267
-304
lines changed

Some content is hidden

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

58 files changed

+267
-304
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[unstable]
22
bindeps = true
3+
profile-hint-mostly-unused = true
34

45
[build]
56
# This is the recommended configuration that yields the

Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,26 @@ walkdir = "2"
176176
which = "6"
177177
zstd = "0.13"
178178

179+
[profile.dev.package]
180+
aws-config = { hint-mostly-unused = true }
181+
aws-sdk-ebs = { hint-mostly-unused = true }
182+
aws-sdk-ec2 = { hint-mostly-unused = true }
183+
aws-sdk-kms = { hint-mostly-unused = true }
184+
aws-sdk-ssm = { hint-mostly-unused = true }
185+
aws-sdk-sts = { hint-mostly-unused = true }
186+
aws-smithy-types = { hint-mostly-unused = true }
187+
aws-types = { hint-mostly-unused = true }
188+
189+
[profile.release.package]
190+
aws-config = { hint-mostly-unused = true }
191+
aws-sdk-ebs = { hint-mostly-unused = true }
192+
aws-sdk-ec2 = { hint-mostly-unused = true }
193+
aws-sdk-kms = { hint-mostly-unused = true }
194+
aws-sdk-ssm = { hint-mostly-unused = true }
195+
aws-sdk-sts = { hint-mostly-unused = true }
196+
aws-smithy-types = { hint-mostly-unused = true }
197+
aws-types = { hint-mostly-unused = true }
198+
179199
# The profile that 'cargo dist' will build with
180200
[profile.dist]
181201
inherits = "release"

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# particular date of the nightly compiler, but we want builds to be reproducable, so we lock to a
33
# specific, recent instance of nightly.
44
[toolchain]
5-
channel = "nightly-2025-02-28"
5+
channel = "nightly-2025-07-15"
66
profile = "default"

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

0 commit comments

Comments
 (0)