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:
Douglas Creager 2025-01-17 17:11:00 -05:00 committed by GitHub
parent 8e3633f55a
commit 98ef564170
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 52 additions and 5349 deletions

View file

@ -1,5 +1,4 @@
use ruff_formatter::{format_args, write};
use ruff_python_ast::AstNode;
use ruff_python_ast::{Stmt, StmtWhile};
use ruff_text_size::Ranged;
@ -22,7 +21,7 @@ impl FormatNodeRule<StmtWhile> for FormatStmtWhile {
} = item;
let comments = f.context().comments().clone();
let dangling_comments = comments.dangling(item.as_any_node_ref());
let dangling_comments = comments.dangling(item);
let body_start = body.first().map_or(test.end(), Stmt::start);
let or_else_comments_start =