diff --git a/crates/artifacts/solc/src/sourcemap.rs b/crates/artifacts/solc/src/sourcemap.rs index aab1e5f85..39fd60bfd 100644 --- a/crates/artifacts/solc/src/sourcemap.rs +++ b/crates/artifacts/solc/src/sourcemap.rs @@ -556,20 +556,23 @@ enum State { impl State { fn advance(&mut self, pos: usize) -> Result<(), SyntaxError> { - match self { - Self::Offset => *self = Self::Length, - Self::Length => *self = Self::Index, - Self::Index => *self = Self::Jmp, - Self::Jmp => *self = Self::Modifier, + *self = match self { + Self::Offset => Self::Length, + Self::Length => Self::Index, + Self::Index => Self::Jmp, + Self::Jmp => Self::Modifier, Self::Modifier => return Err(SyntaxError::new(pos, "unexpected colon")), - } + }; Ok(()) } } -/// Parses a source map +/// Parses a source map. pub fn parse(input: &str) -> Result { - Parser::new(input).collect() + Parser::new(input).collect::>().map(|mut v| { + v.shrink_to_fit(); + v + }) } #[cfg(test)] diff --git a/crates/compilers/src/compilers/solc/compiler.rs b/crates/compilers/src/compilers/solc/compiler.rs index e99a09e85..1840c3960 100644 --- a/crates/compilers/src/compilers/solc/compiler.rs +++ b/crates/compilers/src/compilers/solc/compiler.rs @@ -615,7 +615,7 @@ fn version_from_output(output: Output) -> Result { let version = stdout .lines() .filter(|l| !l.trim().is_empty()) - .last() + .next_back() .ok_or_else(|| SolcError::msg("Version not found in Solc output"))?; // NOTE: semver doesn't like `+` in g++ in build metadata which is invalid semver Ok(Version::from_str(&version.trim_start_matches("Version: ").replace(".g++", ".gcc"))?)