Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: inline constants in Settings::sanitize #219

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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