From 3d4a278f2ec2880bf82d3b0934938e57be928cad Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 22 Mar 2023 10:19:30 +0800 Subject: [PATCH] Remove ASTFlags::EMPTY. --- src/ast/expr.rs | 6 +++--- src/ast/flags.rs | 2 -- src/ast/stmt.rs | 6 +++--- src/parser.rs | 18 +++++++++--------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/ast/expr.rs b/src/ast/expr.rs index 6add6903..2f96af59 100644 --- a/src/ast/expr.rs +++ b/src/ast/expr.rs @@ -620,7 +620,7 @@ impl Expr { Self::Index(_, options, _) | Self::Dot(_, options, _) => *options, #[cfg(not(feature = "no_float"))] - Self::FloatConstant(..) => ASTFlags::NONE, + Self::FloatConstant(..) => ASTFlags::empty(), Self::DynamicConstant(..) | Self::BoolConstant(..) @@ -638,10 +638,10 @@ impl Expr { | Self::MethodCall(..) | Self::InterpolatedString(..) | Self::Property(..) - | Self::Stmt(..) => ASTFlags::NONE, + | Self::Stmt(..) => ASTFlags::empty(), #[cfg(not(feature = "no_custom_syntax"))] - Self::Custom(..) => ASTFlags::NONE, + Self::Custom(..) => ASTFlags::empty(), } } /// Get the [position][Position] of the expression. diff --git a/src/ast/flags.rs b/src/ast/flags.rs index 7085ee54..f58eae68 100644 --- a/src/ast/flags.rs +++ b/src/ast/flags.rs @@ -41,8 +41,6 @@ bitflags! { /// _(internals)_ Bit-flags containing [`AST`][crate::AST] node configuration options. /// Exported under the `internals` feature only. pub struct ASTFlags: u8 { - /// No options for the [`AST`][crate::AST] node. - const NONE = 0b_0000_0000; /// The [`AST`][crate::AST] node is read-only. const CONSTANT = 0b_0000_0001; /// The [`AST`][crate::AST] node is exposed to the outside (i.e. public). diff --git a/src/ast/stmt.rs b/src/ast/stmt.rs index 9c67bcab..8487c4fb 100644 --- a/src/ast/stmt.rs +++ b/src/ast/stmt.rs @@ -779,13 +779,13 @@ impl Stmt { | Self::While(..) | Self::For(..) | Self::TryCatch(..) - | Self::Assignment(..) => ASTFlags::NONE, + | Self::Assignment(..) => ASTFlags::empty(), #[cfg(not(feature = "no_module"))] - Self::Import(..) | Self::Export(..) => ASTFlags::NONE, + Self::Import(..) | Self::Export(..) => ASTFlags::empty(), #[cfg(not(feature = "no_closure"))] - Self::Share(..) => ASTFlags::NONE, + Self::Share(..) => ASTFlags::empty(), } } /// Get the [position][Position] of this statement. diff --git a/src/parser.rs b/src/parser.rs index cbe69827..87e70e18 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -864,7 +864,7 @@ impl Engine { let settings = settings.level_up()?; // Recursively parse the indexing chain, right-binding each let options = match token { - Token::LeftBracket => ASTFlags::NONE, + Token::LeftBracket => ASTFlags::empty(), Token::QuestionBracket => ASTFlags::NEGATED, _ => unreachable!("`[` or `?[`"), }; @@ -1810,7 +1810,7 @@ impl Engine { #[cfg(not(feature = "no_index"))] (expr, token @ (Token::LeftBracket | Token::QuestionBracket)) => { let opt = match token { - Token::LeftBracket => ASTFlags::NONE, + Token::LeftBracket => ASTFlags::empty(), Token::QuestionBracket => ASTFlags::NEGATED, _ => unreachable!("`[` or `?[`"), }; @@ -1834,7 +1834,7 @@ impl Engine { } let op_flags = match op { - Token::Period => ASTFlags::NONE, + Token::Period => ASTFlags::empty(), Token::Elvis => ASTFlags::NEGATED, _ => unreachable!("`.` or `?.`"), }; @@ -1842,7 +1842,7 @@ impl Engine { let rhs = self.parse_primary(input, state, lib, settings.level_up()?, options)?; - Self::make_dot_expr(state, expr, rhs, ASTFlags::NONE, op_flags, tail_pos)? + Self::make_dot_expr(state, expr, rhs, ASTFlags::empty(), op_flags, tail_pos)? } // Unknown postfix operator (expr, token) => { @@ -2141,7 +2141,7 @@ impl Engine { { let options = options | parent_options; x.rhs = Self::make_dot_expr(state, x.rhs, rhs, options, op_flags, op_pos)?; - Ok(Expr::Index(x, ASTFlags::NONE, pos)) + Ok(Expr::Index(x, ASTFlags::empty(), pos)) } // lhs.module::id - syntax error #[cfg(not(feature = "no_module"))] @@ -2770,7 +2770,7 @@ impl Engine { let body = self.parse_block(input, state, lib, settings)?.into(); let negated = match input.next().expect(NEVER_ENDS) { - (Token::While, ..) => ASTFlags::NONE, + (Token::While, ..) => ASTFlags::empty(), (Token::Until, ..) => ASTFlags::NEGATED, (.., pos) => { return Err( @@ -2966,7 +2966,7 @@ impl Engine { let export = if is_export { ASTFlags::EXPORTED } else { - ASTFlags::NONE + ASTFlags::empty() }; let (existing, hit_barrier) = state.find_var(&name); @@ -3433,7 +3433,7 @@ impl Engine { if self.allow_looping() && settings.has_flag(ParseSettingFlags::BREAKABLE) => { let pos = eat_token(input, Token::Continue); - Ok(Stmt::BreakLoop(None, ASTFlags::NONE, pos)) + Ok(Stmt::BreakLoop(None, ASTFlags::empty(), pos)) } Token::Break if self.allow_looping() && settings.has_flag(ParseSettingFlags::BREAKABLE) => @@ -3465,7 +3465,7 @@ impl Engine { .next() .map(|(token, pos)| { let flags = match token { - Token::Return => ASTFlags::NONE, + Token::Return => ASTFlags::empty(), Token::Throw => ASTFlags::BREAK, token => unreachable!( "Token::Return or Token::Throw expected but gets {:?}",