new clippies (#352)

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
xermicus
2025-06-28 11:48:24 +02:00
committed by GitHub
parent 7656c6a8b4
commit 486c9c28a1
19 changed files with 37 additions and 42 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ impl std::str::FromStr for BuildType {
"Release" => Ok(Self::Release),
"RelWithDebInfo" => Ok(Self::RelWithDebInfo),
"MinSizeRel" => Ok(Self::MinSizeRel),
value => Err(format!("Unsupported build type: `{}`", value)),
value => Err(format!("Unsupported build type: `{value}`")),
}
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ impl std::str::FromStr for CcacheVariant {
match value {
"ccache" => Ok(Self::Ccache),
"sccache" => Ok(Self::Sccache),
value => Err(format!("Unsupported ccache variant: `{}`", value)),
value => Err(format!("Unsupported ccache variant: `{value}`")),
}
}
}
+13 -14
View File
@@ -127,23 +127,22 @@ pub fn build(
sanitizer: Option<sanitizer::Sanitizer>,
enable_valgrind: bool,
) -> anyhow::Result<()> {
log::trace!("build type: {:?}", build_type);
log::trace!("target env: {:?}", target_env);
log::trace!("targets: {:?}", targets);
log::trace!("llvm projects: {:?}", llvm_projects);
log::trace!("enable rtti: {:?}", enable_rtti);
log::trace!("default target: {:?}", default_target);
log::trace!("eneable tests: {:?}", enable_tests);
log::trace!("enable_coverage: {:?}", enable_coverage);
log::trace!("extra args: {:?}", extra_args);
log::trace!("sanitzer: {:?}", sanitizer);
log::trace!("enable valgrind: {:?}", enable_valgrind);
log::trace!("build type: {build_type:?}");
log::trace!("target env: {target_env:?}");
log::trace!("targets: {targets:?}");
log::trace!("llvm projects: {llvm_projects:?}");
log::trace!("enable rtti: {enable_rtti:?}");
log::trace!("default target: {default_target:?}");
log::trace!("eneable tests: {enable_tests:?}");
log::trace!("enable_coverage: {enable_coverage:?}");
log::trace!("extra args: {extra_args:?}");
log::trace!("sanitzer: {sanitizer:?}");
log::trace!("enable valgrind: {enable_valgrind:?}");
if !PathBuf::from(LLVMPath::DIRECTORY_LLVM_SOURCE).exists() {
log::error!(
"LLVM project source directory {} does not exist (run `revive-llvm --target-env {} clone`)",
LLVMPath::DIRECTORY_LLVM_SOURCE,
target_env
"LLVM project source directory {} does not exist (run `revive-llvm --target-env {target_env} clone`)",
LLVMPath::DIRECTORY_LLVM_SOURCE
)
}
+1 -1
View File
@@ -22,7 +22,7 @@ impl std::str::FromStr for LLVMProject {
"lld" => Ok(Self::LLD),
"lldb" => Ok(Self::LLDB),
"mlir" => Ok(Self::MLIR),
value => Err(format!("Unsupported LLVM project to enable: `{}`", value)),
value => Err(format!("Unsupported LLVM project to enable: `{value}`")),
}
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ impl TryFrom<&PathBuf> for Lock {
fn try_from(path: &PathBuf) -> Result<Self, Self::Error> {
let mut config_str = String::new();
let mut config_file =
File::open(path).with_context(|| format!("Error opening {:?} file", path))?;
File::open(path).with_context(|| format!("Error opening {path:?} file"))?;
config_file.read_to_string(&mut config_str)?;
Ok(toml::from_str(&config_str)?)
}
+1 -1
View File
@@ -29,7 +29,7 @@ impl FromStr for Platform {
fn from_str(value: &str) -> Result<Self, Self::Err> {
match value {
"PolkaVM" => Ok(Self::PolkaVM),
value => Err(format!("Unsupported platform: `{}`", value)),
value => Err(format!("Unsupported platform: `{value}`")),
}
}
}
+2 -2
View File
@@ -69,8 +69,8 @@ fn main_inner() -> anyhow::Result<()> {
})
.collect();
log::debug!("extra_args: {:#?}", extra_args);
log::debug!("extra_args_unescaped: {:#?}", extra_args_unescaped);
log::debug!("extra_args: {extra_args:#?}");
log::debug!("extra_args_unescaped: {extra_args_unescaped:#?}");
if let Some(ccache_variant) = ccache_variant {
revive_llvm_builder::utils::check_presence(ccache_variant.to_string().as_str())?;
+1 -1
View File
@@ -30,7 +30,7 @@ impl std::str::FromStr for Sanitizer {
"thread" => Ok(Self::Thread),
"dataflow" => Ok(Self::DataFlow),
"address;undefined" => Ok(Self::AddressUndefined),
value => Err(format!("Unsupported sanitizer: `{}`", value)),
value => Err(format!("Unsupported sanitizer: `{value}`")),
}
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ impl std::str::FromStr for TargetEnv {
"gnu" => Ok(Self::GNU),
"musl" => Ok(Self::MUSL),
"emscripten" => Ok(Self::Emscripten),
value => Err(format!("Unsupported target environment: `{}`", value)),
value => Err(format!("Unsupported target environment: `{value}`")),
}
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ impl std::str::FromStr for TargetTriple {
fn from_str(value: &str) -> Result<Self, Self::Err> {
match value {
"polkavm" => Ok(Self::PolkaVM),
value => Err(format!("Unsupported target triple: `{}`", value)),
value => Err(format!("Unsupported target triple: `{value}`")),
}
}
}
+2 -2
View File
@@ -92,7 +92,7 @@ pub fn unpack_tar(filename: PathBuf, path: &str) -> anyhow::Result<()> {
pub fn download_musl(name: &str) -> anyhow::Result<()> {
log::info!("downloading musl {name}");
let tar_file_name = format!("{name}.tar.gz");
let url = format!("{}/{tar_file_name}", MUSL_SNAPSHOTS_URL);
let url = format!("{MUSL_SNAPSHOTS_URL}/{tar_file_name}");
let target_path = crate::llvm_path::DIRECTORY_LLVM_TARGET
.get()
.unwrap()
@@ -223,6 +223,6 @@ pub fn install_emsdk() -> anyhow::Result<()> {
/// The LLVM target directory default path.
pub fn directory_target_llvm(target_env: crate::target_env::TargetEnv) -> PathBuf {
crate::llvm_path::DIRECTORY_LLVM_TARGET
.get_or_init(|| PathBuf::from(format!("./target-llvm/{}/", target_env)))
.get_or_init(|| PathBuf::from(format!("./target-llvm/{target_env}/")))
.clone()
}
+1 -1
View File
@@ -37,7 +37,7 @@ pub fn build_assembly_text(
let mut disassembled_code = Vec::new();
disassembler
.disassemble_into(&mut disassembled_code)
.with_context(|| format!("Failed to disassemble contract: {}", contract_path))?;
.with_context(|| format!("Failed to disassemble contract: {contract_path}"))?;
let assembly_text = String::from_utf8(disassembled_code).with_context(|| {
format!("Failed to convert disassembled code to string for contract: {contract_path}")
+2 -2
View File
@@ -155,8 +155,8 @@ impl Project {
.iter()
.flat_map(|(file, names)| {
names
.iter()
.map(|(name, _address)| format!("{file}:{name}"))
.keys()
.map(|name| format!("{file}:{name}"))
.collect::<HashSet<String>>()
})
.collect::<HashSet<String>>();
+1 -3
View File
@@ -240,9 +240,7 @@ fn main_inner() -> anyhow::Result<()> {
writeln!(
std::io::stdout(),
"Contract `{}` assembly:\n\n{}",
path,
assembly_text
"Contract `{path}` assembly:\n\n{assembly_text}"
)?;
}
if arguments.output_binary {
+1 -1
View File
@@ -361,7 +361,7 @@ fn compile_evm(
.expect("source should compile");
let object = &contracts
.get(contract_name)
.unwrap_or_else(|| panic!("contract '{}' didn't produce bin-runtime", contract_name));
.unwrap_or_else(|| panic!("contract '{contract_name}' didn't produce bin-runtime"));
let code = if runtime {
object.1.object.as_str()
} else {
+2 -2
View File
@@ -121,10 +121,10 @@ fn optimizer() {
assert!(
size_when_optimized_for_cycles < size_when_unoptimized,
"Expected the cycles-optimized bytecode to be smaller than the unoptimized. Optimized: {}B, Unoptimized: {}B", size_when_optimized_for_cycles, size_when_unoptimized,
"Expected the cycles-optimized bytecode to be smaller than the unoptimized. Optimized: {size_when_optimized_for_cycles}B, Unoptimized: {size_when_unoptimized}B",
);
assert!(
size_when_optimized_for_size < size_when_unoptimized,
"Expected the size-optimized bytecode to be smaller than the unoptimized. Optimized: {}B, Unoptimized: {}B", size_when_optimized_for_size, size_when_unoptimized,
"Expected the size-optimized bytecode to be smaller than the unoptimized. Optimized: {size_when_optimized_for_size}B, Unoptimized: {size_when_unoptimized}B",
);
}
+2 -3
View File
@@ -37,12 +37,11 @@ fn compile(source_path: &str, bitcode_path: &str) {
source_path,
])
.output()
.unwrap_or_else(|error| panic!("failed to execute clang: {}", error));
.unwrap_or_else(|error| panic!("failed to execute clang: {error}"));
assert!(
output.status.success(),
"failed to compile the PolkaVM C API: {:?}",
output
"failed to compile the PolkaVM C API: {output:?}"
);
}
+2 -3
View File
@@ -17,12 +17,11 @@ fn main() {
"stdlib.ll",
])
.output()
.unwrap_or_else(|error| panic!("failed to execute llvm-as: {}", error));
.unwrap_or_else(|error| panic!("failed to execute llvm-as: {error}"));
assert!(
output.status.success(),
"failed to assemble the stdlib: {:?}",
output
"failed to assemble the stdlib: {output:?}"
);
let bitcode = fs::read(bitcode_path).expect("bitcode should have been built");
@@ -167,7 +167,7 @@ impl Literal {
unicode_char.encode_utf8(&mut unicode_bytes);
for byte in unicode_bytes.into_iter() {
hex_string.push_str(format!("{:02x}", byte).as_str());
hex_string.push_str(format!("{byte:02x}").as_str());
}
index += 5;
} else if string[index..].starts_with('t') {