mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-24 20:34:53 +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
|
@ -28,11 +28,11 @@ nodes_file = (
|
|||
.read_text()
|
||||
)
|
||||
node_lines = (
|
||||
nodes_file.split("pub enum AnyNode {")[1].split("}")[0].strip().splitlines()
|
||||
nodes_file.split("pub enum AnyNodeRef<'a> {")[1].split("}")[0].strip().splitlines()
|
||||
)
|
||||
nodes = []
|
||||
for node_line in node_lines:
|
||||
node = node_line.split("(")[1].split(")")[0].split("::")[-1].split("<")[0]
|
||||
node = node_line.split("(")[1].split(")")[0].split("::")[-1].removeprefix("&'a ")
|
||||
# `FString` has a custom implementation while the formatting for
|
||||
# `FStringLiteralElement`, `FStringFormatSpec` and `FStringExpressionElement` are handled by the `FString`
|
||||
# implementation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue