diff --git a/crates/codegen/runtime/cargo/crate/src/extensions/bindings/mod.rs b/crates/codegen/runtime/cargo/crate/src/extensions/bindings/mod.rs index eee8b7880f..92cf63b2e4 100644 --- a/crates/codegen/runtime/cargo/crate/src/extensions/bindings/mod.rs +++ b/crates/codegen/runtime/cargo/crate/src/extensions/bindings/mod.rs @@ -6,7 +6,7 @@ use crate::parser::ParserInitializationError; #[allow(clippy::needless_pass_by_value)] pub fn add_built_ins( _binding_graph: &mut BindingGraph, - _version: Version, + _version: &Version, ) -> Result<(), ParserInitializationError> { unreachable!("Built-ins are Solidity-specific") } diff --git a/crates/codegen/runtime/cargo/crate/src/runtime/bindings/mod.rs b/crates/codegen/runtime/cargo/crate/src/runtime/bindings/mod.rs index 5aa7ed4638..d788c030ae 100644 --- a/crates/codegen/runtime/cargo/crate/src/runtime/bindings/mod.rs +++ b/crates/codegen/runtime/cargo/crate/src/runtime/bindings/mod.rs @@ -26,6 +26,7 @@ pub enum BindingGraphInitializationError { ParserInitialization(#[from] ParserInitializationError), } +#[allow(clippy::needless_pass_by_value)] pub fn create_with_resolver( version: Version, resolver: Rc>, @@ -37,7 +38,7 @@ pub fn create_with_resolver( resolver, ); - crate::extensions::bindings::add_built_ins(&mut binding_graph, version)?; + crate::extensions::bindings::add_built_ins(&mut binding_graph, &version)?; Ok(binding_graph) } diff --git a/crates/solidity/outputs/cargo/crate/src/extensions/bindings/mod.rs b/crates/solidity/outputs/cargo/crate/src/extensions/bindings/mod.rs index b3ec4aa052..d2bdb47843 100644 --- a/crates/solidity/outputs/cargo/crate/src/extensions/bindings/mod.rs +++ b/crates/solidity/outputs/cargo/crate/src/extensions/bindings/mod.rs @@ -8,15 +8,21 @@ use crate::bindings::BindingGraph; use crate::cst::{Edge, Node, NonterminalNode, TerminalKind, TerminalNode}; use crate::parser::{Parser, ParserInitializationError}; +static BUILT_INS_PARSER_VERSION: Version = Version::new(0, 8, 28); + pub fn add_built_ins( binding_graph: &mut BindingGraph, - version: Version, + version: &Version, ) -> Result<(), ParserInitializationError> { - let source = get_built_ins_contents(&version); - let parser = Parser::create(version)?; - let parse_output = parser.parse(Parser::ROOT_KIND, source); + let parser = Parser::create(BUILT_INS_PARSER_VERSION.clone())?; + let built_ins_parse_output = parser.parse(Parser::ROOT_KIND, get_built_ins_contents(version)); + assert!( + built_ins_parse_output.is_valid(), + "built-ins parse without errors" + ); - let built_ins_cursor = transform(parse_output.tree()).cursor_with_offset(TextIndex::ZERO); + let built_ins_cursor = transform(built_ins_parse_output.tree()) + .cursor_with_offset(TextIndex::ZERO); binding_graph.add_system_file("built_ins.sol", built_ins_cursor); Ok(()) diff --git a/crates/solidity/outputs/cargo/crate/src/generated/bindings/mod.rs b/crates/solidity/outputs/cargo/crate/src/generated/bindings/mod.rs index 965983ba21..d1a8401d8d 100644 --- a/crates/solidity/outputs/cargo/crate/src/generated/bindings/mod.rs +++ b/crates/solidity/outputs/cargo/crate/src/generated/bindings/mod.rs @@ -28,6 +28,7 @@ pub enum BindingGraphInitializationError { ParserInitialization(#[from] ParserInitializationError), } +#[allow(clippy::needless_pass_by_value)] pub fn create_with_resolver( version: Version, resolver: Rc>, @@ -39,7 +40,7 @@ pub fn create_with_resolver( resolver, ); - crate::extensions::bindings::add_built_ins(&mut binding_graph, version)?; + crate::extensions::bindings::add_built_ins(&mut binding_graph, &version)?; Ok(binding_graph) } diff --git a/crates/testlang/outputs/cargo/crate/src/extensions/bindings/mod.rs b/crates/testlang/outputs/cargo/crate/src/extensions/bindings/mod.rs index eee8b7880f..92cf63b2e4 100644 --- a/crates/testlang/outputs/cargo/crate/src/extensions/bindings/mod.rs +++ b/crates/testlang/outputs/cargo/crate/src/extensions/bindings/mod.rs @@ -6,7 +6,7 @@ use crate::parser::ParserInitializationError; #[allow(clippy::needless_pass_by_value)] pub fn add_built_ins( _binding_graph: &mut BindingGraph, - _version: Version, + _version: &Version, ) -> Result<(), ParserInitializationError> { unreachable!("Built-ins are Solidity-specific") } diff --git a/crates/testlang/outputs/cargo/crate/src/generated/bindings/mod.rs b/crates/testlang/outputs/cargo/crate/src/generated/bindings/mod.rs index 965983ba21..d1a8401d8d 100644 --- a/crates/testlang/outputs/cargo/crate/src/generated/bindings/mod.rs +++ b/crates/testlang/outputs/cargo/crate/src/generated/bindings/mod.rs @@ -28,6 +28,7 @@ pub enum BindingGraphInitializationError { ParserInitialization(#[from] ParserInitializationError), } +#[allow(clippy::needless_pass_by_value)] pub fn create_with_resolver( version: Version, resolver: Rc>, @@ -39,7 +40,7 @@ pub fn create_with_resolver( resolver, ); - crate::extensions::bindings::add_built_ins(&mut binding_graph, version)?; + crate::extensions::bindings::add_built_ins(&mut binding_graph, &version)?; Ok(binding_graph) }