Skip to content

Commit

Permalink
chore: inline constants in Settings::sanitize (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Nov 18, 2024
1 parent 59633c7 commit e9668e1
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions crates/artifacts/solc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.soliditylang.org/en/v0.6.0/using-the-compiler.html#compiler-api>
// missing in <https://docs.soliditylang.org/en/v0.5.17/using-the-compiler.html#compiler-api>
Expand All @@ -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 <https://github.com/ethereum/solidity/releases/tag/v0.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 <https://github.com/ethereum/solidity/releases/tag/v0.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 <https://github.com/ethereum/solidity/releases/tag/v0.8.7>
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 <https://docs.soliditylang.org/en/v0.8.10/using-the-compiler.html#compiler-api>
// <https://github.com/ethereum/solidity/releases/tag/v0.8.10>
Expand All @@ -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 <https://github.com/ethereum/solidity/releases/tag/v0.8.18>
if let Some(meta) = &mut self.metadata {
meta.cbor_metadata = None;
Expand All @@ -359,7 +353,7 @@ impl Settings {
}
}

if *version < SHANGHAI_SOLC {
if *version < Version::new(0, 8, 20) {
// introduced in 0.8.20 <https://github.com/ethereum/solidity/releases/tag/v0.8.20>
if let Some(model_checker) = &mut self.model_checker {
model_checker.show_proved_safe = None;
Expand All @@ -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();
}
}

Expand Down

0 comments on commit e9668e1

Please sign in to comment.