Skip to content

Commit cd28fec

Browse files
committed
Upgrade regex-syntax to 0.7 version
1 parent 1c9cc66 commit cd28fec

File tree

2 files changed

+23
-41
lines changed

2 files changed

+23
-41
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ nom_locate = "4.0"
3232

3333
# "into-regex" feature dependencies
3434
either = { version = "1.6", optional = true }
35-
regex = { version = "1.5.5", optional = true }
36-
regex-syntax = { version = "0.6", optional = true }
35+
regex = { version = "1.8.1", optional = true }
36+
regex-syntax = { version = "0.7.1", optional = true }
3737

3838
[workspace]
3939
members = ["fuzz"]

src/expand/parameters.rs

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ type WithParsIter<I, P> = Either<
306306
mod regex_hir {
307307
use std::mem;
308308

309-
use regex_syntax::hir::{self, Hir, HirKind};
309+
use regex_syntax::hir::{Hir, HirKind};
310310

311311
/// Checks whether the given [`Regex`] [`Hir`] contains any capturing
312312
/// groups.
@@ -317,19 +317,9 @@ mod regex_hir {
317317
HirKind::Empty
318318
| HirKind::Literal(_)
319319
| HirKind::Class(_)
320-
| HirKind::Anchor(_)
321-
| HirKind::WordBoundary(_)
322-
| HirKind::Repetition(_)
323-
| HirKind::Group(hir::Group {
324-
kind: hir::GroupKind::NonCapturing,
325-
..
326-
}) => false,
327-
HirKind::Group(hir::Group {
328-
kind:
329-
hir::GroupKind::CaptureName { .. }
330-
| hir::GroupKind::CaptureIndex(_),
331-
..
332-
}) => true,
320+
| HirKind::Look(_)
321+
| HirKind::Repetition(_) => false,
322+
HirKind::Capture(_) => true,
333323
HirKind::Concat(inner) | HirKind::Alternation(inner) => {
334324
inner.iter().any(has_capture_groups)
335325
}
@@ -343,7 +333,7 @@ mod regex_hir {
343333
}
344334

345335
/// Renames capturing groups in the given [`Hir`] via
346-
/// `__{parameter_id}_{group_id}` naming scheme, using the given
336+
/// `__{parameter_id}_{group_id}` naming scheme, using the provided
347337
/// `group_id_indexer`.
348338
fn rename_groups_inner(
349339
hir: Hir,
@@ -352,38 +342,28 @@ mod regex_hir {
352342
) -> Hir {
353343
match hir.into_kind() {
354344
HirKind::Empty => Hir::empty(),
355-
HirKind::Literal(lit) => Hir::literal(lit),
345+
HirKind::Literal(lit) => Hir::literal(lit.0),
356346
HirKind::Class(cl) => Hir::class(cl),
357-
HirKind::Anchor(anc) => Hir::anchor(anc),
358-
HirKind::WordBoundary(bound) => Hir::word_boundary(bound),
347+
HirKind::Look(l) => Hir::look(l),
359348
HirKind::Repetition(rep) => Hir::repetition(rep),
360-
HirKind::Group(mut group) => {
361-
match group.kind {
362-
hir::GroupKind::CaptureIndex(index)
363-
| hir::GroupKind::CaptureName { index, .. } => {
364-
group.kind = hir::GroupKind::CaptureName {
365-
name: format!(
366-
"__{parameter_id}_{}",
367-
*group_id_indexer,
368-
),
369-
index,
370-
};
371-
*group_id_indexer += 1;
372-
}
373-
hir::GroupKind::NonCapturing => {}
374-
}
375-
376-
let inner_hir = mem::replace(group.hir.as_mut(), Hir::empty());
349+
HirKind::Capture(mut capture) => {
350+
capture.name = Some(
351+
format!("__{parameter_id}_{}", *group_id_indexer).into(),
352+
);
353+
*group_id_indexer += 1;
354+
355+
let inner_hir =
356+
mem::replace(capture.sub.as_mut(), Hir::empty());
377357
drop(mem::replace(
378-
group.hir.as_mut(),
358+
capture.sub.as_mut(),
379359
rename_groups_inner(
380360
inner_hir,
381361
parameter_id,
382362
group_id_indexer,
383363
),
384364
));
385365

386-
Hir::group(group)
366+
Hir::capture(capture)
387367
}
388368
HirKind::Concat(concat) => Hir::concat(
389369
concat
@@ -428,8 +408,10 @@ mod spec {
428408

429409
assert_eq!(
430410
expr.as_str(),
431-
"^(?:\"(?P<__0_0>custom)\"|'(?P<__0_1>custom)') \
432-
(?:\"(?P<__1_0>custom)\"|'(?P<__1_1>custom)')$",
411+
"^(?:(?:(?:\"(?P<__0_0>(?:custom))\")\
412+
|(?:'(?P<__0_1>(?:custom))'))) \
413+
(?:(?:(?:\"(?P<__1_0>(?:custom))\")\
414+
|(?:'(?P<__1_1>(?:custom))')))$",
433415
);
434416
}
435417

0 commit comments

Comments
 (0)