Skip to content

Commit

Permalink
fix: remove the need for the regex crate's pattern feature (#51)
Browse files Browse the repository at this point in the history
The `std::str::pattern::Pattern` trait implementation in the `regex`
crate recently broke compilation with the nightly rust toolchain.
The removal of the trait implementation and the corresponding `pattern`
feature is being
[planned](rust-lang/regex#1233).
This PR removes the reliance on this trait implementation.
  • Loading branch information
robik75 authored Oct 25, 2024
1 parent 7cde0a4 commit 042ed7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/zkevm_test_harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ env_logger = "0.9"
smallvec = "1.13"
structopt = "0.3.26"
codegen = "0.2.0"
regex = { version = "1.10.6", features = ["pattern"] }
regex = "1.11.1"

[dev-dependencies]
rand = "0.4"
Expand Down
12 changes: 6 additions & 6 deletions crates/zkevm_test_harness/src/tests/utils/preprocess_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn replace_tags_in_template(
let mut result = asm_template.clone();
let template_regex = Regex::new(r#"\$\{[^\}]+\}"#).expect("Invalid regex");

for (_, matched) in asm_template.match_indices(&template_regex) {
for matched in template_regex.find_iter(&asm_template).map(|m| m.as_str()) {
let prefix = "${";
let suffix = "}";
let key_to_replace = matched
Expand Down Expand Up @@ -111,7 +111,7 @@ fn link_additional_contracts(
// regex: <ADDRESS.asm>
let contract_regex = Regex::new(r#"<\d+\.asm>"#).expect("Invalid regex");

for (_, matched) in asm.match_indices(&contract_regex) {
for matched in contract_regex.find_iter(asm).map(|m| m.as_str()) {
let prefix = "<";
let suffix = ".asm>";
let contract_address = Address::from_low_u64_be(
Expand Down Expand Up @@ -214,7 +214,7 @@ fn replace_directives(asm: String, directive: Directive) -> (String, Vec<String>
};

let mut args_for_commands: Vec<String> = Vec::new();
for (index, matched) in asm.match_indices(&regex) {
for (index, matched) in regex.find_iter(&asm).map(|m| (m.start(), m.as_str())) {
// skip if directive commented out
if asm[..index]
.chars()
Expand Down Expand Up @@ -330,9 +330,9 @@ fn parse_args<'a>(text: &'a str, prefix: &str, suffix: &str) -> Vec<&'a str> {
.expect("Invalid text in directive")
.trim();

trimmed_content
.matches(&args_regex)
.map(|x| x.trim_matches(',').trim().trim_matches('"'))
args_regex
.find_iter(trimmed_content)
.map(|x| x.as_str().trim_matches(',').trim().trim_matches('"'))
.collect()
}

Expand Down

0 comments on commit 042ed7c

Please sign in to comment.