Skip to content

Commit 1087068

Browse files
authored
chore: bump to edition 2024 (#167)
1 parent 2f312f5 commit 1087068

File tree

6 files changed

+62
-65
lines changed

6 files changed

+62
-65
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resolver = "2"
44

55
[workspace.package]
66
version = "0.5.17"
7-
edition = "2021"
7+
edition = "2024"
88
rust-version = "1.89"
99
authors = [
1010
"Rohit Narurkar <[email protected]>",

crates/svm-rs/src/bin/solc/main.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,21 @@ fn main() {
2525

2626
fn main_() -> anyhow::Result<i32> {
2727
let mut args = std::env::args_os().skip(1).peekable();
28-
let version = 'v: {
29-
// Try to parse the first argument as a version specifier `+x.y.z`.
30-
if let Some(arg) = args.peek() {
31-
if let Some(arg) = arg.to_str() {
32-
if let Some(stripped) = arg.strip_prefix('+') {
33-
let version = stripped
34-
.parse::<semver::Version>()
35-
.context("failed to parse version specifier")?;
36-
if !version.build.is_empty() || !version.pre.is_empty() {
37-
anyhow::bail!(
38-
"version specifier must not have pre-release or build metadata"
39-
);
40-
}
41-
args.next();
42-
break 'v version;
43-
}
44-
}
28+
29+
// Try to parse the first argument as a version specifier `+x.y.z`.
30+
let version = if let Some(arg) = args.peek()
31+
&& let Some(arg) = arg.to_str()
32+
&& let Some(stripped) = arg.strip_prefix('+')
33+
{
34+
let version = stripped
35+
.parse::<semver::Version>()
36+
.context("failed to parse version specifier")?;
37+
if !version.build.is_empty() || !version.pre.is_empty() {
38+
anyhow::bail!("version specifier must not have pre-release or build metadata");
4539
}
40+
args.next();
41+
version
42+
} else {
4643
// Fallback to the global version if one is not specified.
4744
svm::get_global_version()?.ok_or(svm::SvmError::GlobalVersionNotSet)?
4845
};

crates/svm-rs/src/bin/svm-bin/remove.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,16 @@ impl RemoveCmd {
3131
.interact_text()?;
3232
if matches!(input.as_str(), "y" | "Y" | "yes" | "Yes") {
3333
svm::remove_version(&version)?;
34-
if let Some(v) = current_version {
35-
if version == v {
36-
if let Some(i) = installed_versions.iter().position(|x| *x == v) {
37-
installed_versions.remove(i);
38-
if let Some(new_version) = installed_versions.pop() {
39-
svm::set_global_version(&new_version)?;
40-
print::set_global_version(&new_version);
41-
} else {
42-
svm::unset_global_version()?;
43-
}
44-
}
34+
if let Some(v) = current_version
35+
&& version == v
36+
&& let Some(i) = installed_versions.iter().position(|x| *x == v)
37+
{
38+
installed_versions.remove(i);
39+
if let Some(new_version) = installed_versions.pop() {
40+
svm::set_global_version(&new_version)?;
41+
print::set_global_version(&new_version);
42+
} else {
43+
svm::unset_global_version()?;
4544
}
4645
}
4746
}

crates/svm-rs/src/install.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
2-
all_releases, data_dir, platform, releases::artifact_url, setup_data_dir, setup_version,
3-
version_binary, SvmError,
2+
SvmError, all_releases, data_dir, platform, releases::artifact_url, setup_data_dir,
3+
setup_version, version_binary,
44
};
55
use semver::Version;
66
use sha2::Digest;
@@ -137,13 +137,12 @@ fn do_install_and_retry(
137137
if err.to_string().to_lowercase().contains("text file busy") {
138138
// busy solc can be in use for a while (e.g. if compiling a large project), so we check if the file exists and has the correct checksum
139139
let solc_path = version_binary(&version.to_string());
140-
if solc_path.exists() {
141-
if let Ok(content) = fs::read(&solc_path) {
142-
if ensure_checksum(&content, version, expected_checksum).is_ok() {
143-
// checksum of the existing file matches the expected release checksum
144-
return Ok(solc_path);
145-
}
146-
}
140+
if solc_path.exists()
141+
&& let Ok(content) = fs::read(&solc_path)
142+
&& ensure_checksum(&content, version, expected_checksum).is_ok()
143+
{
144+
// checksum of the existing file matches the expected release checksum
145+
return Ok(solc_path);
147146
}
148147

149148
// retry after some time
@@ -366,9 +365,11 @@ mod tests {
366365
install(&version).await.unwrap();
367366
let solc_path = version_binary(version.to_string().as_str());
368367
let output = Command::new(solc_path).arg("--version").output().unwrap();
369-
assert!(String::from_utf8_lossy(&output.stdout)
370-
.as_ref()
371-
.contains("0.8.10"));
368+
assert!(
369+
String::from_utf8_lossy(&output.stdout)
370+
.as_ref()
371+
.contains("0.8.10")
372+
);
372373
}
373374

374375
#[cfg(feature = "blocking")]
@@ -379,9 +380,11 @@ mod tests {
379380
let solc_path = version_binary(LATEST.to_string().as_str());
380381
let output = Command::new(solc_path).arg("--version").output().unwrap();
381382

382-
assert!(String::from_utf8_lossy(&output.stdout)
383-
.as_ref()
384-
.contains(&LATEST.to_string()));
383+
assert!(
384+
String::from_utf8_lossy(&output.stdout)
385+
.as_ref()
386+
.contains(&LATEST.to_string())
387+
);
385388
}
386389

387390
#[cfg(feature = "blocking")]
@@ -393,9 +396,11 @@ mod tests {
393396
let solc_path = version_binary(version.to_string().as_str());
394397
let output = Command::new(solc_path).arg("--version").output().unwrap();
395398

396-
assert!(String::from_utf8_lossy(&output.stdout)
397-
.as_ref()
398-
.contains("0.8.10"));
399+
assert!(
400+
String::from_utf8_lossy(&output.stdout)
401+
.as_ref()
402+
.contains("0.8.10")
403+
);
399404
}
400405

401406
#[cfg(feature = "blocking")]
@@ -460,8 +465,10 @@ mod tests {
460465
let solc_path = version_binary(version.to_string().as_str());
461466
let output = Command::new(&solc_path).arg("--version").output().unwrap();
462467

463-
assert!(String::from_utf8_lossy(&output.stdout)
464-
.as_ref()
465-
.contains("0.7.1"));
468+
assert!(
469+
String::from_utf8_lossy(&output.stdout)
470+
.as_ref()
471+
.contains("0.7.1")
472+
);
466473
}
467474
}

crates/svm-rs/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ mod paths;
2626
pub use paths::{data_dir, global_version_path, setup_data_dir, version_binary, version_path};
2727

2828
mod platform;
29-
pub use platform::{platform, Platform};
29+
pub use platform::{Platform, platform};
3030

3131
mod releases;
32-
pub use releases::{all_releases, BuildInfo, Releases};
32+
pub use releases::{BuildInfo, Releases, all_releases};
3333

3434
#[cfg(feature = "blocking")]
3535
pub use releases::blocking_all_releases;

crates/svm-rs/src/releases.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,24 @@ static OLD_SOLC_RELEASES: LazyLock<Releases> = LazyLock::new(|| {
3030

3131
const LINUX_AARCH64_MIN: Version = Version::new(0, 5, 0);
3232

33-
static LINUX_AARCH64_URL_PREFIX: &str =
34-
"https://raw.githubusercontent.com/nikitastupin/solc/0045084c85d8c159de03442a37d2018d52374445/linux/aarch64";
33+
static LINUX_AARCH64_URL_PREFIX: &str = "https://raw.githubusercontent.com/nikitastupin/solc/0045084c85d8c159de03442a37d2018d52374445/linux/aarch64";
3534

36-
static LINUX_AARCH64_RELEASES_URL: &str =
37-
"https://raw.githubusercontent.com/nikitastupin/solc/0045084c85d8c159de03442a37d2018d52374445/linux/aarch64/list.json";
35+
static LINUX_AARCH64_RELEASES_URL: &str = "https://raw.githubusercontent.com/nikitastupin/solc/0045084c85d8c159de03442a37d2018d52374445/linux/aarch64/list.json";
3836

3937
// NOTE: Since version 0.8.24, universal macosx releases are available: https://binaries.soliditylang.org/macosx-amd64/list.json
4038
const MACOS_AARCH64_NATIVE: Version = Version::new(0, 8, 5);
4139

4240
const UNIVERSAL_MACOS_BINARIES: Version = Version::new(0, 8, 24);
4341

44-
static MACOS_AARCH64_URL_PREFIX: &str =
45-
"https://raw.githubusercontent.com/alloy-rs/solc-builds/e4b80d33bc4d015b2fc3583e217fbf248b2014e1/macosx/aarch64";
42+
static MACOS_AARCH64_URL_PREFIX: &str = "https://raw.githubusercontent.com/alloy-rs/solc-builds/e4b80d33bc4d015b2fc3583e217fbf248b2014e1/macosx/aarch64";
4643

47-
static MACOS_AARCH64_RELEASES_URL: &str =
48-
"https://raw.githubusercontent.com/alloy-rs/solc-builds/e4b80d33bc4d015b2fc3583e217fbf248b2014e1/macosx/aarch64/list.json";
44+
static MACOS_AARCH64_RELEASES_URL: &str = "https://raw.githubusercontent.com/alloy-rs/solc-builds/e4b80d33bc4d015b2fc3583e217fbf248b2014e1/macosx/aarch64/list.json";
4945

5046
const ANDROID_AARCH64_MIN: Version = Version::new(0, 8, 24);
5147

52-
static ANDROID_AARCH64_URL_PREFIX: &str =
53-
"https://raw.githubusercontent.com/alloy-rs/solc-builds/ac6f303a04b38e7ec507ced511fd3ed7a605179f/android/aarch64";
48+
static ANDROID_AARCH64_URL_PREFIX: &str = "https://raw.githubusercontent.com/alloy-rs/solc-builds/ac6f303a04b38e7ec507ced511fd3ed7a605179f/android/aarch64";
5449

55-
static ANDROID_AARCH64_RELEASES_URL: &str =
56-
"https://raw.githubusercontent.com/alloy-rs/solc-builds/ac6f303a04b38e7ec507ced511fd3ed7a605179f/android/aarch64/list.json";
50+
static ANDROID_AARCH64_RELEASES_URL: &str = "https://raw.githubusercontent.com/alloy-rs/solc-builds/ac6f303a04b38e7ec507ced511fd3ed7a605179f/android/aarch64/list.json";
5751

5852
/// Defines the struct that the JSON-formatted release list can be deserialized into.
5953
///
@@ -115,7 +109,7 @@ pub struct BuildInfo {
115109
/// Helper serde module to serialize and deserialize bytes as hex.
116110
mod hex_string {
117111
use super::*;
118-
use serde::{de, Deserializer, Serializer};
112+
use serde::{Deserializer, Serializer, de};
119113

120114
pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
121115
where

0 commit comments

Comments
 (0)