From e9668e12f5ab1ddf9cae5b3915f420b3f9172870 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:34:52 +0100 Subject: [PATCH] chore: inline constants in Settings::sanitize (#219) --- crates/artifacts/solc/src/lib.rs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/crates/artifacts/solc/src/lib.rs b/crates/artifacts/solc/src/lib.rs index 1ad80da2..a14d64ca 100644 --- a/crates/artifacts/solc/src/lib.rs +++ b/crates/artifacts/solc/src/lib.rs @@ -297,8 +297,7 @@ impl Settings { /// This will remove/adjust values in the settings that are not compatible with this version. pub fn sanitize(&mut self, version: &Version, language: SolcLanguage) { - const V0_6_0: Version = Version::new(0, 6, 0); - if *version < V0_6_0 { + if *version < Version::new(0, 6, 0) { if let Some(meta) = &mut self.metadata { // introduced in // missing in @@ -308,30 +307,26 @@ impl Settings { self.debug = None; } - const V0_7_5: Version = Version::new(0, 7, 5); - if *version < V0_7_5 { + if *version < Version::new(0, 7, 5) { // introduced in 0.7.5 self.via_ir = None; } - const V0_8_5: Version = Version::new(0, 8, 5); - if *version < V0_8_5 { + if *version < Version::new(0, 8, 5) { // introduced in 0.8.5 if let Some(optimizer_details) = &mut self.optimizer.details { optimizer_details.inliner = None; } } - const V0_8_7: Version = Version::new(0, 8, 7); - if *version < V0_8_7 { + if *version < Version::new(0, 8, 7) { // lower the disable version from 0.8.10 to 0.8.7, due to `divModNoSlacks`, // `showUnproved` and `solvers` are implemented // introduced in self.model_checker = None; } - const V0_8_10: Version = Version::new(0, 8, 10); - if *version < V0_8_10 { + if *version < Version::new(0, 8, 10) { if let Some(debug) = &mut self.debug { // introduced in // @@ -344,8 +339,7 @@ impl Settings { } } - const V0_8_18: Version = Version::new(0, 8, 18); - if *version < V0_8_18 { + if *version < Version::new(0, 8, 18) { // introduced in 0.8.18 if let Some(meta) = &mut self.metadata { meta.cbor_metadata = None; @@ -359,7 +353,7 @@ impl Settings { } } - if *version < SHANGHAI_SOLC { + if *version < Version::new(0, 8, 20) { // introduced in 0.8.20 if let Some(model_checker) = &mut self.model_checker { model_checker.show_proved_safe = None; @@ -371,11 +365,14 @@ impl Settings { self.evm_version = evm_version.normalize_version_solc(version); } - if language == SolcLanguage::Yul { - if !self.remappings.is_empty() { - warn!("omitting remappings supplied for the yul sources"); + match language { + SolcLanguage::Solidity => {} + SolcLanguage::Yul => { + if !self.remappings.is_empty() { + warn!("omitting remappings supplied for the yul sources"); + } + self.remappings = Vec::new(); } - self.remappings = Vec::new(); } }