Skip to content

Commit 326d900

Browse files
committed
Fix formatting + clippy
1 parent 559e8b5 commit 326d900

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

aws-lc-sys/builder/cc_builder.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub(crate) struct CcBuilder {
2727
output_lib_type: OutputLibType,
2828
}
2929

30-
use cc;
3130
use std::{env, fs};
3231

3332
pub(crate) struct Library {
@@ -83,28 +82,29 @@ impl Default for PlatformConfig {
8382
}
8483
}
8584

85+
#[allow(clippy::upper_case_acronyms)]
8686
pub(crate) enum BuildOption {
8787
STD(String),
8888
FLAG(String),
8989
DEFINE(String, String),
9090
INCLUDE(PathBuf),
9191
}
9292
impl BuildOption {
93-
fn std<T: ToString>(val: T) -> Self {
93+
fn std<T: ToString + ?Sized>(val: &T) -> Self {
9494
Self::STD(val.to_string())
9595
}
96-
fn flag<T: ToString>(val: T) -> Self {
96+
fn flag<T: ToString + ?Sized>(val: &T) -> Self {
9797
Self::FLAG(val.to_string())
9898
}
99-
fn flag_if_supported<T: ToString>(cc_build: &cc::Build, flag: T) -> Option<Self> {
99+
fn flag_if_supported<T: ToString + ?Sized>(cc_build: &cc::Build, flag: &T) -> Option<Self> {
100100
if let Ok(true) = cc_build.is_flag_supported(flag.to_string()) {
101101
Some(Self::FLAG(flag.to_string()))
102102
} else {
103103
None
104104
}
105105
}
106106

107-
fn define<K: ToString, V: ToString>(key: K, val: V) -> Self {
107+
fn define<K: ToString + ?Sized, V: ToString + ?Sized>(key: &K, val: &V) -> Self {
108108
Self::DEFINE(key.to_string(), val.to_string())
109109
}
110110

@@ -222,13 +222,13 @@ impl CcBuilder {
222222
let flag = format!("-ffile-prefix-map={}=", self.manifest_dir.display());
223223
if let Ok(true) = cc_build.is_flag_supported(&flag) {
224224
emit_warning(&format!("Using flag: {}", &flag));
225-
build_options.push(BuildOption::flag(flag));
225+
build_options.push(BuildOption::flag(&flag));
226226
} else {
227227
emit_warning("NOTICE: Build environment source paths might be visible in release binary.");
228228
let flag = format!("-fdebug-prefix-map={}=", self.manifest_dir.display());
229229
if let Ok(true) = cc_build.is_flag_supported(&flag) {
230230
emit_warning(&format!("Using flag: {}", &flag));
231-
build_options.push(BuildOption::flag(flag));
231+
build_options.push(BuildOption::flag(&flag));
232232
}
233233
}
234234
}
@@ -241,12 +241,11 @@ impl CcBuilder {
241241
// clang: error: overriding '-mmacosx-version-min=13.7' option with '--target=x86_64-apple-macosx14.2' [-Werror,-Woverriding-t-option]
242242
// ```
243243
if let Some(option) =
244-
BuildOption::flag_if_supported(&cc_build, "-Wno-overriding-t-option")
244+
BuildOption::flag_if_supported(cc_build, "-Wno-overriding-t-option")
245245
{
246246
build_options.push(option);
247247
}
248-
if let Some(option) =
249-
BuildOption::flag_if_supported(&cc_build, "-Wno-overriding-option")
248+
if let Some(option) = BuildOption::flag_if_supported(cc_build, "-Wno-overriding-option")
250249
{
251250
build_options.push(option);
252251
}

aws-lc-sys/builder/cmake_builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl CmakeBuilder {
162162
// https://github.com/rust-lang/cmake-rs/issues/240
163163
// This breaks build configurations that generate warnings when optimizations
164164
// are disabled.
165-
self.preserve_cflag_optimization_flags(&mut cmake_cfg);
165+
Self::preserve_cflag_optimization_flags(&mut cmake_cfg);
166166

167167
// Allow environment to specify CMake toolchain.
168168
let toolchain_var_name = format!("CMAKE_TOOLCHAIN_FILE_{}", target_underscored());
@@ -212,7 +212,7 @@ impl CmakeBuilder {
212212
cmake_cfg
213213
}
214214

215-
fn preserve_cflag_optimization_flags(&self, cmake_cfg: &mut cmake::Config) {
215+
fn preserve_cflag_optimization_flags(cmake_cfg: &mut cmake::Config) {
216216
if let Ok(cflags) = env::var("CFLAGS") {
217217
let split = cflags.split_whitespace();
218218
for arg in split {

0 commit comments

Comments
 (0)