diff --git a/fuzz/fuzz_targets/ast_roundtrip.rs b/fuzz/fuzz_targets/ast_roundtrip.rs index 040b59d63..c35ac962e 100644 --- a/fuzz/fuzz_targets/ast_roundtrip.rs +++ b/fuzz/fuzz_targets/ast_roundtrip.rs @@ -3,7 +3,7 @@ use { libfuzzer_sys::{fuzz_target, Corpus}, regex_syntax::ast::{ - parse::Parser, visit, Ast, Flag, Group, GroupKind, SetFlags, Visitor, + parse::Parser, visit, Ast, Flag, Flags, GroupKind, Visitor, }, }; @@ -32,16 +32,17 @@ impl Visitor for VerboseVisitor { } fn visit_pre(&mut self, ast: &Ast) -> Result { + let reject_flags = |flags: &Flags| { + flags.flag_state(Flag::IgnoreWhitespace).unwrap_or(false) + }; match ast { - Ast::Flags(SetFlags { flags, .. }) - | Ast::Group(Group { - kind: GroupKind::NonCapturing(flags), .. - }) if flags - .flag_state(Flag::IgnoreWhitespace) - .unwrap_or(false) => - { - Err(()) - } + Ast::Flags(x) if reject_flags(&x.flags) => return Err(()), + Ast::Group(x) => match x.kind { + GroupKind::NonCapturing(ref flags) if reject_flags(flags) => { + return Err(()) + } + _ => Ok(()), + }, _ => Ok(()), } } diff --git a/regex-cli/cmd/generate/fowler.rs b/regex-cli/cmd/generate/fowler.rs index c0ab1b361..c287f6f52 100644 --- a/regex-cli/cmd/generate/fowler.rs +++ b/regex-cli/cmd/generate/fowler.rs @@ -404,7 +404,9 @@ fn count_capturing_groups_ast(ast: ®ex_syntax::ast::Ast) -> usize { | Ast::Literal(_) | Ast::Dot(_) | Ast::Assertion(_) - | Ast::Class(_) => 0, + | Ast::ClassUnicode(_) + | Ast::ClassPerl(_) + | Ast::ClassBracketed(_) => 0, Ast::Repetition(ref rep) => count_capturing_groups_ast(&*rep.ast), Ast::Group(ref group) => { let this = if group.is_capturing() { 1 } else { 0 }; diff --git a/regex-syntax/src/ast/mod.rs b/regex-syntax/src/ast/mod.rs index c346abcb6..9e0f92606 100644 --- a/regex-syntax/src/ast/mod.rs +++ b/regex-syntax/src/ast/mod.rs @@ -429,19 +429,9 @@ pub struct Comment { /// /// This type defines its own destructor that uses constant stack space and /// heap space proportional to the size of the `Ast`. -/// -/// This type boxes the actual kind of the AST element so that an `Ast` value -/// itself has a very small size. This in turn makes things like `Vec` use -/// a lot less memory than it might otherwise, which is particularly beneficial -/// for representing long concatenations or alternations. -#[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -pub struct Ast(pub Box); - -/// The kind of an abstract syntax element. #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] -pub enum AstKind { +pub enum Ast { /// An empty regex that matches everything. Empty(Box), /// A set of flags, e.g., `(?is)`. @@ -473,86 +463,86 @@ pub enum AstKind { impl Ast { /// Create an "empty" AST item. pub fn empty(span: Span) -> Ast { - Ast(Box::new(AstKind::Empty(Box::new(span)))) + Ast::Empty(Box::new(span)) } /// Create a "flags" AST item. pub fn flags(e: SetFlags) -> Ast { - Ast(Box::new(AstKind::Flags(Box::new(e)))) + Ast::Flags(Box::new(e)) } /// Create a "literal" AST item. pub fn literal(e: Literal) -> Ast { - Ast(Box::new(AstKind::Literal(Box::new(e)))) + Ast::Literal(Box::new(e)) } /// Create a "dot" AST item. pub fn dot(span: Span) -> Ast { - Ast(Box::new(AstKind::Dot(Box::new(span)))) + Ast::Dot(Box::new(span)) } /// Create a "assertion" AST item. pub fn assertion(e: Assertion) -> Ast { - Ast(Box::new(AstKind::Assertion(Box::new(e)))) + Ast::Assertion(Box::new(e)) } /// Create a "Unicode class" AST item. pub fn class_unicode(e: ClassUnicode) -> Ast { - Ast(Box::new(AstKind::ClassUnicode(Box::new(e)))) + Ast::ClassUnicode(Box::new(e)) } /// Create a "Perl class" AST item. pub fn class_perl(e: ClassPerl) -> Ast { - Ast(Box::new(AstKind::ClassPerl(Box::new(e)))) + Ast::ClassPerl(Box::new(e)) } /// Create a "bracketed class" AST item. pub fn class_bracketed(e: ClassBracketed) -> Ast { - Ast(Box::new(AstKind::ClassBracketed(Box::new(e)))) + Ast::ClassBracketed(Box::new(e)) } /// Create a "repetition" AST item. pub fn repetition(e: Repetition) -> Ast { - Ast(Box::new(AstKind::Repetition(Box::new(e)))) + Ast::Repetition(Box::new(e)) } /// Create a "group" AST item. pub fn group(e: Group) -> Ast { - Ast(Box::new(AstKind::Group(Box::new(e)))) + Ast::Group(Box::new(e)) } /// Create a "alternation" AST item. pub fn alternation(e: Alternation) -> Ast { - Ast(Box::new(AstKind::Alternation(Box::new(e)))) + Ast::Alternation(Box::new(e)) } /// Create a "concat" AST item. pub fn concat(e: Concat) -> Ast { - Ast(Box::new(AstKind::Concat(Box::new(e)))) + Ast::Concat(Box::new(e)) } /// Return the span of this abstract syntax tree. pub fn span(&self) -> &Span { - match *self.0 { - AstKind::Empty(ref span) => span, - AstKind::Flags(ref x) => &x.span, - AstKind::Literal(ref x) => &x.span, - AstKind::Dot(ref span) => span, - AstKind::Assertion(ref x) => &x.span, - AstKind::ClassUnicode(ref x) => &x.span, - AstKind::ClassPerl(ref x) => &x.span, - AstKind::ClassBracketed(ref x) => &x.span, - AstKind::Repetition(ref x) => &x.span, - AstKind::Group(ref x) => &x.span, - AstKind::Alternation(ref x) => &x.span, - AstKind::Concat(ref x) => &x.span, + match *self { + Ast::Empty(ref span) => span, + Ast::Flags(ref x) => &x.span, + Ast::Literal(ref x) => &x.span, + Ast::Dot(ref span) => span, + Ast::Assertion(ref x) => &x.span, + Ast::ClassUnicode(ref x) => &x.span, + Ast::ClassPerl(ref x) => &x.span, + Ast::ClassBracketed(ref x) => &x.span, + Ast::Repetition(ref x) => &x.span, + Ast::Group(ref x) => &x.span, + Ast::Alternation(ref x) => &x.span, + Ast::Concat(ref x) => &x.span, } } /// Return true if and only if this Ast is empty. pub fn is_empty(&self) -> bool { - match *self.0 { - AstKind::Empty(_) => true, + match *self { + Ast::Empty(_) => true, _ => false, } } @@ -560,19 +550,19 @@ impl Ast { /// Returns true if and only if this AST has any (including possibly empty) /// subexpressions. fn has_subexprs(&self) -> bool { - match *self.0 { - AstKind::Empty(_) - | AstKind::Flags(_) - | AstKind::Literal(_) - | AstKind::Dot(_) - | AstKind::Assertion(_) - | AstKind::ClassUnicode(_) - | AstKind::ClassPerl(_) => false, - AstKind::ClassBracketed(_) - | AstKind::Repetition(_) - | AstKind::Group(_) - | AstKind::Alternation(_) - | AstKind::Concat(_) => true, + match *self { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + | Ast::ClassUnicode(_) + | Ast::ClassPerl(_) => false, + Ast::ClassBracketed(_) + | Ast::Repetition(_) + | Ast::Group(_) + | Ast::Alternation(_) + | Ast::Concat(_) => true, } } } @@ -1598,20 +1588,20 @@ impl Drop for Ast { fn drop(&mut self) { use core::mem; - match *self.0 { - AstKind::Empty(_) - | AstKind::Flags(_) - | AstKind::Literal(_) - | AstKind::Dot(_) - | AstKind::Assertion(_) - | AstKind::ClassUnicode(_) - | AstKind::ClassPerl(_) + match *self { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + | Ast::ClassUnicode(_) + | Ast::ClassPerl(_) // Bracketed classes are recursive, they get their own Drop impl. - | AstKind::ClassBracketed(_) => return, - AstKind::Repetition(ref x) if !x.ast.has_subexprs() => return, - AstKind::Group(ref x) if !x.ast.has_subexprs() => return, - AstKind::Alternation(ref x) if x.asts.is_empty() => return, - AstKind::Concat(ref x) if x.asts.is_empty() => return, + | Ast::ClassBracketed(_) => return, + Ast::Repetition(ref x) if !x.ast.has_subexprs() => return, + Ast::Group(ref x) if !x.ast.has_subexprs() => return, + Ast::Alternation(ref x) if x.asts.is_empty() => return, + Ast::Concat(ref x) if x.asts.is_empty() => return, _ => {} } @@ -1619,27 +1609,27 @@ impl Drop for Ast { let empty_ast = || Ast::empty(empty_span()); let mut stack = vec![mem::replace(self, empty_ast())]; while let Some(mut ast) = stack.pop() { - match *ast.0 { - AstKind::Empty(_) - | AstKind::Flags(_) - | AstKind::Literal(_) - | AstKind::Dot(_) - | AstKind::Assertion(_) - | AstKind::ClassUnicode(_) - | AstKind::ClassPerl(_) + match ast { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + | Ast::ClassUnicode(_) + | Ast::ClassPerl(_) // Bracketed classes are recursive, so they get their own Drop // impl. - | AstKind::ClassBracketed(_) => {} - AstKind::Repetition(ref mut x) => { + | Ast::ClassBracketed(_) => {} + Ast::Repetition(ref mut x) => { stack.push(mem::replace(&mut x.ast, empty_ast())); } - AstKind::Group(ref mut x) => { + Ast::Group(ref mut x) => { stack.push(mem::replace(&mut x.ast, empty_ast())); } - AstKind::Alternation(ref mut x) => { + Ast::Alternation(ref mut x) => { stack.extend(x.asts.drain(..)); } - AstKind::Concat(ref mut x) => { + Ast::Concat(ref mut x) => { stack.extend(x.asts.drain(..)); } } @@ -1760,20 +1750,7 @@ mod tests { // 64-bit target. Wow. #[test] fn ast_size() { - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - std::dbg!(core::mem::size_of::()); - - let max = core::mem::size_of::(); + let max = 2 * core::mem::size_of::(); let size = core::mem::size_of::(); assert!( size <= max, @@ -1781,14 +1758,5 @@ mod tests { size, max ); - - let max = 2 * core::mem::size_of::(); - let size = core::mem::size_of::(); - assert!( - size <= max, - "AstKind size of {} bytes is bigger than suggested max {}", - size, - max - ); } } diff --git a/regex-syntax/src/ast/parse.rs b/regex-syntax/src/ast/parse.rs index a87be0e02..f7bae7759 100644 --- a/regex-syntax/src/ast/parse.rs +++ b/regex-syntax/src/ast/parse.rs @@ -16,7 +16,7 @@ use alloc::{ }; use crate::{ - ast::{self, Ast, AstKind, Position, Span}, + ast::{self, Ast, Position, Span}, either::Either, is_escapeable_character, is_meta_character, }; @@ -1044,8 +1044,8 @@ impl<'s, P: Borrow> ParserI<'s, P> { ) } }; - match *ast.0 { - AstKind::Empty(_) | AstKind::Flags(_) => { + match ast { + Ast::Empty(_) | Ast::Flags(_) => { return Err( self.error(self.span(), ast::ErrorKind::RepetitionMissing) ) @@ -1096,8 +1096,8 @@ impl<'s, P: Borrow> ParserI<'s, P> { ) } }; - match *ast.0 { - AstKind::Empty(_) | AstKind::Flags(_) => { + match ast { + Ast::Empty(_) | Ast::Flags(_) => { return Err( self.error(self.span(), ast::ErrorKind::RepetitionMissing) ) @@ -2183,43 +2183,43 @@ impl<'p, 's, P: Borrow> ast::Visitor for NestLimiter<'p, 's, P> { } fn visit_pre(&mut self, ast: &Ast) -> Result<()> { - let span = match *ast.0 { - AstKind::Empty(_) - | AstKind::Flags(_) - | AstKind::Literal(_) - | AstKind::Dot(_) - | AstKind::Assertion(_) - | AstKind::ClassUnicode(_) - | AstKind::ClassPerl(_) => { + let span = match *ast { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + | Ast::ClassUnicode(_) + | Ast::ClassPerl(_) => { // These are all base cases, so we don't increment depth. return Ok(()); } - AstKind::ClassBracketed(ref x) => &x.span, - AstKind::Repetition(ref x) => &x.span, - AstKind::Group(ref x) => &x.span, - AstKind::Alternation(ref x) => &x.span, - AstKind::Concat(ref x) => &x.span, + Ast::ClassBracketed(ref x) => &x.span, + Ast::Repetition(ref x) => &x.span, + Ast::Group(ref x) => &x.span, + Ast::Alternation(ref x) => &x.span, + Ast::Concat(ref x) => &x.span, }; self.increment_depth(span) } fn visit_post(&mut self, ast: &Ast) -> Result<()> { - match *ast.0 { - AstKind::Empty(_) - | AstKind::Flags(_) - | AstKind::Literal(_) - | AstKind::Dot(_) - | AstKind::Assertion(_) - | AstKind::ClassUnicode(_) - | AstKind::ClassPerl(_) => { + match *ast { + Ast::Empty(_) + | Ast::Flags(_) + | Ast::Literal(_) + | Ast::Dot(_) + | Ast::Assertion(_) + | Ast::ClassUnicode(_) + | Ast::ClassPerl(_) => { // These are all base cases, so we don't decrement depth. Ok(()) } - AstKind::ClassBracketed(_) - | AstKind::Repetition(_) - | AstKind::Group(_) - | AstKind::Alternation(_) - | AstKind::Concat(_) => { + Ast::ClassBracketed(_) + | Ast::Repetition(_) + | Ast::Group(_) + | Ast::Alternation(_) + | Ast::Concat(_) => { self.decrement_depth(); Ok(()) } diff --git a/regex-syntax/src/ast/print.rs b/regex-syntax/src/ast/print.rs index 10ee56c2c..7dedf7f48 100644 --- a/regex-syntax/src/ast/print.rs +++ b/regex-syntax/src/ast/print.rs @@ -7,7 +7,7 @@ use core::fmt; use crate::ast::{ self, visitor::{self, Visitor}, - Ast, AstKind, + Ast, }; /// A builder for constructing a printer. @@ -78,27 +78,27 @@ impl Visitor for Writer { } fn visit_pre(&mut self, ast: &Ast) -> fmt::Result { - match *ast.0 { - AstKind::Group(ref x) => self.fmt_group_pre(x), - AstKind::ClassBracketed(ref x) => self.fmt_class_bracketed_pre(x), + match *ast { + Ast::Group(ref x) => self.fmt_group_pre(x), + Ast::ClassBracketed(ref x) => self.fmt_class_bracketed_pre(x), _ => Ok(()), } } fn visit_post(&mut self, ast: &Ast) -> fmt::Result { - match *ast.0 { - AstKind::Empty(_) => Ok(()), - AstKind::Flags(ref x) => self.fmt_set_flags(x), - AstKind::Literal(ref x) => self.fmt_literal(x), - AstKind::Dot(_) => self.wtr.write_str("."), - AstKind::Assertion(ref x) => self.fmt_assertion(x), - AstKind::ClassPerl(ref x) => self.fmt_class_perl(x), - AstKind::ClassUnicode(ref x) => self.fmt_class_unicode(x), - AstKind::ClassBracketed(ref x) => self.fmt_class_bracketed_post(x), - AstKind::Repetition(ref x) => self.fmt_repetition(x), - AstKind::Group(ref x) => self.fmt_group_post(x), - AstKind::Alternation(_) => Ok(()), - AstKind::Concat(_) => Ok(()), + match *ast { + Ast::Empty(_) => Ok(()), + Ast::Flags(ref x) => self.fmt_set_flags(x), + Ast::Literal(ref x) => self.fmt_literal(x), + Ast::Dot(_) => self.wtr.write_str("."), + Ast::Assertion(ref x) => self.fmt_assertion(x), + Ast::ClassPerl(ref x) => self.fmt_class_perl(x), + Ast::ClassUnicode(ref x) => self.fmt_class_unicode(x), + Ast::ClassBracketed(ref x) => self.fmt_class_bracketed_post(x), + Ast::Repetition(ref x) => self.fmt_repetition(x), + Ast::Group(ref x) => self.fmt_group_post(x), + Ast::Alternation(_) => Ok(()), + Ast::Concat(_) => Ok(()), } } diff --git a/regex-syntax/src/ast/visitor.rs b/regex-syntax/src/ast/visitor.rs index 2bd4b1956..c1bb24d97 100644 --- a/regex-syntax/src/ast/visitor.rs +++ b/regex-syntax/src/ast/visitor.rs @@ -1,6 +1,6 @@ use alloc::{vec, vec::Vec}; -use crate::ast::{self, Ast, AstKind}; +use crate::ast::{self, Ast}; /// A trait for visiting an abstract syntax tree (AST) in depth first order. /// @@ -263,19 +263,19 @@ impl<'a> HeapVisitor<'a> { ast: &'a Ast, visitor: &mut V, ) -> Result>, V::Err> { - Ok(match *ast.0 { - AstKind::ClassBracketed(ref x) => { + Ok(match *ast { + Ast::ClassBracketed(ref x) => { self.visit_class(x, visitor)?; None } - AstKind::Repetition(ref x) => Some(Frame::Repetition(x)), - AstKind::Group(ref x) => Some(Frame::Group(x)), - AstKind::Concat(ref x) if x.asts.is_empty() => None, - AstKind::Concat(ref x) => { + Ast::Repetition(ref x) => Some(Frame::Repetition(x)), + Ast::Group(ref x) => Some(Frame::Group(x)), + Ast::Concat(ref x) if x.asts.is_empty() => None, + Ast::Concat(ref x) => { Some(Frame::Concat { head: &x.asts[0], tail: &x.asts[1..] }) } - AstKind::Alternation(ref x) if x.asts.is_empty() => None, - AstKind::Alternation(ref x) => Some(Frame::Alternation { + Ast::Alternation(ref x) if x.asts.is_empty() => None, + Ast::Alternation(ref x) => Some(Frame::Alternation { head: &x.asts[0], tail: &x.asts[1..], }), diff --git a/regex-syntax/src/hir/translate.rs b/regex-syntax/src/hir/translate.rs index ab3aa93d7..56d261aa1 100644 --- a/regex-syntax/src/hir/translate.rs +++ b/regex-syntax/src/hir/translate.rs @@ -7,7 +7,7 @@ use core::cell::{Cell, RefCell}; use alloc::{boxed::Box, string::ToString, vec, vec::Vec}; use crate::{ - ast::{self, Ast, AstKind, Span, Visitor}, + ast::{self, Ast, Span, Visitor}, either::Either, hir::{self, Error, ErrorKind, Hir, HirKind}, unicode::{self, ClassQuery}, @@ -336,8 +336,8 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { } fn visit_pre(&mut self, ast: &Ast) -> Result<()> { - match *ast.0 { - AstKind::ClassBracketed(_) => { + match *ast { + Ast::ClassBracketed(_) => { if self.flags().unicode() { let cls = hir::ClassUnicode::empty(); self.push(HirFrame::ClassUnicode(cls)); @@ -346,20 +346,20 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { self.push(HirFrame::ClassBytes(cls)); } } - AstKind::Repetition(_) => self.push(HirFrame::Repetition), - AstKind::Group(ref x) => { + Ast::Repetition(_) => self.push(HirFrame::Repetition), + Ast::Group(ref x) => { let old_flags = x .flags() .map(|ast| self.set_flags(ast)) .unwrap_or_else(|| self.flags()); self.push(HirFrame::Group { old_flags }); } - AstKind::Concat(ref x) if x.asts.is_empty() => {} - AstKind::Concat(_) => { + Ast::Concat(ref x) if x.asts.is_empty() => {} + Ast::Concat(_) => { self.push(HirFrame::Concat); } - AstKind::Alternation(ref x) if x.asts.is_empty() => {} - AstKind::Alternation(_) => { + Ast::Alternation(ref x) if x.asts.is_empty() => {} + Ast::Alternation(_) => { self.push(HirFrame::Alternation); self.push(HirFrame::AlternationBranch); } @@ -369,11 +369,11 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { } fn visit_post(&mut self, ast: &Ast) -> Result<()> { - match *ast.0 { - AstKind::Empty(_) => { + match *ast { + Ast::Empty(_) => { self.push(HirFrame::Expr(Hir::empty())); } - AstKind::Flags(ref x) => { + Ast::Flags(ref x) => { self.set_flags(&x.flags); // Flags in the AST are generally considered directives and // not actual sub-expressions. However, they can be used in @@ -386,7 +386,7 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { // consistency sake. self.push(HirFrame::Expr(Hir::empty())); } - AstKind::Literal(ref x) => match self.ast_literal_to_scalar(x)? { + Ast::Literal(ref x) => match self.ast_literal_to_scalar(x)? { Either::Right(byte) => self.push_byte(byte), Either::Left(ch) => { if !self.flags().unicode() && ch.len_utf8() > 1 { @@ -400,13 +400,13 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { } } }, - AstKind::Dot(ref span) => { + Ast::Dot(ref span) => { self.push(HirFrame::Expr(self.hir_dot(**span)?)); } - AstKind::Assertion(ref x) => { + Ast::Assertion(ref x) => { self.push(HirFrame::Expr(self.hir_assertion(x)?)); } - AstKind::ClassPerl(ref x) => { + Ast::ClassPerl(ref x) => { if self.flags().unicode() { let cls = self.hir_perl_unicode_class(x)?; let hcls = hir::Class::Unicode(cls); @@ -417,11 +417,11 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { self.push(HirFrame::Expr(Hir::class(hcls))); } } - AstKind::ClassUnicode(ref x) => { + Ast::ClassUnicode(ref x) => { let cls = hir::Class::Unicode(self.hir_unicode_class(x)?); self.push(HirFrame::Expr(Hir::class(cls))); } - AstKind::ClassBracketed(ref ast) => { + Ast::ClassBracketed(ref ast) => { if self.flags().unicode() { let mut cls = self.pop().unwrap().unwrap_class_unicode(); self.unicode_fold_and_negate( @@ -442,18 +442,18 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { self.push(HirFrame::Expr(expr)); } } - AstKind::Repetition(ref x) => { + Ast::Repetition(ref x) => { let expr = self.pop().unwrap().unwrap_expr(); self.pop().unwrap().unwrap_repetition(); self.push(HirFrame::Expr(self.hir_repetition(x, expr))); } - AstKind::Group(ref x) => { + Ast::Group(ref x) => { let expr = self.pop().unwrap().unwrap_expr(); let old_flags = self.pop().unwrap().unwrap_group(); self.trans().flags.set(old_flags); self.push(HirFrame::Expr(self.hir_capture(x, expr))); } - AstKind::Concat(_) => { + Ast::Concat(_) => { let mut exprs = vec![]; while let Some(expr) = self.pop_concat_expr() { if !matches!(*expr.kind(), HirKind::Empty) { @@ -463,7 +463,7 @@ impl<'t, 'p> Visitor for TranslatorI<'t, 'p> { exprs.reverse(); self.push(HirFrame::Expr(Hir::concat(exprs))); } - AstKind::Alternation(_) => { + Ast::Alternation(_) => { let mut exprs = vec![]; while let Some(expr) = self.pop_alt_expr() { self.pop().unwrap().unwrap_alternation_pipe();