Skip to content

Commit 042ed7c

Browse files
authored
fix: remove the need for the regex crate's pattern feature (#51)
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.
1 parent 7cde0a4 commit 042ed7c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

crates/zkevm_test_harness/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ env_logger = "0.9"
4444
smallvec = "1.13"
4545
structopt = "0.3.26"
4646
codegen = "0.2.0"
47-
regex = { version = "1.10.6", features = ["pattern"] }
47+
regex = "1.11.1"
4848

4949
[dev-dependencies]
5050
rand = "0.4"

crates/zkevm_test_harness/src/tests/utils/preprocess_asm.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn replace_tags_in_template(
7474
let mut result = asm_template.clone();
7575
let template_regex = Regex::new(r#"\$\{[^\}]+\}"#).expect("Invalid regex");
7676

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

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

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

333-
trimmed_content
334-
.matches(&args_regex)
335-
.map(|x| x.trim_matches(',').trim().trim_matches('"'))
333+
args_regex
334+
.find_iter(trimmed_content)
335+
.map(|x| x.as_str().trim_matches(',').trim().trim_matches('"'))
336336
.collect()
337337
}
338338

0 commit comments

Comments
 (0)