Skip to content

Commit e9668e1

Browse files
authored
chore: inline constants in Settings::sanitize (#219)
1 parent 59633c7 commit e9668e1

File tree

1 file changed

+14
-17
lines changed
  • crates/artifacts/solc/src

1 file changed

+14
-17
lines changed

crates/artifacts/solc/src/lib.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ impl Settings {
297297

298298
/// This will remove/adjust values in the settings that are not compatible with this version.
299299
pub fn sanitize(&mut self, version: &Version, language: SolcLanguage) {
300-
const V0_6_0: Version = Version::new(0, 6, 0);
301-
if *version < V0_6_0 {
300+
if *version < Version::new(0, 6, 0) {
302301
if let Some(meta) = &mut self.metadata {
303302
// introduced in <https://docs.soliditylang.org/en/v0.6.0/using-the-compiler.html#compiler-api>
304303
// missing in <https://docs.soliditylang.org/en/v0.5.17/using-the-compiler.html#compiler-api>
@@ -308,30 +307,26 @@ impl Settings {
308307
self.debug = None;
309308
}
310309

311-
const V0_7_5: Version = Version::new(0, 7, 5);
312-
if *version < V0_7_5 {
310+
if *version < Version::new(0, 7, 5) {
313311
// introduced in 0.7.5 <https://github.com/ethereum/solidity/releases/tag/v0.7.5>
314312
self.via_ir = None;
315313
}
316314

317-
const V0_8_5: Version = Version::new(0, 8, 5);
318-
if *version < V0_8_5 {
315+
if *version < Version::new(0, 8, 5) {
319316
// introduced in 0.8.5 <https://github.com/ethereum/solidity/releases/tag/v0.8.5>
320317
if let Some(optimizer_details) = &mut self.optimizer.details {
321318
optimizer_details.inliner = None;
322319
}
323320
}
324321

325-
const V0_8_7: Version = Version::new(0, 8, 7);
326-
if *version < V0_8_7 {
322+
if *version < Version::new(0, 8, 7) {
327323
// lower the disable version from 0.8.10 to 0.8.7, due to `divModNoSlacks`,
328324
// `showUnproved` and `solvers` are implemented
329325
// introduced in <https://github.com/ethereum/solidity/releases/tag/v0.8.7>
330326
self.model_checker = None;
331327
}
332328

333-
const V0_8_10: Version = Version::new(0, 8, 10);
334-
if *version < V0_8_10 {
329+
if *version < Version::new(0, 8, 10) {
335330
if let Some(debug) = &mut self.debug {
336331
// introduced in <https://docs.soliditylang.org/en/v0.8.10/using-the-compiler.html#compiler-api>
337332
// <https://github.com/ethereum/solidity/releases/tag/v0.8.10>
@@ -344,8 +339,7 @@ impl Settings {
344339
}
345340
}
346341

347-
const V0_8_18: Version = Version::new(0, 8, 18);
348-
if *version < V0_8_18 {
342+
if *version < Version::new(0, 8, 18) {
349343
// introduced in 0.8.18 <https://github.com/ethereum/solidity/releases/tag/v0.8.18>
350344
if let Some(meta) = &mut self.metadata {
351345
meta.cbor_metadata = None;
@@ -359,7 +353,7 @@ impl Settings {
359353
}
360354
}
361355

362-
if *version < SHANGHAI_SOLC {
356+
if *version < Version::new(0, 8, 20) {
363357
// introduced in 0.8.20 <https://github.com/ethereum/solidity/releases/tag/v0.8.20>
364358
if let Some(model_checker) = &mut self.model_checker {
365359
model_checker.show_proved_safe = None;
@@ -371,11 +365,14 @@ impl Settings {
371365
self.evm_version = evm_version.normalize_version_solc(version);
372366
}
373367

374-
if language == SolcLanguage::Yul {
375-
if !self.remappings.is_empty() {
376-
warn!("omitting remappings supplied for the yul sources");
368+
match language {
369+
SolcLanguage::Solidity => {}
370+
SolcLanguage::Yul => {
371+
if !self.remappings.is_empty() {
372+
warn!("omitting remappings supplied for the yul sources");
373+
}
374+
self.remappings = Vec::new();
377375
}
378-
self.remappings = Vec::new();
379376
}
380377
}
381378

0 commit comments

Comments
 (0)