mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Remove AstNode
and AnyNode
(#15479)
While looking into potential AST optimizations, I noticed the `AstNode` trait and `AnyNode` type aren't used anywhere in Ruff or Red Knot. It looks like they might be historical artifacts of previous ways of consuming AST nodes? - `AstNode::cast`, `AstNode::cast_ref`, and `AstNode::can_cast` are not used anywhere. - Since `cast_ref` isn't needed anymore, the `Ref` associated type isn't either. This is a pure refactoring, with no intended behavior changes.
This commit is contained in:
parent
8e3633f55a
commit
98ef564170
24 changed files with 52 additions and 5349 deletions
|
@ -1,6 +1,5 @@
|
|||
use ruff_formatter::{format_args, write, FormatRuleWithOptions};
|
||||
use ruff_python_ast::Parameters;
|
||||
use ruff_python_ast::{AnyNodeRef, AstNode};
|
||||
use ruff_python_ast::{AnyNodeRef, Parameters};
|
||||
use ruff_python_trivia::{CommentLinePosition, SimpleToken, SimpleTokenKind, SimpleTokenizer};
|
||||
use ruff_text_size::{Ranged, TextRange, TextSize};
|
||||
|
||||
|
@ -165,7 +164,7 @@ impl FormatNodeRule<Parameters> for FormatParameters {
|
|||
token("*"),
|
||||
vararg.format()
|
||||
]);
|
||||
last_node = Some(vararg.as_any_node_ref());
|
||||
last_node = Some(vararg.as_ref().into());
|
||||
} else if !kwonlyargs.is_empty() {
|
||||
// Given very strange comment placement, comments here may not actually have been
|
||||
// marked as `StarLeading`/`StarTrailing`, but that's fine since we still produce
|
||||
|
@ -201,7 +200,7 @@ impl FormatNodeRule<Parameters> for FormatParameters {
|
|||
token("**"),
|
||||
kwarg.format()
|
||||
]);
|
||||
last_node = Some(kwarg.as_any_node_ref());
|
||||
last_node = Some(kwarg.as_ref().into());
|
||||
}
|
||||
|
||||
joiner.finish()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue