mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 20:42:10 +00:00
upgrade rustpython to remove tuple-constants (#5840)
c.f. https://github.com/astral-sh/RustPython-Parser/pull/28 Tests: No snapshots changed --------- Co-authored-by: Zanie <contact@zanie.dev>
This commit is contained in:
parent
e574a6a769
commit
52aa2fc875
13 changed files with 131 additions and 206 deletions
|
@ -3,8 +3,8 @@
|
|||
pub mod preorder;
|
||||
|
||||
use rustpython_parser::ast::{
|
||||
self, Alias, Arg, Arguments, BoolOp, CmpOp, Comprehension, Constant, Decorator, ExceptHandler,
|
||||
Expr, ExprContext, Keyword, MatchCase, Operator, Pattern, Stmt, UnaryOp, WithItem,
|
||||
self, Alias, Arg, Arguments, BoolOp, CmpOp, Comprehension, Decorator, ExceptHandler, Expr,
|
||||
ExprContext, Keyword, MatchCase, Operator, Pattern, Stmt, UnaryOp, WithItem,
|
||||
};
|
||||
|
||||
/// A trait for AST visitors. Visits all nodes in the AST recursively in evaluation-order.
|
||||
|
@ -27,9 +27,6 @@ pub trait Visitor<'a> {
|
|||
fn visit_expr(&mut self, expr: &'a Expr) {
|
||||
walk_expr(self, expr);
|
||||
}
|
||||
fn visit_constant(&mut self, constant: &'a Constant) {
|
||||
walk_constant(self, constant);
|
||||
}
|
||||
fn visit_expr_context(&mut self, expr_context: &'a ExprContext) {
|
||||
walk_expr_context(self, expr_context);
|
||||
}
|
||||
|
@ -507,7 +504,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) {
|
|||
visitor.visit_expr(expr);
|
||||
}
|
||||
}
|
||||
Expr::Constant(ast::ExprConstant { value, .. }) => visitor.visit_constant(value),
|
||||
Expr::Constant(_) => {}
|
||||
Expr::Attribute(ast::ExprAttribute { value, ctx, .. }) => {
|
||||
visitor.visit_expr(value);
|
||||
visitor.visit_expr_context(ctx);
|
||||
|
@ -572,14 +569,6 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_constant<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, constant: &'a Constant) {
|
||||
if let Constant::Tuple(constants) = constant {
|
||||
for constant in constants {
|
||||
visitor.visit_constant(constant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_comprehension<'a, V: Visitor<'a> + ?Sized>(
|
||||
visitor: &mut V,
|
||||
comprehension: &'a Comprehension,
|
||||
|
@ -675,12 +664,7 @@ pub fn walk_pattern<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, pattern: &'a P
|
|||
value,
|
||||
range: _range,
|
||||
}) => visitor.visit_expr(value),
|
||||
Pattern::MatchSingleton(ast::PatternMatchSingleton {
|
||||
value,
|
||||
range: _range,
|
||||
}) => {
|
||||
visitor.visit_constant(value);
|
||||
}
|
||||
Pattern::MatchSingleton(_) => {}
|
||||
Pattern::MatchSequence(ast::PatternMatchSequence {
|
||||
patterns,
|
||||
range: _range,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue