diff --git a/Cargo.lock b/Cargo.lock index 79580e37b0..c0b8576857 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2917,6 +2917,7 @@ dependencies = [ "itertools 0.14.0", "memchr", "ruff_cache", + "ruff_index", "ruff_macros", "ruff_python_trivia", "ruff_source_file", diff --git a/crates/ruff_db/src/parsed.rs b/crates/ruff_db/src/parsed.rs index e93d5e5517..217cdb30d5 100644 --- a/crates/ruff_db/src/parsed.rs +++ b/crates/ruff_db/src/parsed.rs @@ -2,7 +2,7 @@ use std::fmt::Formatter; use std::ops::Deref; use std::sync::Arc; -use ruff_python_ast::{ModModule, PySourceType}; +use ruff_python_ast::{ModModuleId, PySourceType}; use ruff_python_parser::{parse_unchecked_source, Parsed}; use crate::files::{File, FilePath}; @@ -43,24 +43,24 @@ pub fn parsed_module(db: &dyn Db, file: File) -> ParsedModule { /// Cheap cloneable wrapper around the parsed module. #[derive(Clone)] pub struct ParsedModule { - inner: Arc>, + inner: Arc>, } impl ParsedModule { - pub fn new(parsed: Parsed) -> Self { + pub fn new(parsed: Parsed) -> Self { Self { inner: Arc::new(parsed), } } /// Consumes `self` and returns the Arc storing the parsed module. - pub fn into_arc(self) -> Arc> { + pub fn into_arc(self) -> Arc> { self.inner } } impl Deref for ParsedModule { - type Target = Parsed; + type Target = Parsed; fn deref(&self) -> &Self::Target { &self.inner diff --git a/crates/ruff_macros/src/ast_node.rs b/crates/ruff_macros/src/ast_node.rs new file mode 100644 index 0000000000..f383b87a46 --- /dev/null +++ b/crates/ruff_macros/src/ast_node.rs @@ -0,0 +1,321 @@ +use heck::ToSnakeCase; +use proc_macro2::TokenStream; +use quote::quote; +use syn::spanned::Spanned; +use syn::{Attribute, Error, Fields, Ident, ItemEnum, Result, Type, Variant}; + +pub(crate) fn generate_ast_enum(input: ItemEnum) -> Result { + let ast_enum = AstEnum::new(input)?; + let id_enum = generate_id_enum(&ast_enum); + let node_enum = generate_node_enum(&ast_enum); + let node_enum_node_method = generate_node_enum_node_method(&ast_enum); + let node_enum_ranged_impl = generate_node_enum_ranged_impl(&ast_enum); + let variant_ids = generate_variant_ids(&ast_enum); + let storage = generate_storage(&ast_enum); + Ok(quote! { + #id_enum + #node_enum + #node_enum_node_method + #node_enum_ranged_impl + #variant_ids + #storage + }) +} + +fn snake_case(node_ident: &Ident) -> Ident { + let node_string = node_ident.to_string().to_snake_case(); + Ident::new(&node_string, node_ident.span()) +} + +fn concat(prefix: &str, id: &Ident, suffix: &str) -> Ident { + let mut id_string = id.to_string(); + id_string.insert_str(0, prefix); + id_string.push_str(suffix); + Ident::new(&id_string, id.span()) +} + +/// Describes one of the enums that holds syntax nodes (e.g. Mod, Stmt) +struct AstEnum { + /// The base name of the enums (e.g. Mod, Stmt) + base_enum_name: Ident, + /// The syntax node variants for this enum + variants: Vec, +} + +/// Describes one specific syntax node (e.g. ModExpression, StmtIf) +struct AstVariant { + /// The name of the variant within its containing enum (e.g. Expression, If) + variant_name: Ident, + /// The struct type defining the contents of this syntax node (e.g. ModExpression, StmtIf) + node_ty: Ident, + /// All of the attributes attached to this variant + attrs: Vec, +} + +impl AstEnum { + fn new(input: ItemEnum) -> Result { + let base_enum_name = input.ident; + let variants: Result> = input.variants.into_iter().map(AstVariant::new).collect(); + let variants = variants?; + Ok(AstEnum { + base_enum_name, + variants, + }) + } + + fn map_variants<'a, B, F>(&'a self, f: F) -> impl Iterator + 'a + where + F: FnMut(&AstVariant) -> B + 'a, + { + self.variants.iter().map(f) + } + + /// The name of the enum containing syntax node IDs (e.g. ModId, StmtId) + fn id_enum_ty(&self) -> Ident { + concat("", &self.base_enum_name, "Id") + } + + /// The name of the enum containing references to syntax nodes (e.g. ModRef, StmtRef) + fn ref_enum_ty(&self) -> Ident { + concat("", &self.base_enum_name, "Ref") + } + + /// The name of the storage type for this enum (e.g. ModStorage) + fn enum_storage_ty(&self) -> Ident { + concat("", &self.base_enum_name, "Storage") + } + + /// The name of the storage field in Ast (e.g. mod_storage) + fn enum_storage_field(&self) -> Ident { + snake_case(&self.enum_storage_ty()) + } +} + +impl AstVariant { + fn new(variant: Variant) -> Result { + let Fields::Unnamed(fields) = &variant.fields else { + return Err(Error::new( + variant.fields.span(), + "Each AstNode variant must have a single unnamed field", + )); + }; + let mut fields = fields.unnamed.iter(); + let field = fields.next().ok_or_else(|| { + Error::new( + variant.fields.span(), + "Each AstNode variant must have a single unnamed field", + ) + })?; + if fields.next().is_some() { + return Err(Error::new( + variant.fields.span(), + "Each AstNode variant must have a single unnamed field", + )); + } + let Type::Path(field_ty) = &field.ty else { + return Err(Error::new( + field.ty.span(), + "Each AstNode variant must wrap a simple Id type", + )); + }; + let node_ty = field_ty.path.require_ident()?.clone(); + Ok(AstVariant { + variant_name: variant.ident, + node_ty, + attrs: variant.attrs, + }) + } + + /// The name of the ID type for this variant's syntax node (e.g. ModExpressionId, StmtIfId) + fn id_ty(&self) -> Ident { + concat("", &self.node_ty, "Id") + } + + /// The name of the storage field in the containing enum storage type (e.g. + /// mod_expression_storage) + fn variant_storage_field(&self) -> Ident { + concat("", &snake_case(&self.node_ty), "_storage") + } + + /// The name of the method that adds a new syntax node to an [Ast] (e.g. `add_mod_expression`) +} + +/// Generates the enum containing syntax node IDs (e.g. ModId, StmtId) +fn generate_id_enum(ast_enum: &AstEnum) -> TokenStream { + let id_enum_ty = ast_enum.id_enum_ty(); + let id_enum_variants = ast_enum.map_variants(|v| { + let AstVariant { + variant_name, + attrs, + .. + } = v; + let id_ty = v.id_ty(); + quote! { + #( #attrs )* + #variant_name(#id_ty) + } + }); + quote! { + #[automatically_derived] + #[derive(Copy, Clone, Debug, PartialEq, is_macro::Is)] + pub enum #id_enum_ty { + #( #id_enum_variants ),* + } + } +} + +fn generate_ref_enum(ast_enum: &AstEnum) -> TokenStream { + let ref_enum_ty = ast_enum.ref_enum_ty(); + let variants = ast_enum.map_variants(|v| { + let AstVariant { + attrs, + variant_name, + node_ty, + .. + } = v; + quote! { + #( #attrs )* + #variant_name(crate::Node<'a, &'a #node_ty>) + } + }); + quote! { + #[automatically_derived] + #[derive(Copy, Clone, Debug, PartialEq, is_macro::Is)] + pub enum #node_ident<'a> { + #( #variants ),* + } + } +} + +fn generate_node_enum_node_method(ast_enum: &AstEnum) -> TokenStream { + let id_enum_ty = ast_enum.id_enum_ty(); + let ref_enum_ty = ast_enum.ref_enum_ty(); + let variants = ast_enum.map_variants(|v| { + let AstVariant { variant_name, .. } = v; + quote! { #id_enum_ty::#variant_name(id) => #ref_enum_ty::#variant_name(self.ast.wrap(&self.ast[id])) } + }); + quote! { + #[automatically_derived] + impl<'a> crate::Node<'a, #id_enum_ty> { + #[inline] + pub fn node(&self) -> #ref_enum_ty<'a> { + match self.node { + #( #variants ),* + } + } + } + } +} + +fn generate_node_enum_ranged_impl(ast_enum: &AstEnum) -> TokenStream { + let ref_enum_ty = ast_enum.ref_enum_ty(); + let variants = ast_enum.map_variants(|v| { + let AstVariant { variant_name, .. } = v; + quote! { #ref_enum_ty::#variant_name(node) => node.range() } + }); + quote! { + #[automatically_derived] + impl ruff_text_size::Ranged for #ref_enum_ty<'_> { + fn range(&self) -> ruff_text_size::TextRange { + match self { + #( #variants ),* + } + } + } + } +} + +/// Generates the ID type for each syntax node struct in this enum. +/// +/// We also define: +/// - [Index] and [IndexMut] impls so that you can index into an [Ast] using the ID type +/// - a `node` method on e.g. `Node` that returns a `Node<&StmtIf>` +/// - [Ranged] impls for the `StmtIf` and `Node<&StmtIf>` +fn generate_ids(ast_enum: &AstEnum) -> TokenStream { + let id_enum_ty = ast_enum.id_enum_ty(); + let enum_storage_field = ast_enum.enum_storage_field(); + let variants = ast_enum.map_variants(|v| { + let AstVariant { node_ty, .. } = v; + let id_ty = v.id_ty(); + let variant_storage_field = v.variant_storage_field(); + quote! { + #[automatically_derived] + #[ruff_index::newtype_index] + pub struct #id_ty; + + #[automatically_derived] + impl std::ops::Index<#id_ty> for crate::Ast { + type Output = #node_ty; + #[inline] + fn index(&self, id: #id_ty) -> &#node_ty { + &self.#enum_storage_field.#variant_storage_field[id] + } + } + + #[automatically_derived] + impl std::ops::IndexMut<#id_ty> for crate::Ast { + #[inline] + fn index_mut(&mut self, id: #id_ty) -> &mut #node_ty { + &mut self.#enum_storage_field.#variant_storage_field[id] + } + } + + #[automatically_derived] + impl<'a> crate::Node<'a, #id_ty> { + #[inline] + pub fn node(&self) -> crate::Node<'a, &'a #node_ty> { + self.ast.wrap(&self.ast[self.node]) + } + } + + #[automatically_derived] + impl<'a> ruff_text_size::Ranged for #node_ty { + fn range(&self) -> TextRange { + self.range + } + } + + #[automatically_derived] + impl<'a> ruff_text_size::Ranged for crate::Node<'a, &'a #node_ty> { + fn range(&self) -> TextRange { + self.as_ref().range() + } + } + } + }); + quote! { #( #variants )* } +} + +fn generate_storage(ast_enum: &AstEnum) -> TokenStream { + let id_enum_ty = ast_enum.id_enum_ty(); + let enum_storage_ty = ast_enum.enum_storage_ty(); + let enum_storage_field = ast_enum.enum_storage_field(); + let storage_fields = ast_enum.map_variants(|v| { + let AstVariant { id_ty, node_ty, .. } = v; + let variant_storage_field = v.variant_storage_field(); + quote! { #variant_storage_field: ruff_index::IndexVec<#id_ty, #node_ty> } + }); + let add_methods = ast_enum.map_variants(|v| { + let AstVariant { node_ty, .. } = v; + let variant_storage_field = v.variant_storage_field(); + let method_name = concat("add_", vec_name, ""); + quote! { + #[automatically_derived] + impl crate::Ast { + pub fn #method_name(&mut self, payload: #node_ty) -> #id_ident { + #id_ident::#variant_name(self.#storage_field.#vec_name.push(payload)) + } + } + } + }); + quote! { + #[automatically_derived] + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, Default, PartialEq)] + pub(crate) struct #storage_ty { + #( #storage_fields ),* + } + + #( #add_methods )* + } +} diff --git a/crates/ruff_python_ast/Cargo.toml b/crates/ruff_python_ast/Cargo.toml index f923773b93..096eebed55 100644 --- a/crates/ruff_python_ast/Cargo.toml +++ b/crates/ruff_python_ast/Cargo.toml @@ -14,6 +14,7 @@ license = { workspace = true } [dependencies] ruff_cache = { workspace = true, optional = true } +ruff_index = { workspace = true } ruff_macros = { workspace = true, optional = true } ruff_python_trivia = { workspace = true } ruff_source_file = { workspace = true } diff --git a/crates/ruff_python_ast/generate.py b/crates/ruff_python_ast/generate.py index c317bae3bb..74a5a607f8 100644 --- a/crates/ruff_python_ast/generate.py +++ b/crates/ruff_python_ast/generate.py @@ -67,6 +67,7 @@ class Ast: class Group: name: str nodes: list[Node] + id_enum_ty: str owned_enum_ty: str add_suffix_to_is_methods: bool @@ -75,6 +76,7 @@ class Group: def __init__(self, group_name: str, group: dict[str, Any]) -> None: self.name = group_name + self.id_enum_ty = group_name + "Id" self.owned_enum_ty = group_name self.ref_enum_ty = group_name + "Ref" self.add_suffix_to_is_methods = group.get("add_suffix_to_is_methods", False) @@ -89,12 +91,16 @@ class Group: class Node: name: str variant: str + id_ty: str ty: str + storage_field: str def __init__(self, group: Group, node_name: str, node: dict[str, Any]) -> None: self.name = node_name self.variant = node.get("variant", node_name.removeprefix(group.name)) + self.id_ty = node_name + "Id" self.ty = f"crate::{node_name}" + self.storage_field = to_snake_case(node_name) # ------------------------------------------------------------------------------ @@ -108,6 +114,75 @@ def write_preamble(out: list[str]) -> None: """) +# ------------------------------------------------------------------------------ +# ID enum + + +def write_ids(out: list[str], ast: Ast) -> None: + """ + Create an ID type for each syntax node, and a per-group enum that contains a + syntax node ID. + + ```rust + #[newindex_type] + pub struct TypeParamTypeVarId; + #[newindex_type] + pub struct TypeParamTypeVarTuple; + ... + + pub enum TypeParamId { + TypeVar(TypeParamTypeVarId), + TypeVarTuple(TypeParamTypeVarTupleId), + ... + } + ``` + + Also creates: + - `impl From for TypeParamId` + - `impl Ranged for TypeParamTypeVar` + - `fn TypeParamId::is_type_var() -> bool` + + If the `add_suffix_to_is_methods` group option is true, then the + `is_type_var` method will be named `is_type_var_type_param`. + """ + + for node in ast.all_nodes: + out.append("") + out.append("#[ruff_index::newtype_index]") + out.append(f"pub struct {node.id_ty};") + + out.append(f""" + impl ruff_text_size::Ranged for {node.ty} {{ + fn range(&self) -> ruff_text_size::TextRange {{ + self.range + }} + }} + """) + + for group in ast.groups: + out.append("") + if group.rustdoc is not None: + out.append(group.rustdoc) + out.append("#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)]") + out.append(f"pub enum {group.id_enum_ty} {{") + for node in group.nodes: + if group.add_suffix_to_is_methods: + is_name = to_snake_case(node.variant + group.name) + out.append(f'#[is(name = "{is_name}")]') + out.append(f"{node.variant}({node.id_ty}),") + out.append("}") + + for node in group.nodes: + out.append(f""" + impl From<{node.id_ty}> for {group.id_enum_ty} {{ + fn from(id: {node.id_ty}) -> Self {{ + Self::{node.variant}(id) + }} + }} + """) + + + # ------------------------------------------------------------------------------ # Owned enum @@ -126,7 +201,6 @@ def write_owned_enum(out: list[str], ast: Ast) -> None: Also creates: - `impl Ranged for TypeParam` - - `TypeParam::visit_source_order` - `impl From for TypeParam` - `impl Ranged for TypeParamTypeVar` - `fn TypeParam::is_type_var() -> bool` @@ -170,15 +244,6 @@ def write_owned_enum(out: list[str], ast: Ast) -> None: } """) - for node in ast.all_nodes: - out.append(f""" - impl ruff_text_size::Ranged for {node.ty} {{ - fn range(&self) -> ruff_text_size::TextRange {{ - self.range - }} - }} - """) - for group in ast.groups: out.append(f""" impl {group.owned_enum_ty} {{ @@ -210,17 +275,18 @@ def write_ref_enum(out: list[str], ast: Ast) -> None: ```rust pub enum TypeParamRef<'a> { - TypeVar(&'a TypeParamTypeVar), - TypeVarTuple(&'a TypeParamTypeVarTuple), + TypeVar(Node<'a, &'a TypeParamTypeVar>), + TypeVarTuple(Node<'a, &'a TypeParamTypeVarTuple>), ... } ``` Also creates: - - `impl<'a> From<&'a TypeParam> for TypeParamRef<'a>` - - `impl<'a> From<&'a TypeParamTypeVar> for TypeParamRef<'a>` + - `impl<'a> From> for TypeParamRef<'a>` + - `impl<'a> From> for TypeParamRef<'a>` - `impl Ranged for TypeParamRef<'_>` - `fn TypeParamRef::is_type_var() -> bool` + - `TypeParamRef::visit_source_order` The name of each variant can be customized via the `variant` node option. If the `add_suffix_to_is_methods` group option is true, then the `is_type_var` @@ -237,17 +303,17 @@ def write_ref_enum(out: list[str], ast: Ast) -> None: if group.add_suffix_to_is_methods: is_name = to_snake_case(node.variant + group.name) out.append(f'#[is(name = "{is_name}")]') - out.append(f"""{node.variant}(&'a {node.ty}),""") + out.append(f"""{node.variant}(crate::Node<'a, &'a {node.ty}>),""") out.append("}") out.append(f""" - impl<'a> From<&'a {group.owned_enum_ty}> for {group.ref_enum_ty}<'a> {{ - fn from(node: &'a {group.owned_enum_ty}) -> Self {{ - match node {{ + impl<'a> From> for {group.ref_enum_ty}<'a> {{ + fn from(node: crate::Node<'a, &'a {group.owned_enum_ty}>) -> Self {{ + match node.node {{ """) for node in group.nodes: out.append( - f"{group.owned_enum_ty}::{node.variant}(node) => {group.ref_enum_ty}::{node.variant}(node)," + f"""{group.owned_enum_ty}::{node.variant}(n) => {group.ref_enum_ty}::{node.variant}(node.ast.wrap(n)),""" ) out.append(""" } @@ -257,8 +323,8 @@ def write_ref_enum(out: list[str], ast: Ast) -> None: for node in group.nodes: out.append(f""" - impl<'a> From<&'a {node.ty}> for {group.ref_enum_ty}<'a> {{ - fn from(node: &'a {node.ty}) -> Self {{ + impl<'a> From> for {group.ref_enum_ty}<'a> {{ + fn from(node: crate::Node<'a, &'a {node.ty}>) -> Self {{ Self::{node.variant}(node) }} }} @@ -277,6 +343,112 @@ def write_ref_enum(out: list[str], ast: Ast) -> None: } """) + for group in ast.groups: + out.append(f""" + impl<'a> {group.ref_enum_ty}<'a> {{ + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + {{ + match self {{ + """) + for node in group.nodes: + out.append( + f"""{group.ref_enum_ty}::{node.variant}(node) => node.visit_source_order(visitor),""" + ) + out.append(""" + } + } + } + """) + + +# ------------------------------------------------------------------------------ +# AST storage + + +def write_storage(out: list[str], ast: Ast) -> None: + """ + Create the storage struct for all of the syntax nodes. + + ```rust + pub(crate) struct Storage { + ... + pub(crate) type_param_type_var_id: IndexVec, + pub(crate) type_param_type_var_tuple_id: IndexVec, + ... + } + ``` + + Also creates: + - `impl AstId for TypeParamTypeVarId for Ast` + - `impl AstIdMut for TypeParamTypeVarId for Ast` + """ + + out.append("") + out.append("#[derive(Clone, Default, PartialEq)]") + out.append("pub(crate) struct Storage {") + for node in ast.all_nodes: + out.append(f"""pub(crate) {node.storage_field}: ruff_index::IndexVec<{node.id_ty}, {node.ty}>,""") + out.append("}") + + for node in ast.all_nodes: + out.append(f""" + impl crate::ast::AstId for {node.id_ty} {{ + type Output<'a> = crate::Node<'a, &'a {node.ty}>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> {{ + ast.wrap(&ast.storage.{node.storage_field}[self]) + }} + }} + """) + + out.append(f""" + impl crate::ast::AstIdMut for {node.id_ty} {{ + type Output<'a> = crate::Node<'a, &'a mut {node.ty}>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> {{ + ast.wrap(&mut ast.storage.{node.storage_field}[self]) + }} + }} + """) + + out.append(f""" + impl<'a> crate::Node<'a, {node.id_ty}> {{ + #[inline] + pub fn node(self) -> crate::Node<'a, &'a {node.ty}> {{ + self.ast.node(self.node) + }} + }} + """) + + for group in ast.groups: + out.append(f""" + impl crate::ast::AstId for {group.id_enum_ty} {{ + type Output<'a> = {group.ref_enum_ty}<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> {{ + match self {{ + """) + for node in group.nodes: + out.append(f"""{group.id_enum_ty}::{node.variant}(node) => {group.ref_enum_ty}::{node.variant}(ast.node(node)),""") + out.append(f""" + }} + }} + }} + """) + + out.append(f""" + impl<'a> crate::Node<'a, {group.id_enum_ty}> {{ + #[inline] + pub fn node(self) -> crate::Node<'a, &'a {node.ty}> {{ + self.ast.node(self.node) + }} + }} + """) + + # ------------------------------------------------------------------------------ # AnyNodeRef @@ -289,16 +461,16 @@ def write_anynoderef(out: list[str], ast: Ast) -> None: ```rust pub enum AnyNodeRef<'a> { ... - TypeParamTypeVar(&'a TypeParamTypeVar), - TypeParamTypeVarTuple(&'a TypeParamTypeVarTuple), + TypeParamTypeVar(Node<'a, &'a TypeParamTypeVar>), + TypeParamTypeVarTuple(Node<'a, &'a TypeParamTypeVarTuple>), ... } ``` Also creates: - - `impl<'a> From<&'a TypeParam> for AnyNodeRef<'a>` - `impl<'a> From> for AnyNodeRef<'a>` - - `impl<'a> From<&'a TypeParamTypeVarTuple> for AnyNodeRef<'a>` + - `impl<'a> From> for AnyNodeRef<'a>` + - `impl<'a> From> for AnyNodeRef<'a>` - `impl Ranged for AnyNodeRef<'_>` - `fn AnyNodeRef::as_ptr(&self) -> std::ptr::NonNull<()>` - `fn AnyNodeRef::visit_preorder(self, visitor &mut impl SourceOrderVisitor)` @@ -309,20 +481,20 @@ def write_anynoderef(out: list[str], ast: Ast) -> None: pub enum AnyNodeRef<'a> { """) for node in ast.all_nodes: - out.append(f"""{node.name}(&'a {node.ty}),""") + out.append(f"""{node.name}(crate::Node<'a, &'a {node.ty}>),""") out.append(""" } """) for group in ast.groups: out.append(f""" - impl<'a> From<&'a {group.owned_enum_ty}> for AnyNodeRef<'a> {{ - fn from(node: &'a {group.owned_enum_ty}) -> AnyNodeRef<'a> {{ - match node {{ + impl<'a> From> for AnyNodeRef<'a> {{ + fn from(node: crate::Node<'a, &'a {group.owned_enum_ty}>) -> AnyNodeRef<'a> {{ + match node.node {{ """) for node in group.nodes: out.append( - f"{group.owned_enum_ty}::{node.variant}(node) => AnyNodeRef::{node.name}(node)," + f"{group.owned_enum_ty}::{node.variant}(n) => AnyNodeRef::{node.name}(node.ast.wrap(n))," ) out.append(""" } @@ -347,8 +519,8 @@ def write_anynoderef(out: list[str], ast: Ast) -> None: for node in ast.all_nodes: out.append(f""" - impl<'a> From<&'a {node.ty}> for AnyNodeRef<'a> {{ - fn from(node: &'a {node.ty}) -> AnyNodeRef<'a> {{ + impl<'a> From> for AnyNodeRef<'a> {{ + fn from(node: crate::Node<'a, &'a {node.ty}>) -> AnyNodeRef<'a> {{ AnyNodeRef::{node.name}(node) }} }} @@ -374,7 +546,7 @@ def write_anynoderef(out: list[str], ast: Ast) -> None: """) for node in ast.all_nodes: out.append( - f"AnyNodeRef::{node.name}(node) => std::ptr::NonNull::from(*node).cast()," + f"AnyNodeRef::{node.name}(node) => std::ptr::NonNull::from(node.as_ref()).cast()," ) out.append(""" } @@ -470,8 +642,10 @@ def write_nodekind(out: list[str], ast: Ast) -> None: def generate(ast: Ast) -> list[str]: out = [] write_preamble(out) + write_ids(out, ast) write_owned_enum(out, ast) write_ref_enum(out, ast) + write_storage(out, ast) write_anynoderef(out, ast) write_nodekind(out, ast) return out diff --git a/crates/ruff_python_ast/src/ast.rs b/crates/ruff_python_ast/src/ast.rs new file mode 100644 index 0000000000..599cb2824c --- /dev/null +++ b/crates/ruff_python_ast/src/ast.rs @@ -0,0 +1,92 @@ +#![allow(clippy::derive_partial_eq_without_eq)] + +use std::ops::{Deref, Index}; + +use crate as ast; + +#[derive(Clone, Default, PartialEq)] +pub struct Ast { + pub(crate) storage: ast::Storage, +} + +impl Ast { + #[inline] + pub fn wrap(&self, node: T) -> Node { + Node { ast: self, node } + } + + #[inline] + pub fn node<'a, I>(&'a self, id: I) -> ::Output<'a> + where + I: AstId, + { + id.node(self) + } +} + +impl std::fmt::Debug for Ast { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Ast").finish() + } +} + +pub trait AstId { + type Output<'a>; + fn node<'a>(self, ast: &'a Ast) -> Self::Output<'a>; +} + +pub trait AstIdMut { + type Output<'a>; + fn node_mut<'a>(self, ast: &'a mut Ast) -> Self::Output<'a>; +} + +#[derive(Clone, Copy)] +pub struct Node<'ast, T> { + pub ast: &'ast Ast, + pub node: T, +} + +impl Node<'_, T> { + pub fn as_ref(&self) -> &T { + &self.node + } +} + +impl std::fmt::Debug for Node<'_, T> +where + T: std::fmt::Debug, +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_tuple("Node").field(&self.node).finish() + } +} + +impl Deref for Node<'_, T> { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.node + } +} + +impl Eq for Node<'_, T> where T: Eq {} + +impl std::hash::Hash for Node<'_, T> +where + T: std::hash::Hash, +{ + fn hash(&self, state: &mut H) + where + H: std::hash::Hasher, + { + self.node.hash(state); + } +} + +impl PartialEq for Node<'_, T> +where + T: PartialEq, +{ + fn eq(&self, other: &Self) -> bool { + self.node == other.node + } +} diff --git a/crates/ruff_python_ast/src/comparable.rs b/crates/ruff_python_ast/src/comparable.rs index 8dd4c0dd85..a7db6278ee 100644 --- a/crates/ruff_python_ast/src/comparable.rs +++ b/crates/ruff_python_ast/src/comparable.rs @@ -16,7 +16,7 @@ //! have the same shape in that they evaluate to the same value. use crate as ast; -use crate::{Expr, Number}; +use crate::{Expr, Node, Number}; use std::borrow::Cow; use std::hash::Hash; @@ -593,18 +593,14 @@ impl<'a> From> for ComparableLiteral<'a> { match literal { ast::LiteralExpressionRef::NoneLiteral(_) => Self::None, ast::LiteralExpressionRef::EllipsisLiteral(_) => Self::Ellipsis, - ast::LiteralExpressionRef::BooleanLiteral(ast::ExprBooleanLiteral { - value, .. - }) => Self::Bool(value), - ast::LiteralExpressionRef::StringLiteral(ast::ExprStringLiteral { value, .. }) => { - Self::Str(value.iter().map(Into::into).collect()) + ast::LiteralExpressionRef::BooleanLiteral(node) => Self::Bool(&node.value), + ast::LiteralExpressionRef::StringLiteral(node) => { + Self::Str(node.value.iter().map(Into::into).collect()) } - ast::LiteralExpressionRef::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => { - Self::Bytes(value.iter().map(Into::into).collect()) - } - ast::LiteralExpressionRef::NumberLiteral(ast::ExprNumberLiteral { value, .. }) => { - Self::Number(value.into()) + ast::LiteralExpressionRef::BytesLiteral(node) => { + Self::Bytes(node.value.iter().map(Into::into).collect()) } + ast::LiteralExpressionRef::NumberLiteral(node) => Self::Number((&node.value).into()), } } } @@ -1437,9 +1433,9 @@ pub enum ComparableStmt<'a> { Continue, } -impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { - fn from(stmt: &'a ast::Stmt) -> Self { - match stmt { +impl<'a> From>> for ComparableStmt<'a> { + fn from(stmt: Node<'a, ast::StmtRef<'a>>) -> Self { + match stmt.node { ast::Stmt::FunctionDef(ast::StmtFunctionDef { is_async, name, @@ -1451,7 +1447,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> { range: _, }) => Self::FunctionDef(StmtFunctionDef { is_async: *is_async, - name: name.as_str(), + name: stmt.name().as_str(), parameters: parameters.into(), body: body.iter().map(Into::into).collect(), decorator_list: decorator_list.iter().map(Into::into).collect(), diff --git a/crates/ruff_python_ast/src/expression.rs b/crates/ruff_python_ast/src/expression.rs index 48a0342971..7db250b536 100644 --- a/crates/ruff_python_ast/src/expression.rs +++ b/crates/ruff_python_ast/src/expression.rs @@ -3,26 +3,20 @@ use std::iter::FusedIterator; use ruff_text_size::{Ranged, TextRange}; use crate::{ - self as ast, AnyNodeRef, AnyStringFlags, Expr, ExprBytesLiteral, ExprFString, ExprRef, - ExprStringLiteral, StringFlags, + self as ast, AnyNodeRef, AnyStringFlags, Ast, Expr, ExprBytesLiteral, ExprFString, ExprRef, + ExprStringLiteral, Node, StringFlags, }; -impl<'a> From<&'a Box> for ExprRef<'a> { - fn from(value: &'a Box) -> Self { - ExprRef::from(value.as_ref()) - } -} - /// Unowned pendant to all the literal variants of [`ast::Expr`] that stores a /// reference instead of an owned value. #[derive(Copy, Clone, Debug, PartialEq, is_macro::Is)] pub enum LiteralExpressionRef<'a> { - StringLiteral(&'a ast::ExprStringLiteral), - BytesLiteral(&'a ast::ExprBytesLiteral), - NumberLiteral(&'a ast::ExprNumberLiteral), - BooleanLiteral(&'a ast::ExprBooleanLiteral), - NoneLiteral(&'a ast::ExprNoneLiteral), - EllipsisLiteral(&'a ast::ExprEllipsisLiteral), + StringLiteral(Node<'a, &'a ast::ExprStringLiteral>), + BytesLiteral(Node<'a, &'a ast::ExprBytesLiteral>), + NumberLiteral(Node<'a, &'a ast::ExprNumberLiteral>), + BooleanLiteral(Node<'a, &'a ast::ExprBooleanLiteral>), + NoneLiteral(Node<'a, &'a ast::ExprNoneLiteral>), + EllipsisLiteral(Node<'a, &'a ast::ExprEllipsisLiteral>), } impl Ranged for LiteralExpressionRef<'_> { @@ -83,9 +77,9 @@ impl LiteralExpressionRef<'_> { /// literals, bytes literals, and f-strings. #[derive(Copy, Clone, Debug, PartialEq)] pub enum StringLike<'a> { - String(&'a ast::ExprStringLiteral), - Bytes(&'a ast::ExprBytesLiteral), - FString(&'a ast::ExprFString), + String(Node<'a, &'a ast::ExprStringLiteral>), + Bytes(Node<'a, &'a ast::ExprBytesLiteral>), + FString(Node<'a, &'a ast::ExprFString>), } impl<'a> StringLike<'a> { @@ -96,18 +90,18 @@ impl<'a> StringLike<'a> { /// Returns an iterator over the [`StringLikePart`] contained in this string-like expression. pub fn parts(&self) -> StringLikePartIter<'a> { match self { - StringLike::String(expr) => StringLikePartIter::String(expr.value.iter()), - StringLike::Bytes(expr) => StringLikePartIter::Bytes(expr.value.iter()), - StringLike::FString(expr) => StringLikePartIter::FString(expr.value.iter()), + StringLike::String(expr) => StringLikePartIter::String(expr.ast, expr.value.iter()), + StringLike::Bytes(expr) => StringLikePartIter::Bytes(expr.ast, expr.value.iter()), + StringLike::FString(expr) => StringLikePartIter::FString(expr.ast, expr.value.iter()), } } /// Returns `true` if the string is implicitly concatenated. pub fn is_implicit_concatenated(self) -> bool { match self { - Self::String(ExprStringLiteral { value, .. }) => value.is_implicit_concatenated(), - Self::Bytes(ExprBytesLiteral { value, .. }) => value.is_implicit_concatenated(), - Self::FString(ExprFString { value, .. }) => value.is_implicit_concatenated(), + Self::String(node) => node.value.is_implicit_concatenated(), + Self::Bytes(node) => node.value.is_implicit_concatenated(), + Self::FString(node) => node.value.is_implicit_concatenated(), } } @@ -120,26 +114,26 @@ impl<'a> StringLike<'a> { } } -impl<'a> From<&'a ast::ExprStringLiteral> for StringLike<'a> { - fn from(value: &'a ast::ExprStringLiteral) -> Self { +impl<'a> From> for StringLike<'a> { + fn from(value: Node<'a, &'a ast::ExprStringLiteral>) -> Self { StringLike::String(value) } } -impl<'a> From<&'a ast::ExprBytesLiteral> for StringLike<'a> { - fn from(value: &'a ast::ExprBytesLiteral) -> Self { +impl<'a> From> for StringLike<'a> { + fn from(value: Node<'a, &'a ast::ExprBytesLiteral>) -> Self { StringLike::Bytes(value) } } -impl<'a> From<&'a ast::ExprFString> for StringLike<'a> { - fn from(value: &'a ast::ExprFString) -> Self { +impl<'a> From> for StringLike<'a> { + fn from(value: Node<'a, &'a ast::ExprFString>) -> Self { StringLike::FString(value) } } -impl<'a> From<&StringLike<'a>> for ExprRef<'a> { - fn from(value: &StringLike<'a>) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(value: StringLike<'a>) -> Self { match value { StringLike::String(expr) => ExprRef::StringLiteral(expr), StringLike::Bytes(expr) => ExprRef::BytesLiteral(expr), @@ -150,12 +144,6 @@ impl<'a> From<&StringLike<'a>> for ExprRef<'a> { impl<'a> From> for AnyNodeRef<'a> { fn from(value: StringLike<'a>) -> Self { - AnyNodeRef::from(&value) - } -} - -impl<'a> From<&StringLike<'a>> for AnyNodeRef<'a> { - fn from(value: &StringLike<'a>) -> Self { match value { StringLike::String(expr) => AnyNodeRef::ExprStringLiteral(expr), StringLike::Bytes(expr) => AnyNodeRef::ExprBytesLiteral(expr), @@ -164,14 +152,14 @@ impl<'a> From<&StringLike<'a>> for AnyNodeRef<'a> { } } -impl<'a> TryFrom<&'a Expr> for StringLike<'a> { +impl<'a> TryFrom> for StringLike<'a> { type Error = (); - fn try_from(value: &'a Expr) -> Result { - match value { - Expr::StringLiteral(value) => Ok(Self::String(value)), - Expr::BytesLiteral(value) => Ok(Self::Bytes(value)), - Expr::FString(value) => Ok(Self::FString(value)), + fn try_from(value: Node<'a, &'a Expr>) -> Result { + match value.node { + Expr::StringLiteral(v) => Ok(Self::String(value.ast.wrap(v))), + Expr::BytesLiteral(v) => Ok(Self::Bytes(value.ast.wrap(v))), + Expr::FString(v) => Ok(Self::FString(value.ast.wrap(v))), _ => Err(()), } } @@ -203,9 +191,9 @@ impl Ranged for StringLike<'_> { /// An enum that holds a reference to an individual part of a string-like expression. #[derive(Copy, Clone, Debug, PartialEq)] pub enum StringLikePart<'a> { - String(&'a ast::StringLiteral), - Bytes(&'a ast::BytesLiteral), - FString(&'a ast::FString), + String(Node<'a, &'a ast::StringLiteral>), + Bytes(Node<'a, &'a ast::BytesLiteral>), + FString(Node<'a, &'a ast::FString>), } impl<'a> StringLikePart<'a> { @@ -231,7 +219,7 @@ impl<'a> StringLikePart<'a> { matches!(self, Self::String(_)) } - pub const fn as_string_literal(self) -> Option<&'a ast::StringLiteral> { + pub const fn as_string_literal(self) -> Option> { match self { StringLikePart::String(value) => Some(value), _ => None, @@ -243,30 +231,24 @@ impl<'a> StringLikePart<'a> { } } -impl<'a> From<&'a ast::StringLiteral> for StringLikePart<'a> { - fn from(value: &'a ast::StringLiteral) -> Self { +impl<'a> From> for StringLikePart<'a> { + fn from(value: Node<'a, &'a ast::StringLiteral>) -> Self { StringLikePart::String(value) } } -impl<'a> From<&'a ast::BytesLiteral> for StringLikePart<'a> { - fn from(value: &'a ast::BytesLiteral) -> Self { +impl<'a> From> for StringLikePart<'a> { + fn from(value: Node<'a, &'a ast::BytesLiteral>) -> Self { StringLikePart::Bytes(value) } } -impl<'a> From<&'a ast::FString> for StringLikePart<'a> { - fn from(value: &'a ast::FString) -> Self { +impl<'a> From> for StringLikePart<'a> { + fn from(value: Node<'a, &'a ast::FString>) -> Self { StringLikePart::FString(value) } } -impl<'a> From<&StringLikePart<'a>> for AnyNodeRef<'a> { - fn from(value: &StringLikePart<'a>) -> Self { - AnyNodeRef::from(*value) - } -} - impl<'a> From> for AnyNodeRef<'a> { fn from(value: StringLikePart<'a>) -> Self { match value { @@ -292,9 +274,9 @@ impl Ranged for StringLikePart<'_> { /// This is created by the [`StringLike::parts`] method. #[derive(Clone)] pub enum StringLikePartIter<'a> { - String(std::slice::Iter<'a, ast::StringLiteral>), - Bytes(std::slice::Iter<'a, ast::BytesLiteral>), - FString(std::slice::Iter<'a, ast::FStringPart>), + String(&'a Ast, std::slice::Iter<'a, ast::StringLiteral>), + Bytes(&'a Ast, std::slice::Iter<'a, ast::BytesLiteral>), + FString(&'a Ast, std::slice::Iter<'a, ast::FStringPart>), } impl<'a> Iterator for StringLikePartIter<'a> { @@ -302,15 +284,19 @@ impl<'a> Iterator for StringLikePartIter<'a> { fn next(&mut self) -> Option { let part = match self { - StringLikePartIter::String(inner) => StringLikePart::String(inner.next()?), - StringLikePartIter::Bytes(inner) => StringLikePart::Bytes(inner.next()?), - StringLikePartIter::FString(inner) => { + StringLikePartIter::String(ast, inner) => { + StringLikePart::String(ast.wrap(inner.next()?)) + } + StringLikePartIter::Bytes(ast, inner) => StringLikePart::Bytes(ast.wrap(inner.next()?)), + StringLikePartIter::FString(ast, inner) => { let part = inner.next()?; match part { ast::FStringPart::Literal(string_literal) => { - StringLikePart::String(string_literal) + StringLikePart::String(ast.wrap(string_literal)) + } + ast::FStringPart::FString(f_string) => { + StringLikePart::FString(ast.wrap(f_string)) } - ast::FStringPart::FString(f_string) => StringLikePart::FString(f_string), } } }; @@ -320,9 +306,9 @@ impl<'a> Iterator for StringLikePartIter<'a> { fn size_hint(&self) -> (usize, Option) { match self { - StringLikePartIter::String(inner) => inner.size_hint(), - StringLikePartIter::Bytes(inner) => inner.size_hint(), - StringLikePartIter::FString(inner) => inner.size_hint(), + StringLikePartIter::String(_, inner) => inner.size_hint(), + StringLikePartIter::Bytes(_, inner) => inner.size_hint(), + StringLikePartIter::FString(_, inner) => inner.size_hint(), } } } @@ -330,15 +316,21 @@ impl<'a> Iterator for StringLikePartIter<'a> { impl DoubleEndedIterator for StringLikePartIter<'_> { fn next_back(&mut self) -> Option { let part = match self { - StringLikePartIter::String(inner) => StringLikePart::String(inner.next_back()?), - StringLikePartIter::Bytes(inner) => StringLikePart::Bytes(inner.next_back()?), - StringLikePartIter::FString(inner) => { + StringLikePartIter::String(ast, inner) => { + StringLikePart::String(ast.wrap(inner.next_back()?)) + } + StringLikePartIter::Bytes(ast, inner) => { + StringLikePart::Bytes(ast.wrap(inner.next_back()?)) + } + StringLikePartIter::FString(ast, inner) => { let part = inner.next_back()?; match part { ast::FStringPart::Literal(string_literal) => { - StringLikePart::String(string_literal) + StringLikePart::String(ast.wrap(string_literal)) + } + ast::FStringPart::FString(f_string) => { + StringLikePart::FString(ast.wrap(f_string)) } - ast::FStringPart::FString(f_string) => StringLikePart::FString(f_string), } } }; diff --git a/crates/ruff_python_ast/src/generated.rs b/crates/ruff_python_ast/src/generated.rs index c9dc97243d..7c314fea00 100644 --- a/crates/ruff_python_ast/src/generated.rs +++ b/crates/ruff_python_ast/src/generated.rs @@ -1,6 +1,1436 @@ // This is a generated file. Don't modify it by hand! // Run `crates/ruff_python_ast/generate.py` to re-generate the file. +#[ruff_index::newtype_index] +pub struct ModModuleId; + +impl ruff_text_size::Ranged for crate::ModModule { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ModExpressionId; + +impl ruff_text_size::Ranged for crate::ModExpression { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtFunctionDefId; + +impl ruff_text_size::Ranged for crate::StmtFunctionDef { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtClassDefId; + +impl ruff_text_size::Ranged for crate::StmtClassDef { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtReturnId; + +impl ruff_text_size::Ranged for crate::StmtReturn { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtDeleteId; + +impl ruff_text_size::Ranged for crate::StmtDelete { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtTypeAliasId; + +impl ruff_text_size::Ranged for crate::StmtTypeAlias { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtAssignId; + +impl ruff_text_size::Ranged for crate::StmtAssign { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtAugAssignId; + +impl ruff_text_size::Ranged for crate::StmtAugAssign { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtAnnAssignId; + +impl ruff_text_size::Ranged for crate::StmtAnnAssign { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtForId; + +impl ruff_text_size::Ranged for crate::StmtFor { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtWhileId; + +impl ruff_text_size::Ranged for crate::StmtWhile { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtIfId; + +impl ruff_text_size::Ranged for crate::StmtIf { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtWithId; + +impl ruff_text_size::Ranged for crate::StmtWith { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtMatchId; + +impl ruff_text_size::Ranged for crate::StmtMatch { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtRaiseId; + +impl ruff_text_size::Ranged for crate::StmtRaise { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtTryId; + +impl ruff_text_size::Ranged for crate::StmtTry { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtAssertId; + +impl ruff_text_size::Ranged for crate::StmtAssert { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtImportId; + +impl ruff_text_size::Ranged for crate::StmtImport { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtImportFromId; + +impl ruff_text_size::Ranged for crate::StmtImportFrom { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtGlobalId; + +impl ruff_text_size::Ranged for crate::StmtGlobal { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtNonlocalId; + +impl ruff_text_size::Ranged for crate::StmtNonlocal { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtExprId; + +impl ruff_text_size::Ranged for crate::StmtExpr { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtPassId; + +impl ruff_text_size::Ranged for crate::StmtPass { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtBreakId; + +impl ruff_text_size::Ranged for crate::StmtBreak { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtContinueId; + +impl ruff_text_size::Ranged for crate::StmtContinue { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StmtIpyEscapeCommandId; + +impl ruff_text_size::Ranged for crate::StmtIpyEscapeCommand { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprBoolOpId; + +impl ruff_text_size::Ranged for crate::ExprBoolOp { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprNamedId; + +impl ruff_text_size::Ranged for crate::ExprNamed { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprBinOpId; + +impl ruff_text_size::Ranged for crate::ExprBinOp { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprUnaryOpId; + +impl ruff_text_size::Ranged for crate::ExprUnaryOp { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprLambdaId; + +impl ruff_text_size::Ranged for crate::ExprLambda { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprIfId; + +impl ruff_text_size::Ranged for crate::ExprIf { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprDictId; + +impl ruff_text_size::Ranged for crate::ExprDict { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprSetId; + +impl ruff_text_size::Ranged for crate::ExprSet { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprListCompId; + +impl ruff_text_size::Ranged for crate::ExprListComp { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprSetCompId; + +impl ruff_text_size::Ranged for crate::ExprSetComp { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprDictCompId; + +impl ruff_text_size::Ranged for crate::ExprDictComp { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprGeneratorId; + +impl ruff_text_size::Ranged for crate::ExprGenerator { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprAwaitId; + +impl ruff_text_size::Ranged for crate::ExprAwait { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprYieldId; + +impl ruff_text_size::Ranged for crate::ExprYield { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprYieldFromId; + +impl ruff_text_size::Ranged for crate::ExprYieldFrom { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprCompareId; + +impl ruff_text_size::Ranged for crate::ExprCompare { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprCallId; + +impl ruff_text_size::Ranged for crate::ExprCall { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprFStringId; + +impl ruff_text_size::Ranged for crate::ExprFString { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprStringLiteralId; + +impl ruff_text_size::Ranged for crate::ExprStringLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprBytesLiteralId; + +impl ruff_text_size::Ranged for crate::ExprBytesLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprNumberLiteralId; + +impl ruff_text_size::Ranged for crate::ExprNumberLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprBooleanLiteralId; + +impl ruff_text_size::Ranged for crate::ExprBooleanLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprNoneLiteralId; + +impl ruff_text_size::Ranged for crate::ExprNoneLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprEllipsisLiteralId; + +impl ruff_text_size::Ranged for crate::ExprEllipsisLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprAttributeId; + +impl ruff_text_size::Ranged for crate::ExprAttribute { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprSubscriptId; + +impl ruff_text_size::Ranged for crate::ExprSubscript { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprStarredId; + +impl ruff_text_size::Ranged for crate::ExprStarred { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprNameId; + +impl ruff_text_size::Ranged for crate::ExprName { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprListId; + +impl ruff_text_size::Ranged for crate::ExprList { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprTupleId; + +impl ruff_text_size::Ranged for crate::ExprTuple { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprSliceId; + +impl ruff_text_size::Ranged for crate::ExprSlice { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExprIpyEscapeCommandId; + +impl ruff_text_size::Ranged for crate::ExprIpyEscapeCommand { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ExceptHandlerExceptHandlerId; + +impl ruff_text_size::Ranged for crate::ExceptHandlerExceptHandler { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct FStringExpressionElementId; + +impl ruff_text_size::Ranged for crate::FStringExpressionElement { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct FStringLiteralElementId; + +impl ruff_text_size::Ranged for crate::FStringLiteralElement { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchValueId; + +impl ruff_text_size::Ranged for crate::PatternMatchValue { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchSingletonId; + +impl ruff_text_size::Ranged for crate::PatternMatchSingleton { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchSequenceId; + +impl ruff_text_size::Ranged for crate::PatternMatchSequence { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchMappingId; + +impl ruff_text_size::Ranged for crate::PatternMatchMapping { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchClassId; + +impl ruff_text_size::Ranged for crate::PatternMatchClass { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchStarId; + +impl ruff_text_size::Ranged for crate::PatternMatchStar { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchAsId; + +impl ruff_text_size::Ranged for crate::PatternMatchAs { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternMatchOrId; + +impl ruff_text_size::Ranged for crate::PatternMatchOr { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct TypeParamTypeVarId; + +impl ruff_text_size::Ranged for crate::TypeParamTypeVar { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct TypeParamTypeVarTupleId; + +impl ruff_text_size::Ranged for crate::TypeParamTypeVarTuple { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct TypeParamParamSpecId; + +impl ruff_text_size::Ranged for crate::TypeParamParamSpec { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct FStringFormatSpecId; + +impl ruff_text_size::Ranged for crate::FStringFormatSpec { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternArgumentsId; + +impl ruff_text_size::Ranged for crate::PatternArguments { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct PatternKeywordId; + +impl ruff_text_size::Ranged for crate::PatternKeyword { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ComprehensionId; + +impl ruff_text_size::Ranged for crate::Comprehension { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ArgumentsId; + +impl ruff_text_size::Ranged for crate::Arguments { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ParametersId; + +impl ruff_text_size::Ranged for crate::Parameters { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ParameterId; + +impl ruff_text_size::Ranged for crate::Parameter { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ParameterWithDefaultId; + +impl ruff_text_size::Ranged for crate::ParameterWithDefault { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct KeywordId; + +impl ruff_text_size::Ranged for crate::Keyword { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct AliasId; + +impl ruff_text_size::Ranged for crate::Alias { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct WithItemId; + +impl ruff_text_size::Ranged for crate::WithItem { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct MatchCaseId; + +impl ruff_text_size::Ranged for crate::MatchCase { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct DecoratorId; + +impl ruff_text_size::Ranged for crate::Decorator { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct ElifElseClauseId; + +impl ruff_text_size::Ranged for crate::ElifElseClause { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct TypeParamsId; + +impl ruff_text_size::Ranged for crate::TypeParams { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct FStringId; + +impl ruff_text_size::Ranged for crate::FString { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct StringLiteralId; + +impl ruff_text_size::Ranged for crate::StringLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct BytesLiteralId; + +impl ruff_text_size::Ranged for crate::BytesLiteral { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +#[ruff_index::newtype_index] +pub struct IdentifierId; + +impl ruff_text_size::Ranged for crate::Identifier { + fn range(&self) -> ruff_text_size::TextRange { + self.range + } +} + +/// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod) +#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] +pub enum ModId { + Module(ModModuleId), + Expression(ModExpressionId), +} + +impl From for ModId { + fn from(id: ModModuleId) -> Self { + Self::Module(id) + } +} + +impl From for ModId { + fn from(id: ModExpressionId) -> Self { + Self::Expression(id) + } +} + +/// See also [stmt](https://docs.python.org/3/library/ast.html#ast.stmt) +#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] +pub enum StmtId { + #[is(name = "function_def_stmt")] + FunctionDef(StmtFunctionDefId), + #[is(name = "class_def_stmt")] + ClassDef(StmtClassDefId), + #[is(name = "return_stmt")] + Return(StmtReturnId), + #[is(name = "delete_stmt")] + Delete(StmtDeleteId), + #[is(name = "type_alias_stmt")] + TypeAlias(StmtTypeAliasId), + #[is(name = "assign_stmt")] + Assign(StmtAssignId), + #[is(name = "aug_assign_stmt")] + AugAssign(StmtAugAssignId), + #[is(name = "ann_assign_stmt")] + AnnAssign(StmtAnnAssignId), + #[is(name = "for_stmt")] + For(StmtForId), + #[is(name = "while_stmt")] + While(StmtWhileId), + #[is(name = "if_stmt")] + If(StmtIfId), + #[is(name = "with_stmt")] + With(StmtWithId), + #[is(name = "match_stmt")] + Match(StmtMatchId), + #[is(name = "raise_stmt")] + Raise(StmtRaiseId), + #[is(name = "try_stmt")] + Try(StmtTryId), + #[is(name = "assert_stmt")] + Assert(StmtAssertId), + #[is(name = "import_stmt")] + Import(StmtImportId), + #[is(name = "import_from_stmt")] + ImportFrom(StmtImportFromId), + #[is(name = "global_stmt")] + Global(StmtGlobalId), + #[is(name = "nonlocal_stmt")] + Nonlocal(StmtNonlocalId), + #[is(name = "expr_stmt")] + Expr(StmtExprId), + #[is(name = "pass_stmt")] + Pass(StmtPassId), + #[is(name = "break_stmt")] + Break(StmtBreakId), + #[is(name = "continue_stmt")] + Continue(StmtContinueId), + #[is(name = "ipy_escape_command_stmt")] + IpyEscapeCommand(StmtIpyEscapeCommandId), +} + +impl From for StmtId { + fn from(id: StmtFunctionDefId) -> Self { + Self::FunctionDef(id) + } +} + +impl From for StmtId { + fn from(id: StmtClassDefId) -> Self { + Self::ClassDef(id) + } +} + +impl From for StmtId { + fn from(id: StmtReturnId) -> Self { + Self::Return(id) + } +} + +impl From for StmtId { + fn from(id: StmtDeleteId) -> Self { + Self::Delete(id) + } +} + +impl From for StmtId { + fn from(id: StmtTypeAliasId) -> Self { + Self::TypeAlias(id) + } +} + +impl From for StmtId { + fn from(id: StmtAssignId) -> Self { + Self::Assign(id) + } +} + +impl From for StmtId { + fn from(id: StmtAugAssignId) -> Self { + Self::AugAssign(id) + } +} + +impl From for StmtId { + fn from(id: StmtAnnAssignId) -> Self { + Self::AnnAssign(id) + } +} + +impl From for StmtId { + fn from(id: StmtForId) -> Self { + Self::For(id) + } +} + +impl From for StmtId { + fn from(id: StmtWhileId) -> Self { + Self::While(id) + } +} + +impl From for StmtId { + fn from(id: StmtIfId) -> Self { + Self::If(id) + } +} + +impl From for StmtId { + fn from(id: StmtWithId) -> Self { + Self::With(id) + } +} + +impl From for StmtId { + fn from(id: StmtMatchId) -> Self { + Self::Match(id) + } +} + +impl From for StmtId { + fn from(id: StmtRaiseId) -> Self { + Self::Raise(id) + } +} + +impl From for StmtId { + fn from(id: StmtTryId) -> Self { + Self::Try(id) + } +} + +impl From for StmtId { + fn from(id: StmtAssertId) -> Self { + Self::Assert(id) + } +} + +impl From for StmtId { + fn from(id: StmtImportId) -> Self { + Self::Import(id) + } +} + +impl From for StmtId { + fn from(id: StmtImportFromId) -> Self { + Self::ImportFrom(id) + } +} + +impl From for StmtId { + fn from(id: StmtGlobalId) -> Self { + Self::Global(id) + } +} + +impl From for StmtId { + fn from(id: StmtNonlocalId) -> Self { + Self::Nonlocal(id) + } +} + +impl From for StmtId { + fn from(id: StmtExprId) -> Self { + Self::Expr(id) + } +} + +impl From for StmtId { + fn from(id: StmtPassId) -> Self { + Self::Pass(id) + } +} + +impl From for StmtId { + fn from(id: StmtBreakId) -> Self { + Self::Break(id) + } +} + +impl From for StmtId { + fn from(id: StmtContinueId) -> Self { + Self::Continue(id) + } +} + +impl From for StmtId { + fn from(id: StmtIpyEscapeCommandId) -> Self { + Self::IpyEscapeCommand(id) + } +} + +/// See also [expr](https://docs.python.org/3/library/ast.html#ast.expr) +#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] +pub enum ExprId { + #[is(name = "bool_op_expr")] + BoolOp(ExprBoolOpId), + #[is(name = "named_expr")] + Named(ExprNamedId), + #[is(name = "bin_op_expr")] + BinOp(ExprBinOpId), + #[is(name = "unary_op_expr")] + UnaryOp(ExprUnaryOpId), + #[is(name = "lambda_expr")] + Lambda(ExprLambdaId), + #[is(name = "if_expr")] + If(ExprIfId), + #[is(name = "dict_expr")] + Dict(ExprDictId), + #[is(name = "set_expr")] + Set(ExprSetId), + #[is(name = "list_comp_expr")] + ListComp(ExprListCompId), + #[is(name = "set_comp_expr")] + SetComp(ExprSetCompId), + #[is(name = "dict_comp_expr")] + DictComp(ExprDictCompId), + #[is(name = "generator_expr")] + Generator(ExprGeneratorId), + #[is(name = "await_expr")] + Await(ExprAwaitId), + #[is(name = "yield_expr")] + Yield(ExprYieldId), + #[is(name = "yield_from_expr")] + YieldFrom(ExprYieldFromId), + #[is(name = "compare_expr")] + Compare(ExprCompareId), + #[is(name = "call_expr")] + Call(ExprCallId), + #[is(name = "f_string_expr")] + FString(ExprFStringId), + #[is(name = "string_literal_expr")] + StringLiteral(ExprStringLiteralId), + #[is(name = "bytes_literal_expr")] + BytesLiteral(ExprBytesLiteralId), + #[is(name = "number_literal_expr")] + NumberLiteral(ExprNumberLiteralId), + #[is(name = "boolean_literal_expr")] + BooleanLiteral(ExprBooleanLiteralId), + #[is(name = "none_literal_expr")] + NoneLiteral(ExprNoneLiteralId), + #[is(name = "ellipsis_literal_expr")] + EllipsisLiteral(ExprEllipsisLiteralId), + #[is(name = "attribute_expr")] + Attribute(ExprAttributeId), + #[is(name = "subscript_expr")] + Subscript(ExprSubscriptId), + #[is(name = "starred_expr")] + Starred(ExprStarredId), + #[is(name = "name_expr")] + Name(ExprNameId), + #[is(name = "list_expr")] + List(ExprListId), + #[is(name = "tuple_expr")] + Tuple(ExprTupleId), + #[is(name = "slice_expr")] + Slice(ExprSliceId), + #[is(name = "ipy_escape_command_expr")] + IpyEscapeCommand(ExprIpyEscapeCommandId), +} + +impl From for ExprId { + fn from(id: ExprBoolOpId) -> Self { + Self::BoolOp(id) + } +} + +impl From for ExprId { + fn from(id: ExprNamedId) -> Self { + Self::Named(id) + } +} + +impl From for ExprId { + fn from(id: ExprBinOpId) -> Self { + Self::BinOp(id) + } +} + +impl From for ExprId { + fn from(id: ExprUnaryOpId) -> Self { + Self::UnaryOp(id) + } +} + +impl From for ExprId { + fn from(id: ExprLambdaId) -> Self { + Self::Lambda(id) + } +} + +impl From for ExprId { + fn from(id: ExprIfId) -> Self { + Self::If(id) + } +} + +impl From for ExprId { + fn from(id: ExprDictId) -> Self { + Self::Dict(id) + } +} + +impl From for ExprId { + fn from(id: ExprSetId) -> Self { + Self::Set(id) + } +} + +impl From for ExprId { + fn from(id: ExprListCompId) -> Self { + Self::ListComp(id) + } +} + +impl From for ExprId { + fn from(id: ExprSetCompId) -> Self { + Self::SetComp(id) + } +} + +impl From for ExprId { + fn from(id: ExprDictCompId) -> Self { + Self::DictComp(id) + } +} + +impl From for ExprId { + fn from(id: ExprGeneratorId) -> Self { + Self::Generator(id) + } +} + +impl From for ExprId { + fn from(id: ExprAwaitId) -> Self { + Self::Await(id) + } +} + +impl From for ExprId { + fn from(id: ExprYieldId) -> Self { + Self::Yield(id) + } +} + +impl From for ExprId { + fn from(id: ExprYieldFromId) -> Self { + Self::YieldFrom(id) + } +} + +impl From for ExprId { + fn from(id: ExprCompareId) -> Self { + Self::Compare(id) + } +} + +impl From for ExprId { + fn from(id: ExprCallId) -> Self { + Self::Call(id) + } +} + +impl From for ExprId { + fn from(id: ExprFStringId) -> Self { + Self::FString(id) + } +} + +impl From for ExprId { + fn from(id: ExprStringLiteralId) -> Self { + Self::StringLiteral(id) + } +} + +impl From for ExprId { + fn from(id: ExprBytesLiteralId) -> Self { + Self::BytesLiteral(id) + } +} + +impl From for ExprId { + fn from(id: ExprNumberLiteralId) -> Self { + Self::NumberLiteral(id) + } +} + +impl From for ExprId { + fn from(id: ExprBooleanLiteralId) -> Self { + Self::BooleanLiteral(id) + } +} + +impl From for ExprId { + fn from(id: ExprNoneLiteralId) -> Self { + Self::NoneLiteral(id) + } +} + +impl From for ExprId { + fn from(id: ExprEllipsisLiteralId) -> Self { + Self::EllipsisLiteral(id) + } +} + +impl From for ExprId { + fn from(id: ExprAttributeId) -> Self { + Self::Attribute(id) + } +} + +impl From for ExprId { + fn from(id: ExprSubscriptId) -> Self { + Self::Subscript(id) + } +} + +impl From for ExprId { + fn from(id: ExprStarredId) -> Self { + Self::Starred(id) + } +} + +impl From for ExprId { + fn from(id: ExprNameId) -> Self { + Self::Name(id) + } +} + +impl From for ExprId { + fn from(id: ExprListId) -> Self { + Self::List(id) + } +} + +impl From for ExprId { + fn from(id: ExprTupleId) -> Self { + Self::Tuple(id) + } +} + +impl From for ExprId { + fn from(id: ExprSliceId) -> Self { + Self::Slice(id) + } +} + +impl From for ExprId { + fn from(id: ExprIpyEscapeCommandId) -> Self { + Self::IpyEscapeCommand(id) + } +} + +/// See also [excepthandler](https://docs.python.org/3/library/ast.html#ast.excepthandler) +#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] +pub enum ExceptHandlerId { + ExceptHandler(ExceptHandlerExceptHandlerId), +} + +impl From for ExceptHandlerId { + fn from(id: ExceptHandlerExceptHandlerId) -> Self { + Self::ExceptHandler(id) + } +} + +#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] +pub enum FStringElementId { + Expression(FStringExpressionElementId), + Literal(FStringLiteralElementId), +} + +impl From for FStringElementId { + fn from(id: FStringExpressionElementId) -> Self { + Self::Expression(id) + } +} + +impl From for FStringElementId { + fn from(id: FStringLiteralElementId) -> Self { + Self::Literal(id) + } +} + +/// See also [pattern](https://docs.python.org/3/library/ast.html#ast.pattern) +#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] +pub enum PatternId { + MatchValue(PatternMatchValueId), + MatchSingleton(PatternMatchSingletonId), + MatchSequence(PatternMatchSequenceId), + MatchMapping(PatternMatchMappingId), + MatchClass(PatternMatchClassId), + MatchStar(PatternMatchStarId), + MatchAs(PatternMatchAsId), + MatchOr(PatternMatchOrId), +} + +impl From for PatternId { + fn from(id: PatternMatchValueId) -> Self { + Self::MatchValue(id) + } +} + +impl From for PatternId { + fn from(id: PatternMatchSingletonId) -> Self { + Self::MatchSingleton(id) + } +} + +impl From for PatternId { + fn from(id: PatternMatchSequenceId) -> Self { + Self::MatchSequence(id) + } +} + +impl From for PatternId { + fn from(id: PatternMatchMappingId) -> Self { + Self::MatchMapping(id) + } +} + +impl From for PatternId { + fn from(id: PatternMatchClassId) -> Self { + Self::MatchClass(id) + } +} + +impl From for PatternId { + fn from(id: PatternMatchStarId) -> Self { + Self::MatchStar(id) + } +} + +impl From for PatternId { + fn from(id: PatternMatchAsId) -> Self { + Self::MatchAs(id) + } +} + +impl From for PatternId { + fn from(id: PatternMatchOrId) -> Self { + Self::MatchOr(id) + } +} + +/// See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param) +#[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] +pub enum TypeParamId { + TypeVar(TypeParamTypeVarId), + TypeVarTuple(TypeParamTypeVarTupleId), + ParamSpec(TypeParamParamSpecId), +} + +impl From for TypeParamId { + fn from(id: TypeParamTypeVarId) -> Self { + Self::TypeVar(id) + } +} + +impl From for TypeParamId { + fn from(id: TypeParamTypeVarTupleId) -> Self { + Self::TypeVarTuple(id) + } +} + +impl From for TypeParamId { + fn from(id: TypeParamParamSpecId) -> Self { + Self::ParamSpec(id) + } +} + /// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod) #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Mod { @@ -725,558 +2155,6 @@ impl ruff_text_size::Ranged for TypeParam { } } -impl ruff_text_size::Ranged for crate::ModModule { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ModExpression { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtFunctionDef { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtClassDef { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtReturn { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtDelete { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtTypeAlias { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtAssign { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtAugAssign { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtAnnAssign { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtFor { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtWhile { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtIf { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtWith { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtMatch { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtRaise { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtTry { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtAssert { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtImport { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtImportFrom { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtGlobal { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtNonlocal { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtExpr { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtPass { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtBreak { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtContinue { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StmtIpyEscapeCommand { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprBoolOp { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprNamed { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprBinOp { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprUnaryOp { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprLambda { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprIf { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprDict { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprSet { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprListComp { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprSetComp { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprDictComp { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprGenerator { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprAwait { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprYield { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprYieldFrom { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprCompare { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprCall { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprFString { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprStringLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprBytesLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprNumberLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprBooleanLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprNoneLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprEllipsisLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprAttribute { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprSubscript { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprStarred { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprName { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprList { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprTuple { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprSlice { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExprIpyEscapeCommand { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ExceptHandlerExceptHandler { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::FStringExpressionElement { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::FStringLiteralElement { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchValue { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchSingleton { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchSequence { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchMapping { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchClass { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchStar { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchAs { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternMatchOr { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::TypeParamTypeVar { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::TypeParamTypeVarTuple { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::TypeParamParamSpec { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::FStringFormatSpec { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternArguments { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::PatternKeyword { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Comprehension { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Arguments { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Parameters { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Parameter { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ParameterWithDefault { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Keyword { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Alias { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::WithItem { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::MatchCase { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Decorator { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::ElifElseClause { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::TypeParams { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::FString { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::StringLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::BytesLiteral { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - -impl ruff_text_size::Ranged for crate::Identifier { - fn range(&self) -> ruff_text_size::TextRange { - self.range - } -} - impl Mod { #[allow(unused)] pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) @@ -1430,27 +2308,27 @@ impl TypeParam { /// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod) #[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] pub enum ModRef<'a> { - Module(&'a crate::ModModule), - Expression(&'a crate::ModExpression), + Module(crate::Node<'a, &'a crate::ModModule>), + Expression(crate::Node<'a, &'a crate::ModExpression>), } -impl<'a> From<&'a Mod> for ModRef<'a> { - fn from(node: &'a Mod) -> Self { - match node { - Mod::Module(node) => ModRef::Module(node), - Mod::Expression(node) => ModRef::Expression(node), +impl<'a> From> for ModRef<'a> { + fn from(node: crate::Node<'a, &'a Mod>) -> Self { + match node.node { + Mod::Module(n) => ModRef::Module(node.ast.wrap(n)), + Mod::Expression(n) => ModRef::Expression(node.ast.wrap(n)), } } } -impl<'a> From<&'a crate::ModModule> for ModRef<'a> { - fn from(node: &'a crate::ModModule) -> Self { +impl<'a> From> for ModRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ModModule>) -> Self { Self::Module(node) } } -impl<'a> From<&'a crate::ModExpression> for ModRef<'a> { - fn from(node: &'a crate::ModExpression) -> Self { +impl<'a> From> for ModRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ModExpression>) -> Self { Self::Expression(node) } } @@ -1468,235 +2346,235 @@ impl ruff_text_size::Ranged for ModRef<'_> { #[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] pub enum StmtRef<'a> { #[is(name = "function_def_stmt")] - FunctionDef(&'a crate::StmtFunctionDef), + FunctionDef(crate::Node<'a, &'a crate::StmtFunctionDef>), #[is(name = "class_def_stmt")] - ClassDef(&'a crate::StmtClassDef), + ClassDef(crate::Node<'a, &'a crate::StmtClassDef>), #[is(name = "return_stmt")] - Return(&'a crate::StmtReturn), + Return(crate::Node<'a, &'a crate::StmtReturn>), #[is(name = "delete_stmt")] - Delete(&'a crate::StmtDelete), + Delete(crate::Node<'a, &'a crate::StmtDelete>), #[is(name = "type_alias_stmt")] - TypeAlias(&'a crate::StmtTypeAlias), + TypeAlias(crate::Node<'a, &'a crate::StmtTypeAlias>), #[is(name = "assign_stmt")] - Assign(&'a crate::StmtAssign), + Assign(crate::Node<'a, &'a crate::StmtAssign>), #[is(name = "aug_assign_stmt")] - AugAssign(&'a crate::StmtAugAssign), + AugAssign(crate::Node<'a, &'a crate::StmtAugAssign>), #[is(name = "ann_assign_stmt")] - AnnAssign(&'a crate::StmtAnnAssign), + AnnAssign(crate::Node<'a, &'a crate::StmtAnnAssign>), #[is(name = "for_stmt")] - For(&'a crate::StmtFor), + For(crate::Node<'a, &'a crate::StmtFor>), #[is(name = "while_stmt")] - While(&'a crate::StmtWhile), + While(crate::Node<'a, &'a crate::StmtWhile>), #[is(name = "if_stmt")] - If(&'a crate::StmtIf), + If(crate::Node<'a, &'a crate::StmtIf>), #[is(name = "with_stmt")] - With(&'a crate::StmtWith), + With(crate::Node<'a, &'a crate::StmtWith>), #[is(name = "match_stmt")] - Match(&'a crate::StmtMatch), + Match(crate::Node<'a, &'a crate::StmtMatch>), #[is(name = "raise_stmt")] - Raise(&'a crate::StmtRaise), + Raise(crate::Node<'a, &'a crate::StmtRaise>), #[is(name = "try_stmt")] - Try(&'a crate::StmtTry), + Try(crate::Node<'a, &'a crate::StmtTry>), #[is(name = "assert_stmt")] - Assert(&'a crate::StmtAssert), + Assert(crate::Node<'a, &'a crate::StmtAssert>), #[is(name = "import_stmt")] - Import(&'a crate::StmtImport), + Import(crate::Node<'a, &'a crate::StmtImport>), #[is(name = "import_from_stmt")] - ImportFrom(&'a crate::StmtImportFrom), + ImportFrom(crate::Node<'a, &'a crate::StmtImportFrom>), #[is(name = "global_stmt")] - Global(&'a crate::StmtGlobal), + Global(crate::Node<'a, &'a crate::StmtGlobal>), #[is(name = "nonlocal_stmt")] - Nonlocal(&'a crate::StmtNonlocal), + Nonlocal(crate::Node<'a, &'a crate::StmtNonlocal>), #[is(name = "expr_stmt")] - Expr(&'a crate::StmtExpr), + Expr(crate::Node<'a, &'a crate::StmtExpr>), #[is(name = "pass_stmt")] - Pass(&'a crate::StmtPass), + Pass(crate::Node<'a, &'a crate::StmtPass>), #[is(name = "break_stmt")] - Break(&'a crate::StmtBreak), + Break(crate::Node<'a, &'a crate::StmtBreak>), #[is(name = "continue_stmt")] - Continue(&'a crate::StmtContinue), + Continue(crate::Node<'a, &'a crate::StmtContinue>), #[is(name = "ipy_escape_command_stmt")] - IpyEscapeCommand(&'a crate::StmtIpyEscapeCommand), + IpyEscapeCommand(crate::Node<'a, &'a crate::StmtIpyEscapeCommand>), } -impl<'a> From<&'a Stmt> for StmtRef<'a> { - fn from(node: &'a Stmt) -> Self { - match node { - Stmt::FunctionDef(node) => StmtRef::FunctionDef(node), - Stmt::ClassDef(node) => StmtRef::ClassDef(node), - Stmt::Return(node) => StmtRef::Return(node), - Stmt::Delete(node) => StmtRef::Delete(node), - Stmt::TypeAlias(node) => StmtRef::TypeAlias(node), - Stmt::Assign(node) => StmtRef::Assign(node), - Stmt::AugAssign(node) => StmtRef::AugAssign(node), - Stmt::AnnAssign(node) => StmtRef::AnnAssign(node), - Stmt::For(node) => StmtRef::For(node), - Stmt::While(node) => StmtRef::While(node), - Stmt::If(node) => StmtRef::If(node), - Stmt::With(node) => StmtRef::With(node), - Stmt::Match(node) => StmtRef::Match(node), - Stmt::Raise(node) => StmtRef::Raise(node), - Stmt::Try(node) => StmtRef::Try(node), - Stmt::Assert(node) => StmtRef::Assert(node), - Stmt::Import(node) => StmtRef::Import(node), - Stmt::ImportFrom(node) => StmtRef::ImportFrom(node), - Stmt::Global(node) => StmtRef::Global(node), - Stmt::Nonlocal(node) => StmtRef::Nonlocal(node), - Stmt::Expr(node) => StmtRef::Expr(node), - Stmt::Pass(node) => StmtRef::Pass(node), - Stmt::Break(node) => StmtRef::Break(node), - Stmt::Continue(node) => StmtRef::Continue(node), - Stmt::IpyEscapeCommand(node) => StmtRef::IpyEscapeCommand(node), +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a Stmt>) -> Self { + match node.node { + Stmt::FunctionDef(n) => StmtRef::FunctionDef(node.ast.wrap(n)), + Stmt::ClassDef(n) => StmtRef::ClassDef(node.ast.wrap(n)), + Stmt::Return(n) => StmtRef::Return(node.ast.wrap(n)), + Stmt::Delete(n) => StmtRef::Delete(node.ast.wrap(n)), + Stmt::TypeAlias(n) => StmtRef::TypeAlias(node.ast.wrap(n)), + Stmt::Assign(n) => StmtRef::Assign(node.ast.wrap(n)), + Stmt::AugAssign(n) => StmtRef::AugAssign(node.ast.wrap(n)), + Stmt::AnnAssign(n) => StmtRef::AnnAssign(node.ast.wrap(n)), + Stmt::For(n) => StmtRef::For(node.ast.wrap(n)), + Stmt::While(n) => StmtRef::While(node.ast.wrap(n)), + Stmt::If(n) => StmtRef::If(node.ast.wrap(n)), + Stmt::With(n) => StmtRef::With(node.ast.wrap(n)), + Stmt::Match(n) => StmtRef::Match(node.ast.wrap(n)), + Stmt::Raise(n) => StmtRef::Raise(node.ast.wrap(n)), + Stmt::Try(n) => StmtRef::Try(node.ast.wrap(n)), + Stmt::Assert(n) => StmtRef::Assert(node.ast.wrap(n)), + Stmt::Import(n) => StmtRef::Import(node.ast.wrap(n)), + Stmt::ImportFrom(n) => StmtRef::ImportFrom(node.ast.wrap(n)), + Stmt::Global(n) => StmtRef::Global(node.ast.wrap(n)), + Stmt::Nonlocal(n) => StmtRef::Nonlocal(node.ast.wrap(n)), + Stmt::Expr(n) => StmtRef::Expr(node.ast.wrap(n)), + Stmt::Pass(n) => StmtRef::Pass(node.ast.wrap(n)), + Stmt::Break(n) => StmtRef::Break(node.ast.wrap(n)), + Stmt::Continue(n) => StmtRef::Continue(node.ast.wrap(n)), + Stmt::IpyEscapeCommand(n) => StmtRef::IpyEscapeCommand(node.ast.wrap(n)), } } } -impl<'a> From<&'a crate::StmtFunctionDef> for StmtRef<'a> { - fn from(node: &'a crate::StmtFunctionDef) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtFunctionDef>) -> Self { Self::FunctionDef(node) } } -impl<'a> From<&'a crate::StmtClassDef> for StmtRef<'a> { - fn from(node: &'a crate::StmtClassDef) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtClassDef>) -> Self { Self::ClassDef(node) } } -impl<'a> From<&'a crate::StmtReturn> for StmtRef<'a> { - fn from(node: &'a crate::StmtReturn) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtReturn>) -> Self { Self::Return(node) } } -impl<'a> From<&'a crate::StmtDelete> for StmtRef<'a> { - fn from(node: &'a crate::StmtDelete) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtDelete>) -> Self { Self::Delete(node) } } -impl<'a> From<&'a crate::StmtTypeAlias> for StmtRef<'a> { - fn from(node: &'a crate::StmtTypeAlias) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtTypeAlias>) -> Self { Self::TypeAlias(node) } } -impl<'a> From<&'a crate::StmtAssign> for StmtRef<'a> { - fn from(node: &'a crate::StmtAssign) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAssign>) -> Self { Self::Assign(node) } } -impl<'a> From<&'a crate::StmtAugAssign> for StmtRef<'a> { - fn from(node: &'a crate::StmtAugAssign) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAugAssign>) -> Self { Self::AugAssign(node) } } -impl<'a> From<&'a crate::StmtAnnAssign> for StmtRef<'a> { - fn from(node: &'a crate::StmtAnnAssign) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAnnAssign>) -> Self { Self::AnnAssign(node) } } -impl<'a> From<&'a crate::StmtFor> for StmtRef<'a> { - fn from(node: &'a crate::StmtFor) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtFor>) -> Self { Self::For(node) } } -impl<'a> From<&'a crate::StmtWhile> for StmtRef<'a> { - fn from(node: &'a crate::StmtWhile) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtWhile>) -> Self { Self::While(node) } } -impl<'a> From<&'a crate::StmtIf> for StmtRef<'a> { - fn from(node: &'a crate::StmtIf) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtIf>) -> Self { Self::If(node) } } -impl<'a> From<&'a crate::StmtWith> for StmtRef<'a> { - fn from(node: &'a crate::StmtWith) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtWith>) -> Self { Self::With(node) } } -impl<'a> From<&'a crate::StmtMatch> for StmtRef<'a> { - fn from(node: &'a crate::StmtMatch) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtMatch>) -> Self { Self::Match(node) } } -impl<'a> From<&'a crate::StmtRaise> for StmtRef<'a> { - fn from(node: &'a crate::StmtRaise) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtRaise>) -> Self { Self::Raise(node) } } -impl<'a> From<&'a crate::StmtTry> for StmtRef<'a> { - fn from(node: &'a crate::StmtTry) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtTry>) -> Self { Self::Try(node) } } -impl<'a> From<&'a crate::StmtAssert> for StmtRef<'a> { - fn from(node: &'a crate::StmtAssert) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAssert>) -> Self { Self::Assert(node) } } -impl<'a> From<&'a crate::StmtImport> for StmtRef<'a> { - fn from(node: &'a crate::StmtImport) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtImport>) -> Self { Self::Import(node) } } -impl<'a> From<&'a crate::StmtImportFrom> for StmtRef<'a> { - fn from(node: &'a crate::StmtImportFrom) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtImportFrom>) -> Self { Self::ImportFrom(node) } } -impl<'a> From<&'a crate::StmtGlobal> for StmtRef<'a> { - fn from(node: &'a crate::StmtGlobal) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtGlobal>) -> Self { Self::Global(node) } } -impl<'a> From<&'a crate::StmtNonlocal> for StmtRef<'a> { - fn from(node: &'a crate::StmtNonlocal) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtNonlocal>) -> Self { Self::Nonlocal(node) } } -impl<'a> From<&'a crate::StmtExpr> for StmtRef<'a> { - fn from(node: &'a crate::StmtExpr) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtExpr>) -> Self { Self::Expr(node) } } -impl<'a> From<&'a crate::StmtPass> for StmtRef<'a> { - fn from(node: &'a crate::StmtPass) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtPass>) -> Self { Self::Pass(node) } } -impl<'a> From<&'a crate::StmtBreak> for StmtRef<'a> { - fn from(node: &'a crate::StmtBreak) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtBreak>) -> Self { Self::Break(node) } } -impl<'a> From<&'a crate::StmtContinue> for StmtRef<'a> { - fn from(node: &'a crate::StmtContinue) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtContinue>) -> Self { Self::Continue(node) } } -impl<'a> From<&'a crate::StmtIpyEscapeCommand> for StmtRef<'a> { - fn from(node: &'a crate::StmtIpyEscapeCommand) -> Self { +impl<'a> From> for StmtRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtIpyEscapeCommand>) -> Self { Self::IpyEscapeCommand(node) } } @@ -1737,298 +2615,298 @@ impl ruff_text_size::Ranged for StmtRef<'_> { #[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] pub enum ExprRef<'a> { #[is(name = "bool_op_expr")] - BoolOp(&'a crate::ExprBoolOp), + BoolOp(crate::Node<'a, &'a crate::ExprBoolOp>), #[is(name = "named_expr")] - Named(&'a crate::ExprNamed), + Named(crate::Node<'a, &'a crate::ExprNamed>), #[is(name = "bin_op_expr")] - BinOp(&'a crate::ExprBinOp), + BinOp(crate::Node<'a, &'a crate::ExprBinOp>), #[is(name = "unary_op_expr")] - UnaryOp(&'a crate::ExprUnaryOp), + UnaryOp(crate::Node<'a, &'a crate::ExprUnaryOp>), #[is(name = "lambda_expr")] - Lambda(&'a crate::ExprLambda), + Lambda(crate::Node<'a, &'a crate::ExprLambda>), #[is(name = "if_expr")] - If(&'a crate::ExprIf), + If(crate::Node<'a, &'a crate::ExprIf>), #[is(name = "dict_expr")] - Dict(&'a crate::ExprDict), + Dict(crate::Node<'a, &'a crate::ExprDict>), #[is(name = "set_expr")] - Set(&'a crate::ExprSet), + Set(crate::Node<'a, &'a crate::ExprSet>), #[is(name = "list_comp_expr")] - ListComp(&'a crate::ExprListComp), + ListComp(crate::Node<'a, &'a crate::ExprListComp>), #[is(name = "set_comp_expr")] - SetComp(&'a crate::ExprSetComp), + SetComp(crate::Node<'a, &'a crate::ExprSetComp>), #[is(name = "dict_comp_expr")] - DictComp(&'a crate::ExprDictComp), + DictComp(crate::Node<'a, &'a crate::ExprDictComp>), #[is(name = "generator_expr")] - Generator(&'a crate::ExprGenerator), + Generator(crate::Node<'a, &'a crate::ExprGenerator>), #[is(name = "await_expr")] - Await(&'a crate::ExprAwait), + Await(crate::Node<'a, &'a crate::ExprAwait>), #[is(name = "yield_expr")] - Yield(&'a crate::ExprYield), + Yield(crate::Node<'a, &'a crate::ExprYield>), #[is(name = "yield_from_expr")] - YieldFrom(&'a crate::ExprYieldFrom), + YieldFrom(crate::Node<'a, &'a crate::ExprYieldFrom>), #[is(name = "compare_expr")] - Compare(&'a crate::ExprCompare), + Compare(crate::Node<'a, &'a crate::ExprCompare>), #[is(name = "call_expr")] - Call(&'a crate::ExprCall), + Call(crate::Node<'a, &'a crate::ExprCall>), #[is(name = "f_string_expr")] - FString(&'a crate::ExprFString), + FString(crate::Node<'a, &'a crate::ExprFString>), #[is(name = "string_literal_expr")] - StringLiteral(&'a crate::ExprStringLiteral), + StringLiteral(crate::Node<'a, &'a crate::ExprStringLiteral>), #[is(name = "bytes_literal_expr")] - BytesLiteral(&'a crate::ExprBytesLiteral), + BytesLiteral(crate::Node<'a, &'a crate::ExprBytesLiteral>), #[is(name = "number_literal_expr")] - NumberLiteral(&'a crate::ExprNumberLiteral), + NumberLiteral(crate::Node<'a, &'a crate::ExprNumberLiteral>), #[is(name = "boolean_literal_expr")] - BooleanLiteral(&'a crate::ExprBooleanLiteral), + BooleanLiteral(crate::Node<'a, &'a crate::ExprBooleanLiteral>), #[is(name = "none_literal_expr")] - NoneLiteral(&'a crate::ExprNoneLiteral), + NoneLiteral(crate::Node<'a, &'a crate::ExprNoneLiteral>), #[is(name = "ellipsis_literal_expr")] - EllipsisLiteral(&'a crate::ExprEllipsisLiteral), + EllipsisLiteral(crate::Node<'a, &'a crate::ExprEllipsisLiteral>), #[is(name = "attribute_expr")] - Attribute(&'a crate::ExprAttribute), + Attribute(crate::Node<'a, &'a crate::ExprAttribute>), #[is(name = "subscript_expr")] - Subscript(&'a crate::ExprSubscript), + Subscript(crate::Node<'a, &'a crate::ExprSubscript>), #[is(name = "starred_expr")] - Starred(&'a crate::ExprStarred), + Starred(crate::Node<'a, &'a crate::ExprStarred>), #[is(name = "name_expr")] - Name(&'a crate::ExprName), + Name(crate::Node<'a, &'a crate::ExprName>), #[is(name = "list_expr")] - List(&'a crate::ExprList), + List(crate::Node<'a, &'a crate::ExprList>), #[is(name = "tuple_expr")] - Tuple(&'a crate::ExprTuple), + Tuple(crate::Node<'a, &'a crate::ExprTuple>), #[is(name = "slice_expr")] - Slice(&'a crate::ExprSlice), + Slice(crate::Node<'a, &'a crate::ExprSlice>), #[is(name = "ipy_escape_command_expr")] - IpyEscapeCommand(&'a crate::ExprIpyEscapeCommand), + IpyEscapeCommand(crate::Node<'a, &'a crate::ExprIpyEscapeCommand>), } -impl<'a> From<&'a Expr> for ExprRef<'a> { - fn from(node: &'a Expr) -> Self { - match node { - Expr::BoolOp(node) => ExprRef::BoolOp(node), - Expr::Named(node) => ExprRef::Named(node), - Expr::BinOp(node) => ExprRef::BinOp(node), - Expr::UnaryOp(node) => ExprRef::UnaryOp(node), - Expr::Lambda(node) => ExprRef::Lambda(node), - Expr::If(node) => ExprRef::If(node), - Expr::Dict(node) => ExprRef::Dict(node), - Expr::Set(node) => ExprRef::Set(node), - Expr::ListComp(node) => ExprRef::ListComp(node), - Expr::SetComp(node) => ExprRef::SetComp(node), - Expr::DictComp(node) => ExprRef::DictComp(node), - Expr::Generator(node) => ExprRef::Generator(node), - Expr::Await(node) => ExprRef::Await(node), - Expr::Yield(node) => ExprRef::Yield(node), - Expr::YieldFrom(node) => ExprRef::YieldFrom(node), - Expr::Compare(node) => ExprRef::Compare(node), - Expr::Call(node) => ExprRef::Call(node), - Expr::FString(node) => ExprRef::FString(node), - Expr::StringLiteral(node) => ExprRef::StringLiteral(node), - Expr::BytesLiteral(node) => ExprRef::BytesLiteral(node), - Expr::NumberLiteral(node) => ExprRef::NumberLiteral(node), - Expr::BooleanLiteral(node) => ExprRef::BooleanLiteral(node), - Expr::NoneLiteral(node) => ExprRef::NoneLiteral(node), - Expr::EllipsisLiteral(node) => ExprRef::EllipsisLiteral(node), - Expr::Attribute(node) => ExprRef::Attribute(node), - Expr::Subscript(node) => ExprRef::Subscript(node), - Expr::Starred(node) => ExprRef::Starred(node), - Expr::Name(node) => ExprRef::Name(node), - Expr::List(node) => ExprRef::List(node), - Expr::Tuple(node) => ExprRef::Tuple(node), - Expr::Slice(node) => ExprRef::Slice(node), - Expr::IpyEscapeCommand(node) => ExprRef::IpyEscapeCommand(node), +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a Expr>) -> Self { + match node.node { + Expr::BoolOp(n) => ExprRef::BoolOp(node.ast.wrap(n)), + Expr::Named(n) => ExprRef::Named(node.ast.wrap(n)), + Expr::BinOp(n) => ExprRef::BinOp(node.ast.wrap(n)), + Expr::UnaryOp(n) => ExprRef::UnaryOp(node.ast.wrap(n)), + Expr::Lambda(n) => ExprRef::Lambda(node.ast.wrap(n)), + Expr::If(n) => ExprRef::If(node.ast.wrap(n)), + Expr::Dict(n) => ExprRef::Dict(node.ast.wrap(n)), + Expr::Set(n) => ExprRef::Set(node.ast.wrap(n)), + Expr::ListComp(n) => ExprRef::ListComp(node.ast.wrap(n)), + Expr::SetComp(n) => ExprRef::SetComp(node.ast.wrap(n)), + Expr::DictComp(n) => ExprRef::DictComp(node.ast.wrap(n)), + Expr::Generator(n) => ExprRef::Generator(node.ast.wrap(n)), + Expr::Await(n) => ExprRef::Await(node.ast.wrap(n)), + Expr::Yield(n) => ExprRef::Yield(node.ast.wrap(n)), + Expr::YieldFrom(n) => ExprRef::YieldFrom(node.ast.wrap(n)), + Expr::Compare(n) => ExprRef::Compare(node.ast.wrap(n)), + Expr::Call(n) => ExprRef::Call(node.ast.wrap(n)), + Expr::FString(n) => ExprRef::FString(node.ast.wrap(n)), + Expr::StringLiteral(n) => ExprRef::StringLiteral(node.ast.wrap(n)), + Expr::BytesLiteral(n) => ExprRef::BytesLiteral(node.ast.wrap(n)), + Expr::NumberLiteral(n) => ExprRef::NumberLiteral(node.ast.wrap(n)), + Expr::BooleanLiteral(n) => ExprRef::BooleanLiteral(node.ast.wrap(n)), + Expr::NoneLiteral(n) => ExprRef::NoneLiteral(node.ast.wrap(n)), + Expr::EllipsisLiteral(n) => ExprRef::EllipsisLiteral(node.ast.wrap(n)), + Expr::Attribute(n) => ExprRef::Attribute(node.ast.wrap(n)), + Expr::Subscript(n) => ExprRef::Subscript(node.ast.wrap(n)), + Expr::Starred(n) => ExprRef::Starred(node.ast.wrap(n)), + Expr::Name(n) => ExprRef::Name(node.ast.wrap(n)), + Expr::List(n) => ExprRef::List(node.ast.wrap(n)), + Expr::Tuple(n) => ExprRef::Tuple(node.ast.wrap(n)), + Expr::Slice(n) => ExprRef::Slice(node.ast.wrap(n)), + Expr::IpyEscapeCommand(n) => ExprRef::IpyEscapeCommand(node.ast.wrap(n)), } } } -impl<'a> From<&'a crate::ExprBoolOp> for ExprRef<'a> { - fn from(node: &'a crate::ExprBoolOp) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBoolOp>) -> Self { Self::BoolOp(node) } } -impl<'a> From<&'a crate::ExprNamed> for ExprRef<'a> { - fn from(node: &'a crate::ExprNamed) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprNamed>) -> Self { Self::Named(node) } } -impl<'a> From<&'a crate::ExprBinOp> for ExprRef<'a> { - fn from(node: &'a crate::ExprBinOp) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBinOp>) -> Self { Self::BinOp(node) } } -impl<'a> From<&'a crate::ExprUnaryOp> for ExprRef<'a> { - fn from(node: &'a crate::ExprUnaryOp) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprUnaryOp>) -> Self { Self::UnaryOp(node) } } -impl<'a> From<&'a crate::ExprLambda> for ExprRef<'a> { - fn from(node: &'a crate::ExprLambda) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprLambda>) -> Self { Self::Lambda(node) } } -impl<'a> From<&'a crate::ExprIf> for ExprRef<'a> { - fn from(node: &'a crate::ExprIf) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprIf>) -> Self { Self::If(node) } } -impl<'a> From<&'a crate::ExprDict> for ExprRef<'a> { - fn from(node: &'a crate::ExprDict) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprDict>) -> Self { Self::Dict(node) } } -impl<'a> From<&'a crate::ExprSet> for ExprRef<'a> { - fn from(node: &'a crate::ExprSet) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSet>) -> Self { Self::Set(node) } } -impl<'a> From<&'a crate::ExprListComp> for ExprRef<'a> { - fn from(node: &'a crate::ExprListComp) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprListComp>) -> Self { Self::ListComp(node) } } -impl<'a> From<&'a crate::ExprSetComp> for ExprRef<'a> { - fn from(node: &'a crate::ExprSetComp) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSetComp>) -> Self { Self::SetComp(node) } } -impl<'a> From<&'a crate::ExprDictComp> for ExprRef<'a> { - fn from(node: &'a crate::ExprDictComp) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprDictComp>) -> Self { Self::DictComp(node) } } -impl<'a> From<&'a crate::ExprGenerator> for ExprRef<'a> { - fn from(node: &'a crate::ExprGenerator) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprGenerator>) -> Self { Self::Generator(node) } } -impl<'a> From<&'a crate::ExprAwait> for ExprRef<'a> { - fn from(node: &'a crate::ExprAwait) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprAwait>) -> Self { Self::Await(node) } } -impl<'a> From<&'a crate::ExprYield> for ExprRef<'a> { - fn from(node: &'a crate::ExprYield) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprYield>) -> Self { Self::Yield(node) } } -impl<'a> From<&'a crate::ExprYieldFrom> for ExprRef<'a> { - fn from(node: &'a crate::ExprYieldFrom) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprYieldFrom>) -> Self { Self::YieldFrom(node) } } -impl<'a> From<&'a crate::ExprCompare> for ExprRef<'a> { - fn from(node: &'a crate::ExprCompare) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprCompare>) -> Self { Self::Compare(node) } } -impl<'a> From<&'a crate::ExprCall> for ExprRef<'a> { - fn from(node: &'a crate::ExprCall) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprCall>) -> Self { Self::Call(node) } } -impl<'a> From<&'a crate::ExprFString> for ExprRef<'a> { - fn from(node: &'a crate::ExprFString) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprFString>) -> Self { Self::FString(node) } } -impl<'a> From<&'a crate::ExprStringLiteral> for ExprRef<'a> { - fn from(node: &'a crate::ExprStringLiteral) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprStringLiteral>) -> Self { Self::StringLiteral(node) } } -impl<'a> From<&'a crate::ExprBytesLiteral> for ExprRef<'a> { - fn from(node: &'a crate::ExprBytesLiteral) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBytesLiteral>) -> Self { Self::BytesLiteral(node) } } -impl<'a> From<&'a crate::ExprNumberLiteral> for ExprRef<'a> { - fn from(node: &'a crate::ExprNumberLiteral) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprNumberLiteral>) -> Self { Self::NumberLiteral(node) } } -impl<'a> From<&'a crate::ExprBooleanLiteral> for ExprRef<'a> { - fn from(node: &'a crate::ExprBooleanLiteral) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBooleanLiteral>) -> Self { Self::BooleanLiteral(node) } } -impl<'a> From<&'a crate::ExprNoneLiteral> for ExprRef<'a> { - fn from(node: &'a crate::ExprNoneLiteral) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprNoneLiteral>) -> Self { Self::NoneLiteral(node) } } -impl<'a> From<&'a crate::ExprEllipsisLiteral> for ExprRef<'a> { - fn from(node: &'a crate::ExprEllipsisLiteral) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprEllipsisLiteral>) -> Self { Self::EllipsisLiteral(node) } } -impl<'a> From<&'a crate::ExprAttribute> for ExprRef<'a> { - fn from(node: &'a crate::ExprAttribute) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprAttribute>) -> Self { Self::Attribute(node) } } -impl<'a> From<&'a crate::ExprSubscript> for ExprRef<'a> { - fn from(node: &'a crate::ExprSubscript) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSubscript>) -> Self { Self::Subscript(node) } } -impl<'a> From<&'a crate::ExprStarred> for ExprRef<'a> { - fn from(node: &'a crate::ExprStarred) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprStarred>) -> Self { Self::Starred(node) } } -impl<'a> From<&'a crate::ExprName> for ExprRef<'a> { - fn from(node: &'a crate::ExprName) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprName>) -> Self { Self::Name(node) } } -impl<'a> From<&'a crate::ExprList> for ExprRef<'a> { - fn from(node: &'a crate::ExprList) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprList>) -> Self { Self::List(node) } } -impl<'a> From<&'a crate::ExprTuple> for ExprRef<'a> { - fn from(node: &'a crate::ExprTuple) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprTuple>) -> Self { Self::Tuple(node) } } -impl<'a> From<&'a crate::ExprSlice> for ExprRef<'a> { - fn from(node: &'a crate::ExprSlice) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSlice>) -> Self { Self::Slice(node) } } -impl<'a> From<&'a crate::ExprIpyEscapeCommand> for ExprRef<'a> { - fn from(node: &'a crate::ExprIpyEscapeCommand) -> Self { +impl<'a> From> for ExprRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprIpyEscapeCommand>) -> Self { Self::IpyEscapeCommand(node) } } @@ -2075,19 +2953,19 @@ impl ruff_text_size::Ranged for ExprRef<'_> { /// See also [excepthandler](https://docs.python.org/3/library/ast.html#ast.excepthandler) #[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] pub enum ExceptHandlerRef<'a> { - ExceptHandler(&'a crate::ExceptHandlerExceptHandler), + ExceptHandler(crate::Node<'a, &'a crate::ExceptHandlerExceptHandler>), } -impl<'a> From<&'a ExceptHandler> for ExceptHandlerRef<'a> { - fn from(node: &'a ExceptHandler) -> Self { - match node { - ExceptHandler::ExceptHandler(node) => ExceptHandlerRef::ExceptHandler(node), +impl<'a> From> for ExceptHandlerRef<'a> { + fn from(node: crate::Node<'a, &'a ExceptHandler>) -> Self { + match node.node { + ExceptHandler::ExceptHandler(n) => ExceptHandlerRef::ExceptHandler(node.ast.wrap(n)), } } } -impl<'a> From<&'a crate::ExceptHandlerExceptHandler> for ExceptHandlerRef<'a> { - fn from(node: &'a crate::ExceptHandlerExceptHandler) -> Self { +impl<'a> From> for ExceptHandlerRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExceptHandlerExceptHandler>) -> Self { Self::ExceptHandler(node) } } @@ -2102,27 +2980,27 @@ impl ruff_text_size::Ranged for ExceptHandlerRef<'_> { #[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] pub enum FStringElementRef<'a> { - Expression(&'a crate::FStringExpressionElement), - Literal(&'a crate::FStringLiteralElement), + Expression(crate::Node<'a, &'a crate::FStringExpressionElement>), + Literal(crate::Node<'a, &'a crate::FStringLiteralElement>), } -impl<'a> From<&'a FStringElement> for FStringElementRef<'a> { - fn from(node: &'a FStringElement) -> Self { - match node { - FStringElement::Expression(node) => FStringElementRef::Expression(node), - FStringElement::Literal(node) => FStringElementRef::Literal(node), +impl<'a> From> for FStringElementRef<'a> { + fn from(node: crate::Node<'a, &'a FStringElement>) -> Self { + match node.node { + FStringElement::Expression(n) => FStringElementRef::Expression(node.ast.wrap(n)), + FStringElement::Literal(n) => FStringElementRef::Literal(node.ast.wrap(n)), } } } -impl<'a> From<&'a crate::FStringExpressionElement> for FStringElementRef<'a> { - fn from(node: &'a crate::FStringExpressionElement) -> Self { +impl<'a> From> for FStringElementRef<'a> { + fn from(node: crate::Node<'a, &'a crate::FStringExpressionElement>) -> Self { Self::Expression(node) } } -impl<'a> From<&'a crate::FStringLiteralElement> for FStringElementRef<'a> { - fn from(node: &'a crate::FStringLiteralElement) -> Self { +impl<'a> From> for FStringElementRef<'a> { + fn from(node: crate::Node<'a, &'a crate::FStringLiteralElement>) -> Self { Self::Literal(node) } } @@ -2139,75 +3017,75 @@ impl ruff_text_size::Ranged for FStringElementRef<'_> { /// See also [pattern](https://docs.python.org/3/library/ast.html#ast.pattern) #[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] pub enum PatternRef<'a> { - MatchValue(&'a crate::PatternMatchValue), - MatchSingleton(&'a crate::PatternMatchSingleton), - MatchSequence(&'a crate::PatternMatchSequence), - MatchMapping(&'a crate::PatternMatchMapping), - MatchClass(&'a crate::PatternMatchClass), - MatchStar(&'a crate::PatternMatchStar), - MatchAs(&'a crate::PatternMatchAs), - MatchOr(&'a crate::PatternMatchOr), + MatchValue(crate::Node<'a, &'a crate::PatternMatchValue>), + MatchSingleton(crate::Node<'a, &'a crate::PatternMatchSingleton>), + MatchSequence(crate::Node<'a, &'a crate::PatternMatchSequence>), + MatchMapping(crate::Node<'a, &'a crate::PatternMatchMapping>), + MatchClass(crate::Node<'a, &'a crate::PatternMatchClass>), + MatchStar(crate::Node<'a, &'a crate::PatternMatchStar>), + MatchAs(crate::Node<'a, &'a crate::PatternMatchAs>), + MatchOr(crate::Node<'a, &'a crate::PatternMatchOr>), } -impl<'a> From<&'a Pattern> for PatternRef<'a> { - fn from(node: &'a Pattern) -> Self { - match node { - Pattern::MatchValue(node) => PatternRef::MatchValue(node), - Pattern::MatchSingleton(node) => PatternRef::MatchSingleton(node), - Pattern::MatchSequence(node) => PatternRef::MatchSequence(node), - Pattern::MatchMapping(node) => PatternRef::MatchMapping(node), - Pattern::MatchClass(node) => PatternRef::MatchClass(node), - Pattern::MatchStar(node) => PatternRef::MatchStar(node), - Pattern::MatchAs(node) => PatternRef::MatchAs(node), - Pattern::MatchOr(node) => PatternRef::MatchOr(node), +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a Pattern>) -> Self { + match node.node { + Pattern::MatchValue(n) => PatternRef::MatchValue(node.ast.wrap(n)), + Pattern::MatchSingleton(n) => PatternRef::MatchSingleton(node.ast.wrap(n)), + Pattern::MatchSequence(n) => PatternRef::MatchSequence(node.ast.wrap(n)), + Pattern::MatchMapping(n) => PatternRef::MatchMapping(node.ast.wrap(n)), + Pattern::MatchClass(n) => PatternRef::MatchClass(node.ast.wrap(n)), + Pattern::MatchStar(n) => PatternRef::MatchStar(node.ast.wrap(n)), + Pattern::MatchAs(n) => PatternRef::MatchAs(node.ast.wrap(n)), + Pattern::MatchOr(n) => PatternRef::MatchOr(node.ast.wrap(n)), } } } -impl<'a> From<&'a crate::PatternMatchValue> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchValue) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchValue>) -> Self { Self::MatchValue(node) } } -impl<'a> From<&'a crate::PatternMatchSingleton> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchSingleton) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchSingleton>) -> Self { Self::MatchSingleton(node) } } -impl<'a> From<&'a crate::PatternMatchSequence> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchSequence) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchSequence>) -> Self { Self::MatchSequence(node) } } -impl<'a> From<&'a crate::PatternMatchMapping> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchMapping) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchMapping>) -> Self { Self::MatchMapping(node) } } -impl<'a> From<&'a crate::PatternMatchClass> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchClass) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchClass>) -> Self { Self::MatchClass(node) } } -impl<'a> From<&'a crate::PatternMatchStar> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchStar) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchStar>) -> Self { Self::MatchStar(node) } } -impl<'a> From<&'a crate::PatternMatchAs> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchAs) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchAs>) -> Self { Self::MatchAs(node) } } -impl<'a> From<&'a crate::PatternMatchOr> for PatternRef<'a> { - fn from(node: &'a crate::PatternMatchOr) -> Self { +impl<'a> From> for PatternRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchOr>) -> Self { Self::MatchOr(node) } } @@ -2230,35 +3108,35 @@ impl ruff_text_size::Ranged for PatternRef<'_> { /// See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param) #[derive(Clone, Copy, Debug, PartialEq, is_macro::Is)] pub enum TypeParamRef<'a> { - TypeVar(&'a crate::TypeParamTypeVar), - TypeVarTuple(&'a crate::TypeParamTypeVarTuple), - ParamSpec(&'a crate::TypeParamParamSpec), + TypeVar(crate::Node<'a, &'a crate::TypeParamTypeVar>), + TypeVarTuple(crate::Node<'a, &'a crate::TypeParamTypeVarTuple>), + ParamSpec(crate::Node<'a, &'a crate::TypeParamParamSpec>), } -impl<'a> From<&'a TypeParam> for TypeParamRef<'a> { - fn from(node: &'a TypeParam) -> Self { - match node { - TypeParam::TypeVar(node) => TypeParamRef::TypeVar(node), - TypeParam::TypeVarTuple(node) => TypeParamRef::TypeVarTuple(node), - TypeParam::ParamSpec(node) => TypeParamRef::ParamSpec(node), +impl<'a> From> for TypeParamRef<'a> { + fn from(node: crate::Node<'a, &'a TypeParam>) -> Self { + match node.node { + TypeParam::TypeVar(n) => TypeParamRef::TypeVar(node.ast.wrap(n)), + TypeParam::TypeVarTuple(n) => TypeParamRef::TypeVarTuple(node.ast.wrap(n)), + TypeParam::ParamSpec(n) => TypeParamRef::ParamSpec(node.ast.wrap(n)), } } } -impl<'a> From<&'a crate::TypeParamTypeVar> for TypeParamRef<'a> { - fn from(node: &'a crate::TypeParamTypeVar) -> Self { +impl<'a> From> for TypeParamRef<'a> { + fn from(node: crate::Node<'a, &'a crate::TypeParamTypeVar>) -> Self { Self::TypeVar(node) } } -impl<'a> From<&'a crate::TypeParamTypeVarTuple> for TypeParamRef<'a> { - fn from(node: &'a crate::TypeParamTypeVarTuple) -> Self { +impl<'a> From> for TypeParamRef<'a> { + fn from(node: crate::Node<'a, &'a crate::TypeParamTypeVarTuple>) -> Self { Self::TypeVarTuple(node) } } -impl<'a> From<&'a crate::TypeParamParamSpec> for TypeParamRef<'a> { - fn from(node: &'a crate::TypeParamParamSpec) -> Self { +impl<'a> From> for TypeParamRef<'a> { + fn from(node: crate::Node<'a, &'a crate::TypeParamParamSpec>) -> Self { Self::ParamSpec(node) } } @@ -2273,107 +3151,2675 @@ impl ruff_text_size::Ranged for TypeParamRef<'_> { } } -#[derive(Copy, Clone, Debug, is_macro::Is, PartialEq)] -pub enum AnyNodeRef<'a> { - ModModule(&'a crate::ModModule), - ModExpression(&'a crate::ModExpression), - StmtFunctionDef(&'a crate::StmtFunctionDef), - StmtClassDef(&'a crate::StmtClassDef), - StmtReturn(&'a crate::StmtReturn), - StmtDelete(&'a crate::StmtDelete), - StmtTypeAlias(&'a crate::StmtTypeAlias), - StmtAssign(&'a crate::StmtAssign), - StmtAugAssign(&'a crate::StmtAugAssign), - StmtAnnAssign(&'a crate::StmtAnnAssign), - StmtFor(&'a crate::StmtFor), - StmtWhile(&'a crate::StmtWhile), - StmtIf(&'a crate::StmtIf), - StmtWith(&'a crate::StmtWith), - StmtMatch(&'a crate::StmtMatch), - StmtRaise(&'a crate::StmtRaise), - StmtTry(&'a crate::StmtTry), - StmtAssert(&'a crate::StmtAssert), - StmtImport(&'a crate::StmtImport), - StmtImportFrom(&'a crate::StmtImportFrom), - StmtGlobal(&'a crate::StmtGlobal), - StmtNonlocal(&'a crate::StmtNonlocal), - StmtExpr(&'a crate::StmtExpr), - StmtPass(&'a crate::StmtPass), - StmtBreak(&'a crate::StmtBreak), - StmtContinue(&'a crate::StmtContinue), - StmtIpyEscapeCommand(&'a crate::StmtIpyEscapeCommand), - ExprBoolOp(&'a crate::ExprBoolOp), - ExprNamed(&'a crate::ExprNamed), - ExprBinOp(&'a crate::ExprBinOp), - ExprUnaryOp(&'a crate::ExprUnaryOp), - ExprLambda(&'a crate::ExprLambda), - ExprIf(&'a crate::ExprIf), - ExprDict(&'a crate::ExprDict), - ExprSet(&'a crate::ExprSet), - ExprListComp(&'a crate::ExprListComp), - ExprSetComp(&'a crate::ExprSetComp), - ExprDictComp(&'a crate::ExprDictComp), - ExprGenerator(&'a crate::ExprGenerator), - ExprAwait(&'a crate::ExprAwait), - ExprYield(&'a crate::ExprYield), - ExprYieldFrom(&'a crate::ExprYieldFrom), - ExprCompare(&'a crate::ExprCompare), - ExprCall(&'a crate::ExprCall), - ExprFString(&'a crate::ExprFString), - ExprStringLiteral(&'a crate::ExprStringLiteral), - ExprBytesLiteral(&'a crate::ExprBytesLiteral), - ExprNumberLiteral(&'a crate::ExprNumberLiteral), - ExprBooleanLiteral(&'a crate::ExprBooleanLiteral), - ExprNoneLiteral(&'a crate::ExprNoneLiteral), - ExprEllipsisLiteral(&'a crate::ExprEllipsisLiteral), - ExprAttribute(&'a crate::ExprAttribute), - ExprSubscript(&'a crate::ExprSubscript), - ExprStarred(&'a crate::ExprStarred), - ExprName(&'a crate::ExprName), - ExprList(&'a crate::ExprList), - ExprTuple(&'a crate::ExprTuple), - ExprSlice(&'a crate::ExprSlice), - ExprIpyEscapeCommand(&'a crate::ExprIpyEscapeCommand), - ExceptHandlerExceptHandler(&'a crate::ExceptHandlerExceptHandler), - FStringExpressionElement(&'a crate::FStringExpressionElement), - FStringLiteralElement(&'a crate::FStringLiteralElement), - PatternMatchValue(&'a crate::PatternMatchValue), - PatternMatchSingleton(&'a crate::PatternMatchSingleton), - PatternMatchSequence(&'a crate::PatternMatchSequence), - PatternMatchMapping(&'a crate::PatternMatchMapping), - PatternMatchClass(&'a crate::PatternMatchClass), - PatternMatchStar(&'a crate::PatternMatchStar), - PatternMatchAs(&'a crate::PatternMatchAs), - PatternMatchOr(&'a crate::PatternMatchOr), - TypeParamTypeVar(&'a crate::TypeParamTypeVar), - TypeParamTypeVarTuple(&'a crate::TypeParamTypeVarTuple), - TypeParamParamSpec(&'a crate::TypeParamParamSpec), - FStringFormatSpec(&'a crate::FStringFormatSpec), - PatternArguments(&'a crate::PatternArguments), - PatternKeyword(&'a crate::PatternKeyword), - Comprehension(&'a crate::Comprehension), - Arguments(&'a crate::Arguments), - Parameters(&'a crate::Parameters), - Parameter(&'a crate::Parameter), - ParameterWithDefault(&'a crate::ParameterWithDefault), - Keyword(&'a crate::Keyword), - Alias(&'a crate::Alias), - WithItem(&'a crate::WithItem), - MatchCase(&'a crate::MatchCase), - Decorator(&'a crate::Decorator), - ElifElseClause(&'a crate::ElifElseClause), - TypeParams(&'a crate::TypeParams), - FString(&'a crate::FString), - StringLiteral(&'a crate::StringLiteral), - BytesLiteral(&'a crate::BytesLiteral), - Identifier(&'a crate::Identifier), +impl<'a> ModRef<'a> { + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + { + match self { + ModRef::Module(node) => node.visit_source_order(visitor), + ModRef::Expression(node) => node.visit_source_order(visitor), + } + } } -impl<'a> From<&'a Mod> for AnyNodeRef<'a> { - fn from(node: &'a Mod) -> AnyNodeRef<'a> { - match node { - Mod::Module(node) => AnyNodeRef::ModModule(node), - Mod::Expression(node) => AnyNodeRef::ModExpression(node), +impl<'a> StmtRef<'a> { + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + { + match self { + StmtRef::FunctionDef(node) => node.visit_source_order(visitor), + StmtRef::ClassDef(node) => node.visit_source_order(visitor), + StmtRef::Return(node) => node.visit_source_order(visitor), + StmtRef::Delete(node) => node.visit_source_order(visitor), + StmtRef::TypeAlias(node) => node.visit_source_order(visitor), + StmtRef::Assign(node) => node.visit_source_order(visitor), + StmtRef::AugAssign(node) => node.visit_source_order(visitor), + StmtRef::AnnAssign(node) => node.visit_source_order(visitor), + StmtRef::For(node) => node.visit_source_order(visitor), + StmtRef::While(node) => node.visit_source_order(visitor), + StmtRef::If(node) => node.visit_source_order(visitor), + StmtRef::With(node) => node.visit_source_order(visitor), + StmtRef::Match(node) => node.visit_source_order(visitor), + StmtRef::Raise(node) => node.visit_source_order(visitor), + StmtRef::Try(node) => node.visit_source_order(visitor), + StmtRef::Assert(node) => node.visit_source_order(visitor), + StmtRef::Import(node) => node.visit_source_order(visitor), + StmtRef::ImportFrom(node) => node.visit_source_order(visitor), + StmtRef::Global(node) => node.visit_source_order(visitor), + StmtRef::Nonlocal(node) => node.visit_source_order(visitor), + StmtRef::Expr(node) => node.visit_source_order(visitor), + StmtRef::Pass(node) => node.visit_source_order(visitor), + StmtRef::Break(node) => node.visit_source_order(visitor), + StmtRef::Continue(node) => node.visit_source_order(visitor), + StmtRef::IpyEscapeCommand(node) => node.visit_source_order(visitor), + } + } +} + +impl<'a> ExprRef<'a> { + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + { + match self { + ExprRef::BoolOp(node) => node.visit_source_order(visitor), + ExprRef::Named(node) => node.visit_source_order(visitor), + ExprRef::BinOp(node) => node.visit_source_order(visitor), + ExprRef::UnaryOp(node) => node.visit_source_order(visitor), + ExprRef::Lambda(node) => node.visit_source_order(visitor), + ExprRef::If(node) => node.visit_source_order(visitor), + ExprRef::Dict(node) => node.visit_source_order(visitor), + ExprRef::Set(node) => node.visit_source_order(visitor), + ExprRef::ListComp(node) => node.visit_source_order(visitor), + ExprRef::SetComp(node) => node.visit_source_order(visitor), + ExprRef::DictComp(node) => node.visit_source_order(visitor), + ExprRef::Generator(node) => node.visit_source_order(visitor), + ExprRef::Await(node) => node.visit_source_order(visitor), + ExprRef::Yield(node) => node.visit_source_order(visitor), + ExprRef::YieldFrom(node) => node.visit_source_order(visitor), + ExprRef::Compare(node) => node.visit_source_order(visitor), + ExprRef::Call(node) => node.visit_source_order(visitor), + ExprRef::FString(node) => node.visit_source_order(visitor), + ExprRef::StringLiteral(node) => node.visit_source_order(visitor), + ExprRef::BytesLiteral(node) => node.visit_source_order(visitor), + ExprRef::NumberLiteral(node) => node.visit_source_order(visitor), + ExprRef::BooleanLiteral(node) => node.visit_source_order(visitor), + ExprRef::NoneLiteral(node) => node.visit_source_order(visitor), + ExprRef::EllipsisLiteral(node) => node.visit_source_order(visitor), + ExprRef::Attribute(node) => node.visit_source_order(visitor), + ExprRef::Subscript(node) => node.visit_source_order(visitor), + ExprRef::Starred(node) => node.visit_source_order(visitor), + ExprRef::Name(node) => node.visit_source_order(visitor), + ExprRef::List(node) => node.visit_source_order(visitor), + ExprRef::Tuple(node) => node.visit_source_order(visitor), + ExprRef::Slice(node) => node.visit_source_order(visitor), + ExprRef::IpyEscapeCommand(node) => node.visit_source_order(visitor), + } + } +} + +impl<'a> ExceptHandlerRef<'a> { + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + { + match self { + ExceptHandlerRef::ExceptHandler(node) => node.visit_source_order(visitor), + } + } +} + +impl<'a> FStringElementRef<'a> { + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + { + match self { + FStringElementRef::Expression(node) => node.visit_source_order(visitor), + FStringElementRef::Literal(node) => node.visit_source_order(visitor), + } + } +} + +impl<'a> PatternRef<'a> { + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + { + match self { + PatternRef::MatchValue(node) => node.visit_source_order(visitor), + PatternRef::MatchSingleton(node) => node.visit_source_order(visitor), + PatternRef::MatchSequence(node) => node.visit_source_order(visitor), + PatternRef::MatchMapping(node) => node.visit_source_order(visitor), + PatternRef::MatchClass(node) => node.visit_source_order(visitor), + PatternRef::MatchStar(node) => node.visit_source_order(visitor), + PatternRef::MatchAs(node) => node.visit_source_order(visitor), + PatternRef::MatchOr(node) => node.visit_source_order(visitor), + } + } +} + +impl<'a> TypeParamRef<'a> { + #[allow(unused)] + pub(crate) fn visit_source_order(self, visitor: &mut V) + where + V: crate::visitor::source_order::SourceOrderVisitor<'a> + ?Sized, + { + match self { + TypeParamRef::TypeVar(node) => node.visit_source_order(visitor), + TypeParamRef::TypeVarTuple(node) => node.visit_source_order(visitor), + TypeParamRef::ParamSpec(node) => node.visit_source_order(visitor), + } + } +} + +#[derive(Clone, Default, PartialEq)] +pub(crate) struct Storage { + pub(crate) mod_module: ruff_index::IndexVec, + pub(crate) mod_expression: ruff_index::IndexVec, + pub(crate) stmt_function_def: ruff_index::IndexVec, + pub(crate) stmt_class_def: ruff_index::IndexVec, + pub(crate) stmt_return: ruff_index::IndexVec, + pub(crate) stmt_delete: ruff_index::IndexVec, + pub(crate) stmt_type_alias: ruff_index::IndexVec, + pub(crate) stmt_assign: ruff_index::IndexVec, + pub(crate) stmt_aug_assign: ruff_index::IndexVec, + pub(crate) stmt_ann_assign: ruff_index::IndexVec, + pub(crate) stmt_for: ruff_index::IndexVec, + pub(crate) stmt_while: ruff_index::IndexVec, + pub(crate) stmt_if: ruff_index::IndexVec, + pub(crate) stmt_with: ruff_index::IndexVec, + pub(crate) stmt_match: ruff_index::IndexVec, + pub(crate) stmt_raise: ruff_index::IndexVec, + pub(crate) stmt_try: ruff_index::IndexVec, + pub(crate) stmt_assert: ruff_index::IndexVec, + pub(crate) stmt_import: ruff_index::IndexVec, + pub(crate) stmt_import_from: ruff_index::IndexVec, + pub(crate) stmt_global: ruff_index::IndexVec, + pub(crate) stmt_nonlocal: ruff_index::IndexVec, + pub(crate) stmt_expr: ruff_index::IndexVec, + pub(crate) stmt_pass: ruff_index::IndexVec, + pub(crate) stmt_break: ruff_index::IndexVec, + pub(crate) stmt_continue: ruff_index::IndexVec, + pub(crate) stmt_ipy_escape_command: + ruff_index::IndexVec, + pub(crate) expr_bool_op: ruff_index::IndexVec, + pub(crate) expr_named: ruff_index::IndexVec, + pub(crate) expr_bin_op: ruff_index::IndexVec, + pub(crate) expr_unary_op: ruff_index::IndexVec, + pub(crate) expr_lambda: ruff_index::IndexVec, + pub(crate) expr_if: ruff_index::IndexVec, + pub(crate) expr_dict: ruff_index::IndexVec, + pub(crate) expr_set: ruff_index::IndexVec, + pub(crate) expr_list_comp: ruff_index::IndexVec, + pub(crate) expr_set_comp: ruff_index::IndexVec, + pub(crate) expr_dict_comp: ruff_index::IndexVec, + pub(crate) expr_generator: ruff_index::IndexVec, + pub(crate) expr_await: ruff_index::IndexVec, + pub(crate) expr_yield: ruff_index::IndexVec, + pub(crate) expr_yield_from: ruff_index::IndexVec, + pub(crate) expr_compare: ruff_index::IndexVec, + pub(crate) expr_call: ruff_index::IndexVec, + pub(crate) expr_f_string: ruff_index::IndexVec, + pub(crate) expr_string_literal: + ruff_index::IndexVec, + pub(crate) expr_bytes_literal: + ruff_index::IndexVec, + pub(crate) expr_number_literal: + ruff_index::IndexVec, + pub(crate) expr_boolean_literal: + ruff_index::IndexVec, + pub(crate) expr_none_literal: ruff_index::IndexVec, + pub(crate) expr_ellipsis_literal: + ruff_index::IndexVec, + pub(crate) expr_attribute: ruff_index::IndexVec, + pub(crate) expr_subscript: ruff_index::IndexVec, + pub(crate) expr_starred: ruff_index::IndexVec, + pub(crate) expr_name: ruff_index::IndexVec, + pub(crate) expr_list: ruff_index::IndexVec, + pub(crate) expr_tuple: ruff_index::IndexVec, + pub(crate) expr_slice: ruff_index::IndexVec, + pub(crate) expr_ipy_escape_command: + ruff_index::IndexVec, + pub(crate) except_handler_except_handler: + ruff_index::IndexVec, + pub(crate) f_string_expression_element: + ruff_index::IndexVec, + pub(crate) f_string_literal_element: + ruff_index::IndexVec, + pub(crate) pattern_match_value: + ruff_index::IndexVec, + pub(crate) pattern_match_singleton: + ruff_index::IndexVec, + pub(crate) pattern_match_sequence: + ruff_index::IndexVec, + pub(crate) pattern_match_mapping: + ruff_index::IndexVec, + pub(crate) pattern_match_class: + ruff_index::IndexVec, + pub(crate) pattern_match_star: + ruff_index::IndexVec, + pub(crate) pattern_match_as: ruff_index::IndexVec, + pub(crate) pattern_match_or: ruff_index::IndexVec, + pub(crate) type_param_type_var: + ruff_index::IndexVec, + pub(crate) type_param_type_var_tuple: + ruff_index::IndexVec, + pub(crate) type_param_param_spec: + ruff_index::IndexVec, + pub(crate) f_string_format_spec: + ruff_index::IndexVec, + pub(crate) pattern_arguments: ruff_index::IndexVec, + pub(crate) pattern_keyword: ruff_index::IndexVec, + pub(crate) comprehension: ruff_index::IndexVec, + pub(crate) arguments: ruff_index::IndexVec, + pub(crate) parameters: ruff_index::IndexVec, + pub(crate) parameter: ruff_index::IndexVec, + pub(crate) parameter_with_default: + ruff_index::IndexVec, + pub(crate) keyword: ruff_index::IndexVec, + pub(crate) alias: ruff_index::IndexVec, + pub(crate) with_item: ruff_index::IndexVec, + pub(crate) match_case: ruff_index::IndexVec, + pub(crate) decorator: ruff_index::IndexVec, + pub(crate) elif_else_clause: ruff_index::IndexVec, + pub(crate) type_params: ruff_index::IndexVec, + pub(crate) f_string: ruff_index::IndexVec, + pub(crate) string_literal: ruff_index::IndexVec, + pub(crate) bytes_literal: ruff_index::IndexVec, + pub(crate) identifier: ruff_index::IndexVec, +} + +impl crate::ast::AstId for ModModuleId { + type Output<'a> = crate::Node<'a, &'a crate::ModModule>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.mod_module[self]) + } +} + +impl crate::ast::AstIdMut for ModModuleId { + type Output<'a> = crate::Node<'a, &'a mut crate::ModModule>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.mod_module[self]) + } +} + +impl<'a> crate::Node<'a, ModModuleId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ModModule> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ModExpressionId { + type Output<'a> = crate::Node<'a, &'a crate::ModExpression>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.mod_expression[self]) + } +} + +impl crate::ast::AstIdMut for ModExpressionId { + type Output<'a> = crate::Node<'a, &'a mut crate::ModExpression>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.mod_expression[self]) + } +} + +impl<'a> crate::Node<'a, ModExpressionId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ModExpression> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtFunctionDefId { + type Output<'a> = crate::Node<'a, &'a crate::StmtFunctionDef>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_function_def[self]) + } +} + +impl crate::ast::AstIdMut for StmtFunctionDefId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtFunctionDef>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_function_def[self]) + } +} + +impl<'a> crate::Node<'a, StmtFunctionDefId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtFunctionDef> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtClassDefId { + type Output<'a> = crate::Node<'a, &'a crate::StmtClassDef>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_class_def[self]) + } +} + +impl crate::ast::AstIdMut for StmtClassDefId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtClassDef>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_class_def[self]) + } +} + +impl<'a> crate::Node<'a, StmtClassDefId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtClassDef> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtReturnId { + type Output<'a> = crate::Node<'a, &'a crate::StmtReturn>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_return[self]) + } +} + +impl crate::ast::AstIdMut for StmtReturnId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtReturn>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_return[self]) + } +} + +impl<'a> crate::Node<'a, StmtReturnId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtReturn> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtDeleteId { + type Output<'a> = crate::Node<'a, &'a crate::StmtDelete>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_delete[self]) + } +} + +impl crate::ast::AstIdMut for StmtDeleteId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtDelete>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_delete[self]) + } +} + +impl<'a> crate::Node<'a, StmtDeleteId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtDelete> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtTypeAliasId { + type Output<'a> = crate::Node<'a, &'a crate::StmtTypeAlias>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_type_alias[self]) + } +} + +impl crate::ast::AstIdMut for StmtTypeAliasId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtTypeAlias>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_type_alias[self]) + } +} + +impl<'a> crate::Node<'a, StmtTypeAliasId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtTypeAlias> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtAssignId { + type Output<'a> = crate::Node<'a, &'a crate::StmtAssign>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_assign[self]) + } +} + +impl crate::ast::AstIdMut for StmtAssignId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtAssign>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_assign[self]) + } +} + +impl<'a> crate::Node<'a, StmtAssignId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtAssign> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtAugAssignId { + type Output<'a> = crate::Node<'a, &'a crate::StmtAugAssign>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_aug_assign[self]) + } +} + +impl crate::ast::AstIdMut for StmtAugAssignId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtAugAssign>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_aug_assign[self]) + } +} + +impl<'a> crate::Node<'a, StmtAugAssignId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtAugAssign> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtAnnAssignId { + type Output<'a> = crate::Node<'a, &'a crate::StmtAnnAssign>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_ann_assign[self]) + } +} + +impl crate::ast::AstIdMut for StmtAnnAssignId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtAnnAssign>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_ann_assign[self]) + } +} + +impl<'a> crate::Node<'a, StmtAnnAssignId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtAnnAssign> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtForId { + type Output<'a> = crate::Node<'a, &'a crate::StmtFor>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_for[self]) + } +} + +impl crate::ast::AstIdMut for StmtForId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtFor>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_for[self]) + } +} + +impl<'a> crate::Node<'a, StmtForId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtFor> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtWhileId { + type Output<'a> = crate::Node<'a, &'a crate::StmtWhile>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_while[self]) + } +} + +impl crate::ast::AstIdMut for StmtWhileId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtWhile>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_while[self]) + } +} + +impl<'a> crate::Node<'a, StmtWhileId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtWhile> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtIfId { + type Output<'a> = crate::Node<'a, &'a crate::StmtIf>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_if[self]) + } +} + +impl crate::ast::AstIdMut for StmtIfId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtIf>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_if[self]) + } +} + +impl<'a> crate::Node<'a, StmtIfId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtIf> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtWithId { + type Output<'a> = crate::Node<'a, &'a crate::StmtWith>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_with[self]) + } +} + +impl crate::ast::AstIdMut for StmtWithId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtWith>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_with[self]) + } +} + +impl<'a> crate::Node<'a, StmtWithId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtWith> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtMatchId { + type Output<'a> = crate::Node<'a, &'a crate::StmtMatch>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_match[self]) + } +} + +impl crate::ast::AstIdMut for StmtMatchId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtMatch>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_match[self]) + } +} + +impl<'a> crate::Node<'a, StmtMatchId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtMatch> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtRaiseId { + type Output<'a> = crate::Node<'a, &'a crate::StmtRaise>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_raise[self]) + } +} + +impl crate::ast::AstIdMut for StmtRaiseId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtRaise>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_raise[self]) + } +} + +impl<'a> crate::Node<'a, StmtRaiseId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtRaise> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtTryId { + type Output<'a> = crate::Node<'a, &'a crate::StmtTry>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_try[self]) + } +} + +impl crate::ast::AstIdMut for StmtTryId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtTry>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_try[self]) + } +} + +impl<'a> crate::Node<'a, StmtTryId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtTry> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtAssertId { + type Output<'a> = crate::Node<'a, &'a crate::StmtAssert>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_assert[self]) + } +} + +impl crate::ast::AstIdMut for StmtAssertId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtAssert>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_assert[self]) + } +} + +impl<'a> crate::Node<'a, StmtAssertId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtAssert> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtImportId { + type Output<'a> = crate::Node<'a, &'a crate::StmtImport>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_import[self]) + } +} + +impl crate::ast::AstIdMut for StmtImportId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtImport>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_import[self]) + } +} + +impl<'a> crate::Node<'a, StmtImportId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtImport> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtImportFromId { + type Output<'a> = crate::Node<'a, &'a crate::StmtImportFrom>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_import_from[self]) + } +} + +impl crate::ast::AstIdMut for StmtImportFromId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtImportFrom>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_import_from[self]) + } +} + +impl<'a> crate::Node<'a, StmtImportFromId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtImportFrom> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtGlobalId { + type Output<'a> = crate::Node<'a, &'a crate::StmtGlobal>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_global[self]) + } +} + +impl crate::ast::AstIdMut for StmtGlobalId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtGlobal>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_global[self]) + } +} + +impl<'a> crate::Node<'a, StmtGlobalId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtGlobal> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtNonlocalId { + type Output<'a> = crate::Node<'a, &'a crate::StmtNonlocal>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_nonlocal[self]) + } +} + +impl crate::ast::AstIdMut for StmtNonlocalId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtNonlocal>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_nonlocal[self]) + } +} + +impl<'a> crate::Node<'a, StmtNonlocalId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtNonlocal> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtExprId { + type Output<'a> = crate::Node<'a, &'a crate::StmtExpr>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_expr[self]) + } +} + +impl crate::ast::AstIdMut for StmtExprId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtExpr>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_expr[self]) + } +} + +impl<'a> crate::Node<'a, StmtExprId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtExpr> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtPassId { + type Output<'a> = crate::Node<'a, &'a crate::StmtPass>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_pass[self]) + } +} + +impl crate::ast::AstIdMut for StmtPassId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtPass>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_pass[self]) + } +} + +impl<'a> crate::Node<'a, StmtPassId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtPass> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtBreakId { + type Output<'a> = crate::Node<'a, &'a crate::StmtBreak>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_break[self]) + } +} + +impl crate::ast::AstIdMut for StmtBreakId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtBreak>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_break[self]) + } +} + +impl<'a> crate::Node<'a, StmtBreakId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtBreak> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtContinueId { + type Output<'a> = crate::Node<'a, &'a crate::StmtContinue>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_continue[self]) + } +} + +impl crate::ast::AstIdMut for StmtContinueId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtContinue>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_continue[self]) + } +} + +impl<'a> crate::Node<'a, StmtContinueId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtContinue> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtIpyEscapeCommandId { + type Output<'a> = crate::Node<'a, &'a crate::StmtIpyEscapeCommand>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.stmt_ipy_escape_command[self]) + } +} + +impl crate::ast::AstIdMut for StmtIpyEscapeCommandId { + type Output<'a> = crate::Node<'a, &'a mut crate::StmtIpyEscapeCommand>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.stmt_ipy_escape_command[self]) + } +} + +impl<'a> crate::Node<'a, StmtIpyEscapeCommandId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtIpyEscapeCommand> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprBoolOpId { + type Output<'a> = crate::Node<'a, &'a crate::ExprBoolOp>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_bool_op[self]) + } +} + +impl crate::ast::AstIdMut for ExprBoolOpId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprBoolOp>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_bool_op[self]) + } +} + +impl<'a> crate::Node<'a, ExprBoolOpId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprBoolOp> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprNamedId { + type Output<'a> = crate::Node<'a, &'a crate::ExprNamed>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_named[self]) + } +} + +impl crate::ast::AstIdMut for ExprNamedId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprNamed>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_named[self]) + } +} + +impl<'a> crate::Node<'a, ExprNamedId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprNamed> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprBinOpId { + type Output<'a> = crate::Node<'a, &'a crate::ExprBinOp>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_bin_op[self]) + } +} + +impl crate::ast::AstIdMut for ExprBinOpId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprBinOp>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_bin_op[self]) + } +} + +impl<'a> crate::Node<'a, ExprBinOpId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprBinOp> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprUnaryOpId { + type Output<'a> = crate::Node<'a, &'a crate::ExprUnaryOp>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_unary_op[self]) + } +} + +impl crate::ast::AstIdMut for ExprUnaryOpId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprUnaryOp>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_unary_op[self]) + } +} + +impl<'a> crate::Node<'a, ExprUnaryOpId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprUnaryOp> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprLambdaId { + type Output<'a> = crate::Node<'a, &'a crate::ExprLambda>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_lambda[self]) + } +} + +impl crate::ast::AstIdMut for ExprLambdaId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprLambda>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_lambda[self]) + } +} + +impl<'a> crate::Node<'a, ExprLambdaId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprLambda> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprIfId { + type Output<'a> = crate::Node<'a, &'a crate::ExprIf>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_if[self]) + } +} + +impl crate::ast::AstIdMut for ExprIfId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprIf>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_if[self]) + } +} + +impl<'a> crate::Node<'a, ExprIfId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprIf> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprDictId { + type Output<'a> = crate::Node<'a, &'a crate::ExprDict>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_dict[self]) + } +} + +impl crate::ast::AstIdMut for ExprDictId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprDict>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_dict[self]) + } +} + +impl<'a> crate::Node<'a, ExprDictId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprDict> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprSetId { + type Output<'a> = crate::Node<'a, &'a crate::ExprSet>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_set[self]) + } +} + +impl crate::ast::AstIdMut for ExprSetId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprSet>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_set[self]) + } +} + +impl<'a> crate::Node<'a, ExprSetId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprSet> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprListCompId { + type Output<'a> = crate::Node<'a, &'a crate::ExprListComp>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_list_comp[self]) + } +} + +impl crate::ast::AstIdMut for ExprListCompId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprListComp>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_list_comp[self]) + } +} + +impl<'a> crate::Node<'a, ExprListCompId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprListComp> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprSetCompId { + type Output<'a> = crate::Node<'a, &'a crate::ExprSetComp>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_set_comp[self]) + } +} + +impl crate::ast::AstIdMut for ExprSetCompId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprSetComp>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_set_comp[self]) + } +} + +impl<'a> crate::Node<'a, ExprSetCompId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprSetComp> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprDictCompId { + type Output<'a> = crate::Node<'a, &'a crate::ExprDictComp>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_dict_comp[self]) + } +} + +impl crate::ast::AstIdMut for ExprDictCompId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprDictComp>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_dict_comp[self]) + } +} + +impl<'a> crate::Node<'a, ExprDictCompId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprDictComp> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprGeneratorId { + type Output<'a> = crate::Node<'a, &'a crate::ExprGenerator>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_generator[self]) + } +} + +impl crate::ast::AstIdMut for ExprGeneratorId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprGenerator>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_generator[self]) + } +} + +impl<'a> crate::Node<'a, ExprGeneratorId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprGenerator> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprAwaitId { + type Output<'a> = crate::Node<'a, &'a crate::ExprAwait>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_await[self]) + } +} + +impl crate::ast::AstIdMut for ExprAwaitId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprAwait>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_await[self]) + } +} + +impl<'a> crate::Node<'a, ExprAwaitId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprAwait> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprYieldId { + type Output<'a> = crate::Node<'a, &'a crate::ExprYield>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_yield[self]) + } +} + +impl crate::ast::AstIdMut for ExprYieldId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprYield>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_yield[self]) + } +} + +impl<'a> crate::Node<'a, ExprYieldId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprYield> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprYieldFromId { + type Output<'a> = crate::Node<'a, &'a crate::ExprYieldFrom>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_yield_from[self]) + } +} + +impl crate::ast::AstIdMut for ExprYieldFromId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprYieldFrom>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_yield_from[self]) + } +} + +impl<'a> crate::Node<'a, ExprYieldFromId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprYieldFrom> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprCompareId { + type Output<'a> = crate::Node<'a, &'a crate::ExprCompare>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_compare[self]) + } +} + +impl crate::ast::AstIdMut for ExprCompareId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprCompare>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_compare[self]) + } +} + +impl<'a> crate::Node<'a, ExprCompareId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprCompare> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprCallId { + type Output<'a> = crate::Node<'a, &'a crate::ExprCall>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_call[self]) + } +} + +impl crate::ast::AstIdMut for ExprCallId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprCall>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_call[self]) + } +} + +impl<'a> crate::Node<'a, ExprCallId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprCall> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprFStringId { + type Output<'a> = crate::Node<'a, &'a crate::ExprFString>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_f_string[self]) + } +} + +impl crate::ast::AstIdMut for ExprFStringId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprFString>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_f_string[self]) + } +} + +impl<'a> crate::Node<'a, ExprFStringId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprFString> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprStringLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::ExprStringLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_string_literal[self]) + } +} + +impl crate::ast::AstIdMut for ExprStringLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprStringLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_string_literal[self]) + } +} + +impl<'a> crate::Node<'a, ExprStringLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprStringLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprBytesLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::ExprBytesLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_bytes_literal[self]) + } +} + +impl crate::ast::AstIdMut for ExprBytesLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprBytesLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_bytes_literal[self]) + } +} + +impl<'a> crate::Node<'a, ExprBytesLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprBytesLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprNumberLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::ExprNumberLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_number_literal[self]) + } +} + +impl crate::ast::AstIdMut for ExprNumberLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprNumberLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_number_literal[self]) + } +} + +impl<'a> crate::Node<'a, ExprNumberLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprNumberLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprBooleanLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::ExprBooleanLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_boolean_literal[self]) + } +} + +impl crate::ast::AstIdMut for ExprBooleanLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprBooleanLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_boolean_literal[self]) + } +} + +impl<'a> crate::Node<'a, ExprBooleanLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprBooleanLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprNoneLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::ExprNoneLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_none_literal[self]) + } +} + +impl crate::ast::AstIdMut for ExprNoneLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprNoneLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_none_literal[self]) + } +} + +impl<'a> crate::Node<'a, ExprNoneLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprNoneLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprEllipsisLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::ExprEllipsisLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_ellipsis_literal[self]) + } +} + +impl crate::ast::AstIdMut for ExprEllipsisLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprEllipsisLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_ellipsis_literal[self]) + } +} + +impl<'a> crate::Node<'a, ExprEllipsisLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprEllipsisLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprAttributeId { + type Output<'a> = crate::Node<'a, &'a crate::ExprAttribute>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_attribute[self]) + } +} + +impl crate::ast::AstIdMut for ExprAttributeId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprAttribute>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_attribute[self]) + } +} + +impl<'a> crate::Node<'a, ExprAttributeId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprAttribute> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprSubscriptId { + type Output<'a> = crate::Node<'a, &'a crate::ExprSubscript>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_subscript[self]) + } +} + +impl crate::ast::AstIdMut for ExprSubscriptId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprSubscript>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_subscript[self]) + } +} + +impl<'a> crate::Node<'a, ExprSubscriptId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprSubscript> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprStarredId { + type Output<'a> = crate::Node<'a, &'a crate::ExprStarred>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_starred[self]) + } +} + +impl crate::ast::AstIdMut for ExprStarredId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprStarred>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_starred[self]) + } +} + +impl<'a> crate::Node<'a, ExprStarredId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprStarred> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprNameId { + type Output<'a> = crate::Node<'a, &'a crate::ExprName>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_name[self]) + } +} + +impl crate::ast::AstIdMut for ExprNameId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprName>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_name[self]) + } +} + +impl<'a> crate::Node<'a, ExprNameId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprName> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprListId { + type Output<'a> = crate::Node<'a, &'a crate::ExprList>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_list[self]) + } +} + +impl crate::ast::AstIdMut for ExprListId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprList>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_list[self]) + } +} + +impl<'a> crate::Node<'a, ExprListId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprList> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprTupleId { + type Output<'a> = crate::Node<'a, &'a crate::ExprTuple>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_tuple[self]) + } +} + +impl crate::ast::AstIdMut for ExprTupleId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprTuple>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_tuple[self]) + } +} + +impl<'a> crate::Node<'a, ExprTupleId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprTuple> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprSliceId { + type Output<'a> = crate::Node<'a, &'a crate::ExprSlice>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_slice[self]) + } +} + +impl crate::ast::AstIdMut for ExprSliceId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprSlice>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_slice[self]) + } +} + +impl<'a> crate::Node<'a, ExprSliceId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprSlice> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprIpyEscapeCommandId { + type Output<'a> = crate::Node<'a, &'a crate::ExprIpyEscapeCommand>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.expr_ipy_escape_command[self]) + } +} + +impl crate::ast::AstIdMut for ExprIpyEscapeCommandId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExprIpyEscapeCommand>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.expr_ipy_escape_command[self]) + } +} + +impl<'a> crate::Node<'a, ExprIpyEscapeCommandId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprIpyEscapeCommand> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExceptHandlerExceptHandlerId { + type Output<'a> = crate::Node<'a, &'a crate::ExceptHandlerExceptHandler>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.except_handler_except_handler[self]) + } +} + +impl crate::ast::AstIdMut for ExceptHandlerExceptHandlerId { + type Output<'a> = crate::Node<'a, &'a mut crate::ExceptHandlerExceptHandler>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.except_handler_except_handler[self]) + } +} + +impl<'a> crate::Node<'a, ExceptHandlerExceptHandlerId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExceptHandlerExceptHandler> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for FStringExpressionElementId { + type Output<'a> = crate::Node<'a, &'a crate::FStringExpressionElement>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.f_string_expression_element[self]) + } +} + +impl crate::ast::AstIdMut for FStringExpressionElementId { + type Output<'a> = crate::Node<'a, &'a mut crate::FStringExpressionElement>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.f_string_expression_element[self]) + } +} + +impl<'a> crate::Node<'a, FStringExpressionElementId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::FStringExpressionElement> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for FStringLiteralElementId { + type Output<'a> = crate::Node<'a, &'a crate::FStringLiteralElement>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.f_string_literal_element[self]) + } +} + +impl crate::ast::AstIdMut for FStringLiteralElementId { + type Output<'a> = crate::Node<'a, &'a mut crate::FStringLiteralElement>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.f_string_literal_element[self]) + } +} + +impl<'a> crate::Node<'a, FStringLiteralElementId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::FStringLiteralElement> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchValueId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchValue>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_value[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchValueId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchValue>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_value[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchValueId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchValue> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchSingletonId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchSingleton>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_singleton[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchSingletonId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchSingleton>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_singleton[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchSingletonId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchSingleton> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchSequenceId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchSequence>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_sequence[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchSequenceId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchSequence>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_sequence[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchSequenceId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchSequence> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchMappingId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchMapping>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_mapping[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchMappingId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchMapping>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_mapping[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchMappingId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchMapping> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchClassId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchClass>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_class[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchClassId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchClass>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_class[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchClassId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchClass> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchStarId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchStar>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_star[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchStarId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchStar>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_star[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchStarId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchStar> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchAsId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchAs>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_as[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchAsId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchAs>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_as[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchAsId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchAs> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternMatchOrId { + type Output<'a> = crate::Node<'a, &'a crate::PatternMatchOr>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_match_or[self]) + } +} + +impl crate::ast::AstIdMut for PatternMatchOrId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternMatchOr>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_match_or[self]) + } +} + +impl<'a> crate::Node<'a, PatternMatchOrId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchOr> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for TypeParamTypeVarId { + type Output<'a> = crate::Node<'a, &'a crate::TypeParamTypeVar>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.type_param_type_var[self]) + } +} + +impl crate::ast::AstIdMut for TypeParamTypeVarId { + type Output<'a> = crate::Node<'a, &'a mut crate::TypeParamTypeVar>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.type_param_type_var[self]) + } +} + +impl<'a> crate::Node<'a, TypeParamTypeVarId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::TypeParamTypeVar> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for TypeParamTypeVarTupleId { + type Output<'a> = crate::Node<'a, &'a crate::TypeParamTypeVarTuple>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.type_param_type_var_tuple[self]) + } +} + +impl crate::ast::AstIdMut for TypeParamTypeVarTupleId { + type Output<'a> = crate::Node<'a, &'a mut crate::TypeParamTypeVarTuple>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.type_param_type_var_tuple[self]) + } +} + +impl<'a> crate::Node<'a, TypeParamTypeVarTupleId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::TypeParamTypeVarTuple> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for TypeParamParamSpecId { + type Output<'a> = crate::Node<'a, &'a crate::TypeParamParamSpec>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.type_param_param_spec[self]) + } +} + +impl crate::ast::AstIdMut for TypeParamParamSpecId { + type Output<'a> = crate::Node<'a, &'a mut crate::TypeParamParamSpec>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.type_param_param_spec[self]) + } +} + +impl<'a> crate::Node<'a, TypeParamParamSpecId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::TypeParamParamSpec> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for FStringFormatSpecId { + type Output<'a> = crate::Node<'a, &'a crate::FStringFormatSpec>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.f_string_format_spec[self]) + } +} + +impl crate::ast::AstIdMut for FStringFormatSpecId { + type Output<'a> = crate::Node<'a, &'a mut crate::FStringFormatSpec>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.f_string_format_spec[self]) + } +} + +impl<'a> crate::Node<'a, FStringFormatSpecId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::FStringFormatSpec> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternArgumentsId { + type Output<'a> = crate::Node<'a, &'a crate::PatternArguments>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_arguments[self]) + } +} + +impl crate::ast::AstIdMut for PatternArgumentsId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternArguments>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_arguments[self]) + } +} + +impl<'a> crate::Node<'a, PatternArgumentsId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternArguments> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternKeywordId { + type Output<'a> = crate::Node<'a, &'a crate::PatternKeyword>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.pattern_keyword[self]) + } +} + +impl crate::ast::AstIdMut for PatternKeywordId { + type Output<'a> = crate::Node<'a, &'a mut crate::PatternKeyword>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.pattern_keyword[self]) + } +} + +impl<'a> crate::Node<'a, PatternKeywordId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternKeyword> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ComprehensionId { + type Output<'a> = crate::Node<'a, &'a crate::Comprehension>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.comprehension[self]) + } +} + +impl crate::ast::AstIdMut for ComprehensionId { + type Output<'a> = crate::Node<'a, &'a mut crate::Comprehension>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.comprehension[self]) + } +} + +impl<'a> crate::Node<'a, ComprehensionId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Comprehension> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ArgumentsId { + type Output<'a> = crate::Node<'a, &'a crate::Arguments>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.arguments[self]) + } +} + +impl crate::ast::AstIdMut for ArgumentsId { + type Output<'a> = crate::Node<'a, &'a mut crate::Arguments>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.arguments[self]) + } +} + +impl<'a> crate::Node<'a, ArgumentsId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Arguments> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ParametersId { + type Output<'a> = crate::Node<'a, &'a crate::Parameters>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.parameters[self]) + } +} + +impl crate::ast::AstIdMut for ParametersId { + type Output<'a> = crate::Node<'a, &'a mut crate::Parameters>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.parameters[self]) + } +} + +impl<'a> crate::Node<'a, ParametersId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Parameters> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ParameterId { + type Output<'a> = crate::Node<'a, &'a crate::Parameter>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.parameter[self]) + } +} + +impl crate::ast::AstIdMut for ParameterId { + type Output<'a> = crate::Node<'a, &'a mut crate::Parameter>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.parameter[self]) + } +} + +impl<'a> crate::Node<'a, ParameterId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Parameter> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ParameterWithDefaultId { + type Output<'a> = crate::Node<'a, &'a crate::ParameterWithDefault>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.parameter_with_default[self]) + } +} + +impl crate::ast::AstIdMut for ParameterWithDefaultId { + type Output<'a> = crate::Node<'a, &'a mut crate::ParameterWithDefault>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.parameter_with_default[self]) + } +} + +impl<'a> crate::Node<'a, ParameterWithDefaultId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ParameterWithDefault> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for KeywordId { + type Output<'a> = crate::Node<'a, &'a crate::Keyword>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.keyword[self]) + } +} + +impl crate::ast::AstIdMut for KeywordId { + type Output<'a> = crate::Node<'a, &'a mut crate::Keyword>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.keyword[self]) + } +} + +impl<'a> crate::Node<'a, KeywordId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Keyword> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for AliasId { + type Output<'a> = crate::Node<'a, &'a crate::Alias>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.alias[self]) + } +} + +impl crate::ast::AstIdMut for AliasId { + type Output<'a> = crate::Node<'a, &'a mut crate::Alias>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.alias[self]) + } +} + +impl<'a> crate::Node<'a, AliasId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Alias> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for WithItemId { + type Output<'a> = crate::Node<'a, &'a crate::WithItem>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.with_item[self]) + } +} + +impl crate::ast::AstIdMut for WithItemId { + type Output<'a> = crate::Node<'a, &'a mut crate::WithItem>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.with_item[self]) + } +} + +impl<'a> crate::Node<'a, WithItemId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::WithItem> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for MatchCaseId { + type Output<'a> = crate::Node<'a, &'a crate::MatchCase>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.match_case[self]) + } +} + +impl crate::ast::AstIdMut for MatchCaseId { + type Output<'a> = crate::Node<'a, &'a mut crate::MatchCase>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.match_case[self]) + } +} + +impl<'a> crate::Node<'a, MatchCaseId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::MatchCase> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for DecoratorId { + type Output<'a> = crate::Node<'a, &'a crate::Decorator>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.decorator[self]) + } +} + +impl crate::ast::AstIdMut for DecoratorId { + type Output<'a> = crate::Node<'a, &'a mut crate::Decorator>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.decorator[self]) + } +} + +impl<'a> crate::Node<'a, DecoratorId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Decorator> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ElifElseClauseId { + type Output<'a> = crate::Node<'a, &'a crate::ElifElseClause>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.elif_else_clause[self]) + } +} + +impl crate::ast::AstIdMut for ElifElseClauseId { + type Output<'a> = crate::Node<'a, &'a mut crate::ElifElseClause>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.elif_else_clause[self]) + } +} + +impl<'a> crate::Node<'a, ElifElseClauseId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ElifElseClause> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for TypeParamsId { + type Output<'a> = crate::Node<'a, &'a crate::TypeParams>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.type_params[self]) + } +} + +impl crate::ast::AstIdMut for TypeParamsId { + type Output<'a> = crate::Node<'a, &'a mut crate::TypeParams>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.type_params[self]) + } +} + +impl<'a> crate::Node<'a, TypeParamsId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::TypeParams> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for FStringId { + type Output<'a> = crate::Node<'a, &'a crate::FString>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.f_string[self]) + } +} + +impl crate::ast::AstIdMut for FStringId { + type Output<'a> = crate::Node<'a, &'a mut crate::FString>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.f_string[self]) + } +} + +impl<'a> crate::Node<'a, FStringId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::FString> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StringLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::StringLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.string_literal[self]) + } +} + +impl crate::ast::AstIdMut for StringLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::StringLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.string_literal[self]) + } +} + +impl<'a> crate::Node<'a, StringLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StringLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for BytesLiteralId { + type Output<'a> = crate::Node<'a, &'a crate::BytesLiteral>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.bytes_literal[self]) + } +} + +impl crate::ast::AstIdMut for BytesLiteralId { + type Output<'a> = crate::Node<'a, &'a mut crate::BytesLiteral>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.bytes_literal[self]) + } +} + +impl<'a> crate::Node<'a, BytesLiteralId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::BytesLiteral> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for IdentifierId { + type Output<'a> = crate::Node<'a, &'a crate::Identifier>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + ast.wrap(&ast.storage.identifier[self]) + } +} + +impl crate::ast::AstIdMut for IdentifierId { + type Output<'a> = crate::Node<'a, &'a mut crate::Identifier>; + #[inline] + fn node_mut<'a>(self, ast: &'a mut crate::Ast) -> Self::Output<'a> { + ast.wrap(&mut ast.storage.identifier[self]) + } +} + +impl<'a> crate::Node<'a, IdentifierId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::Identifier> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ModId { + type Output<'a> = ModRef<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + match self { + ModId::Module(node) => ModRef::Module(ast.node(node)), + ModId::Expression(node) => ModRef::Expression(ast.node(node)), + } + } +} + +impl<'a> crate::Node<'a, ModId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ModExpression> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for StmtId { + type Output<'a> = StmtRef<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + match self { + StmtId::FunctionDef(node) => StmtRef::FunctionDef(ast.node(node)), + StmtId::ClassDef(node) => StmtRef::ClassDef(ast.node(node)), + StmtId::Return(node) => StmtRef::Return(ast.node(node)), + StmtId::Delete(node) => StmtRef::Delete(ast.node(node)), + StmtId::TypeAlias(node) => StmtRef::TypeAlias(ast.node(node)), + StmtId::Assign(node) => StmtRef::Assign(ast.node(node)), + StmtId::AugAssign(node) => StmtRef::AugAssign(ast.node(node)), + StmtId::AnnAssign(node) => StmtRef::AnnAssign(ast.node(node)), + StmtId::For(node) => StmtRef::For(ast.node(node)), + StmtId::While(node) => StmtRef::While(ast.node(node)), + StmtId::If(node) => StmtRef::If(ast.node(node)), + StmtId::With(node) => StmtRef::With(ast.node(node)), + StmtId::Match(node) => StmtRef::Match(ast.node(node)), + StmtId::Raise(node) => StmtRef::Raise(ast.node(node)), + StmtId::Try(node) => StmtRef::Try(ast.node(node)), + StmtId::Assert(node) => StmtRef::Assert(ast.node(node)), + StmtId::Import(node) => StmtRef::Import(ast.node(node)), + StmtId::ImportFrom(node) => StmtRef::ImportFrom(ast.node(node)), + StmtId::Global(node) => StmtRef::Global(ast.node(node)), + StmtId::Nonlocal(node) => StmtRef::Nonlocal(ast.node(node)), + StmtId::Expr(node) => StmtRef::Expr(ast.node(node)), + StmtId::Pass(node) => StmtRef::Pass(ast.node(node)), + StmtId::Break(node) => StmtRef::Break(ast.node(node)), + StmtId::Continue(node) => StmtRef::Continue(ast.node(node)), + StmtId::IpyEscapeCommand(node) => StmtRef::IpyEscapeCommand(ast.node(node)), + } + } +} + +impl<'a> crate::Node<'a, StmtId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::StmtIpyEscapeCommand> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExprId { + type Output<'a> = ExprRef<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + match self { + ExprId::BoolOp(node) => ExprRef::BoolOp(ast.node(node)), + ExprId::Named(node) => ExprRef::Named(ast.node(node)), + ExprId::BinOp(node) => ExprRef::BinOp(ast.node(node)), + ExprId::UnaryOp(node) => ExprRef::UnaryOp(ast.node(node)), + ExprId::Lambda(node) => ExprRef::Lambda(ast.node(node)), + ExprId::If(node) => ExprRef::If(ast.node(node)), + ExprId::Dict(node) => ExprRef::Dict(ast.node(node)), + ExprId::Set(node) => ExprRef::Set(ast.node(node)), + ExprId::ListComp(node) => ExprRef::ListComp(ast.node(node)), + ExprId::SetComp(node) => ExprRef::SetComp(ast.node(node)), + ExprId::DictComp(node) => ExprRef::DictComp(ast.node(node)), + ExprId::Generator(node) => ExprRef::Generator(ast.node(node)), + ExprId::Await(node) => ExprRef::Await(ast.node(node)), + ExprId::Yield(node) => ExprRef::Yield(ast.node(node)), + ExprId::YieldFrom(node) => ExprRef::YieldFrom(ast.node(node)), + ExprId::Compare(node) => ExprRef::Compare(ast.node(node)), + ExprId::Call(node) => ExprRef::Call(ast.node(node)), + ExprId::FString(node) => ExprRef::FString(ast.node(node)), + ExprId::StringLiteral(node) => ExprRef::StringLiteral(ast.node(node)), + ExprId::BytesLiteral(node) => ExprRef::BytesLiteral(ast.node(node)), + ExprId::NumberLiteral(node) => ExprRef::NumberLiteral(ast.node(node)), + ExprId::BooleanLiteral(node) => ExprRef::BooleanLiteral(ast.node(node)), + ExprId::NoneLiteral(node) => ExprRef::NoneLiteral(ast.node(node)), + ExprId::EllipsisLiteral(node) => ExprRef::EllipsisLiteral(ast.node(node)), + ExprId::Attribute(node) => ExprRef::Attribute(ast.node(node)), + ExprId::Subscript(node) => ExprRef::Subscript(ast.node(node)), + ExprId::Starred(node) => ExprRef::Starred(ast.node(node)), + ExprId::Name(node) => ExprRef::Name(ast.node(node)), + ExprId::List(node) => ExprRef::List(ast.node(node)), + ExprId::Tuple(node) => ExprRef::Tuple(ast.node(node)), + ExprId::Slice(node) => ExprRef::Slice(ast.node(node)), + ExprId::IpyEscapeCommand(node) => ExprRef::IpyEscapeCommand(ast.node(node)), + } + } +} + +impl<'a> crate::Node<'a, ExprId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExprIpyEscapeCommand> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for ExceptHandlerId { + type Output<'a> = ExceptHandlerRef<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + match self { + ExceptHandlerId::ExceptHandler(node) => ExceptHandlerRef::ExceptHandler(ast.node(node)), + } + } +} + +impl<'a> crate::Node<'a, ExceptHandlerId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::ExceptHandlerExceptHandler> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for FStringElementId { + type Output<'a> = FStringElementRef<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + match self { + FStringElementId::Expression(node) => FStringElementRef::Expression(ast.node(node)), + FStringElementId::Literal(node) => FStringElementRef::Literal(ast.node(node)), + } + } +} + +impl<'a> crate::Node<'a, FStringElementId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::FStringLiteralElement> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for PatternId { + type Output<'a> = PatternRef<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + match self { + PatternId::MatchValue(node) => PatternRef::MatchValue(ast.node(node)), + PatternId::MatchSingleton(node) => PatternRef::MatchSingleton(ast.node(node)), + PatternId::MatchSequence(node) => PatternRef::MatchSequence(ast.node(node)), + PatternId::MatchMapping(node) => PatternRef::MatchMapping(ast.node(node)), + PatternId::MatchClass(node) => PatternRef::MatchClass(ast.node(node)), + PatternId::MatchStar(node) => PatternRef::MatchStar(ast.node(node)), + PatternId::MatchAs(node) => PatternRef::MatchAs(ast.node(node)), + PatternId::MatchOr(node) => PatternRef::MatchOr(ast.node(node)), + } + } +} + +impl<'a> crate::Node<'a, PatternId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::PatternMatchOr> { + self.ast.node(self.node) + } +} + +impl crate::ast::AstId for TypeParamId { + type Output<'a> = TypeParamRef<'a>; + #[inline] + fn node<'a>(self, ast: &'a crate::Ast) -> Self::Output<'a> { + match self { + TypeParamId::TypeVar(node) => TypeParamRef::TypeVar(ast.node(node)), + TypeParamId::TypeVarTuple(node) => TypeParamRef::TypeVarTuple(ast.node(node)), + TypeParamId::ParamSpec(node) => TypeParamRef::ParamSpec(ast.node(node)), + } + } +} + +impl<'a> crate::Node<'a, TypeParamId> { + #[inline] + pub fn node(self) -> crate::Node<'a, &'a crate::TypeParamParamSpec> { + self.ast.node(self.node) + } +} + +#[derive(Copy, Clone, Debug, is_macro::Is, PartialEq)] +pub enum AnyNodeRef<'a> { + ModModule(crate::Node<'a, &'a crate::ModModule>), + ModExpression(crate::Node<'a, &'a crate::ModExpression>), + StmtFunctionDef(crate::Node<'a, &'a crate::StmtFunctionDef>), + StmtClassDef(crate::Node<'a, &'a crate::StmtClassDef>), + StmtReturn(crate::Node<'a, &'a crate::StmtReturn>), + StmtDelete(crate::Node<'a, &'a crate::StmtDelete>), + StmtTypeAlias(crate::Node<'a, &'a crate::StmtTypeAlias>), + StmtAssign(crate::Node<'a, &'a crate::StmtAssign>), + StmtAugAssign(crate::Node<'a, &'a crate::StmtAugAssign>), + StmtAnnAssign(crate::Node<'a, &'a crate::StmtAnnAssign>), + StmtFor(crate::Node<'a, &'a crate::StmtFor>), + StmtWhile(crate::Node<'a, &'a crate::StmtWhile>), + StmtIf(crate::Node<'a, &'a crate::StmtIf>), + StmtWith(crate::Node<'a, &'a crate::StmtWith>), + StmtMatch(crate::Node<'a, &'a crate::StmtMatch>), + StmtRaise(crate::Node<'a, &'a crate::StmtRaise>), + StmtTry(crate::Node<'a, &'a crate::StmtTry>), + StmtAssert(crate::Node<'a, &'a crate::StmtAssert>), + StmtImport(crate::Node<'a, &'a crate::StmtImport>), + StmtImportFrom(crate::Node<'a, &'a crate::StmtImportFrom>), + StmtGlobal(crate::Node<'a, &'a crate::StmtGlobal>), + StmtNonlocal(crate::Node<'a, &'a crate::StmtNonlocal>), + StmtExpr(crate::Node<'a, &'a crate::StmtExpr>), + StmtPass(crate::Node<'a, &'a crate::StmtPass>), + StmtBreak(crate::Node<'a, &'a crate::StmtBreak>), + StmtContinue(crate::Node<'a, &'a crate::StmtContinue>), + StmtIpyEscapeCommand(crate::Node<'a, &'a crate::StmtIpyEscapeCommand>), + ExprBoolOp(crate::Node<'a, &'a crate::ExprBoolOp>), + ExprNamed(crate::Node<'a, &'a crate::ExprNamed>), + ExprBinOp(crate::Node<'a, &'a crate::ExprBinOp>), + ExprUnaryOp(crate::Node<'a, &'a crate::ExprUnaryOp>), + ExprLambda(crate::Node<'a, &'a crate::ExprLambda>), + ExprIf(crate::Node<'a, &'a crate::ExprIf>), + ExprDict(crate::Node<'a, &'a crate::ExprDict>), + ExprSet(crate::Node<'a, &'a crate::ExprSet>), + ExprListComp(crate::Node<'a, &'a crate::ExprListComp>), + ExprSetComp(crate::Node<'a, &'a crate::ExprSetComp>), + ExprDictComp(crate::Node<'a, &'a crate::ExprDictComp>), + ExprGenerator(crate::Node<'a, &'a crate::ExprGenerator>), + ExprAwait(crate::Node<'a, &'a crate::ExprAwait>), + ExprYield(crate::Node<'a, &'a crate::ExprYield>), + ExprYieldFrom(crate::Node<'a, &'a crate::ExprYieldFrom>), + ExprCompare(crate::Node<'a, &'a crate::ExprCompare>), + ExprCall(crate::Node<'a, &'a crate::ExprCall>), + ExprFString(crate::Node<'a, &'a crate::ExprFString>), + ExprStringLiteral(crate::Node<'a, &'a crate::ExprStringLiteral>), + ExprBytesLiteral(crate::Node<'a, &'a crate::ExprBytesLiteral>), + ExprNumberLiteral(crate::Node<'a, &'a crate::ExprNumberLiteral>), + ExprBooleanLiteral(crate::Node<'a, &'a crate::ExprBooleanLiteral>), + ExprNoneLiteral(crate::Node<'a, &'a crate::ExprNoneLiteral>), + ExprEllipsisLiteral(crate::Node<'a, &'a crate::ExprEllipsisLiteral>), + ExprAttribute(crate::Node<'a, &'a crate::ExprAttribute>), + ExprSubscript(crate::Node<'a, &'a crate::ExprSubscript>), + ExprStarred(crate::Node<'a, &'a crate::ExprStarred>), + ExprName(crate::Node<'a, &'a crate::ExprName>), + ExprList(crate::Node<'a, &'a crate::ExprList>), + ExprTuple(crate::Node<'a, &'a crate::ExprTuple>), + ExprSlice(crate::Node<'a, &'a crate::ExprSlice>), + ExprIpyEscapeCommand(crate::Node<'a, &'a crate::ExprIpyEscapeCommand>), + ExceptHandlerExceptHandler(crate::Node<'a, &'a crate::ExceptHandlerExceptHandler>), + FStringExpressionElement(crate::Node<'a, &'a crate::FStringExpressionElement>), + FStringLiteralElement(crate::Node<'a, &'a crate::FStringLiteralElement>), + PatternMatchValue(crate::Node<'a, &'a crate::PatternMatchValue>), + PatternMatchSingleton(crate::Node<'a, &'a crate::PatternMatchSingleton>), + PatternMatchSequence(crate::Node<'a, &'a crate::PatternMatchSequence>), + PatternMatchMapping(crate::Node<'a, &'a crate::PatternMatchMapping>), + PatternMatchClass(crate::Node<'a, &'a crate::PatternMatchClass>), + PatternMatchStar(crate::Node<'a, &'a crate::PatternMatchStar>), + PatternMatchAs(crate::Node<'a, &'a crate::PatternMatchAs>), + PatternMatchOr(crate::Node<'a, &'a crate::PatternMatchOr>), + TypeParamTypeVar(crate::Node<'a, &'a crate::TypeParamTypeVar>), + TypeParamTypeVarTuple(crate::Node<'a, &'a crate::TypeParamTypeVarTuple>), + TypeParamParamSpec(crate::Node<'a, &'a crate::TypeParamParamSpec>), + FStringFormatSpec(crate::Node<'a, &'a crate::FStringFormatSpec>), + PatternArguments(crate::Node<'a, &'a crate::PatternArguments>), + PatternKeyword(crate::Node<'a, &'a crate::PatternKeyword>), + Comprehension(crate::Node<'a, &'a crate::Comprehension>), + Arguments(crate::Node<'a, &'a crate::Arguments>), + Parameters(crate::Node<'a, &'a crate::Parameters>), + Parameter(crate::Node<'a, &'a crate::Parameter>), + ParameterWithDefault(crate::Node<'a, &'a crate::ParameterWithDefault>), + Keyword(crate::Node<'a, &'a crate::Keyword>), + Alias(crate::Node<'a, &'a crate::Alias>), + WithItem(crate::Node<'a, &'a crate::WithItem>), + MatchCase(crate::Node<'a, &'a crate::MatchCase>), + Decorator(crate::Node<'a, &'a crate::Decorator>), + ElifElseClause(crate::Node<'a, &'a crate::ElifElseClause>), + TypeParams(crate::Node<'a, &'a crate::TypeParams>), + FString(crate::Node<'a, &'a crate::FString>), + StringLiteral(crate::Node<'a, &'a crate::StringLiteral>), + BytesLiteral(crate::Node<'a, &'a crate::BytesLiteral>), + Identifier(crate::Node<'a, &'a crate::Identifier>), +} + +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a Mod>) -> AnyNodeRef<'a> { + match node.node { + Mod::Module(n) => AnyNodeRef::ModModule(node.ast.wrap(n)), + Mod::Expression(n) => AnyNodeRef::ModExpression(node.ast.wrap(n)), } } } @@ -2387,34 +5833,34 @@ impl<'a> From> for AnyNodeRef<'a> { } } -impl<'a> From<&'a Stmt> for AnyNodeRef<'a> { - fn from(node: &'a Stmt) -> AnyNodeRef<'a> { - match node { - Stmt::FunctionDef(node) => AnyNodeRef::StmtFunctionDef(node), - Stmt::ClassDef(node) => AnyNodeRef::StmtClassDef(node), - Stmt::Return(node) => AnyNodeRef::StmtReturn(node), - Stmt::Delete(node) => AnyNodeRef::StmtDelete(node), - Stmt::TypeAlias(node) => AnyNodeRef::StmtTypeAlias(node), - Stmt::Assign(node) => AnyNodeRef::StmtAssign(node), - Stmt::AugAssign(node) => AnyNodeRef::StmtAugAssign(node), - Stmt::AnnAssign(node) => AnyNodeRef::StmtAnnAssign(node), - Stmt::For(node) => AnyNodeRef::StmtFor(node), - Stmt::While(node) => AnyNodeRef::StmtWhile(node), - Stmt::If(node) => AnyNodeRef::StmtIf(node), - Stmt::With(node) => AnyNodeRef::StmtWith(node), - Stmt::Match(node) => AnyNodeRef::StmtMatch(node), - Stmt::Raise(node) => AnyNodeRef::StmtRaise(node), - Stmt::Try(node) => AnyNodeRef::StmtTry(node), - Stmt::Assert(node) => AnyNodeRef::StmtAssert(node), - Stmt::Import(node) => AnyNodeRef::StmtImport(node), - Stmt::ImportFrom(node) => AnyNodeRef::StmtImportFrom(node), - Stmt::Global(node) => AnyNodeRef::StmtGlobal(node), - Stmt::Nonlocal(node) => AnyNodeRef::StmtNonlocal(node), - Stmt::Expr(node) => AnyNodeRef::StmtExpr(node), - Stmt::Pass(node) => AnyNodeRef::StmtPass(node), - Stmt::Break(node) => AnyNodeRef::StmtBreak(node), - Stmt::Continue(node) => AnyNodeRef::StmtContinue(node), - Stmt::IpyEscapeCommand(node) => AnyNodeRef::StmtIpyEscapeCommand(node), +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a Stmt>) -> AnyNodeRef<'a> { + match node.node { + Stmt::FunctionDef(n) => AnyNodeRef::StmtFunctionDef(node.ast.wrap(n)), + Stmt::ClassDef(n) => AnyNodeRef::StmtClassDef(node.ast.wrap(n)), + Stmt::Return(n) => AnyNodeRef::StmtReturn(node.ast.wrap(n)), + Stmt::Delete(n) => AnyNodeRef::StmtDelete(node.ast.wrap(n)), + Stmt::TypeAlias(n) => AnyNodeRef::StmtTypeAlias(node.ast.wrap(n)), + Stmt::Assign(n) => AnyNodeRef::StmtAssign(node.ast.wrap(n)), + Stmt::AugAssign(n) => AnyNodeRef::StmtAugAssign(node.ast.wrap(n)), + Stmt::AnnAssign(n) => AnyNodeRef::StmtAnnAssign(node.ast.wrap(n)), + Stmt::For(n) => AnyNodeRef::StmtFor(node.ast.wrap(n)), + Stmt::While(n) => AnyNodeRef::StmtWhile(node.ast.wrap(n)), + Stmt::If(n) => AnyNodeRef::StmtIf(node.ast.wrap(n)), + Stmt::With(n) => AnyNodeRef::StmtWith(node.ast.wrap(n)), + Stmt::Match(n) => AnyNodeRef::StmtMatch(node.ast.wrap(n)), + Stmt::Raise(n) => AnyNodeRef::StmtRaise(node.ast.wrap(n)), + Stmt::Try(n) => AnyNodeRef::StmtTry(node.ast.wrap(n)), + Stmt::Assert(n) => AnyNodeRef::StmtAssert(node.ast.wrap(n)), + Stmt::Import(n) => AnyNodeRef::StmtImport(node.ast.wrap(n)), + Stmt::ImportFrom(n) => AnyNodeRef::StmtImportFrom(node.ast.wrap(n)), + Stmt::Global(n) => AnyNodeRef::StmtGlobal(node.ast.wrap(n)), + Stmt::Nonlocal(n) => AnyNodeRef::StmtNonlocal(node.ast.wrap(n)), + Stmt::Expr(n) => AnyNodeRef::StmtExpr(node.ast.wrap(n)), + Stmt::Pass(n) => AnyNodeRef::StmtPass(node.ast.wrap(n)), + Stmt::Break(n) => AnyNodeRef::StmtBreak(node.ast.wrap(n)), + Stmt::Continue(n) => AnyNodeRef::StmtContinue(node.ast.wrap(n)), + Stmt::IpyEscapeCommand(n) => AnyNodeRef::StmtIpyEscapeCommand(node.ast.wrap(n)), } } } @@ -2451,41 +5897,41 @@ impl<'a> From> for AnyNodeRef<'a> { } } -impl<'a> From<&'a Expr> for AnyNodeRef<'a> { - fn from(node: &'a Expr) -> AnyNodeRef<'a> { - match node { - Expr::BoolOp(node) => AnyNodeRef::ExprBoolOp(node), - Expr::Named(node) => AnyNodeRef::ExprNamed(node), - Expr::BinOp(node) => AnyNodeRef::ExprBinOp(node), - Expr::UnaryOp(node) => AnyNodeRef::ExprUnaryOp(node), - Expr::Lambda(node) => AnyNodeRef::ExprLambda(node), - Expr::If(node) => AnyNodeRef::ExprIf(node), - Expr::Dict(node) => AnyNodeRef::ExprDict(node), - Expr::Set(node) => AnyNodeRef::ExprSet(node), - Expr::ListComp(node) => AnyNodeRef::ExprListComp(node), - Expr::SetComp(node) => AnyNodeRef::ExprSetComp(node), - Expr::DictComp(node) => AnyNodeRef::ExprDictComp(node), - Expr::Generator(node) => AnyNodeRef::ExprGenerator(node), - Expr::Await(node) => AnyNodeRef::ExprAwait(node), - Expr::Yield(node) => AnyNodeRef::ExprYield(node), - Expr::YieldFrom(node) => AnyNodeRef::ExprYieldFrom(node), - Expr::Compare(node) => AnyNodeRef::ExprCompare(node), - Expr::Call(node) => AnyNodeRef::ExprCall(node), - Expr::FString(node) => AnyNodeRef::ExprFString(node), - Expr::StringLiteral(node) => AnyNodeRef::ExprStringLiteral(node), - Expr::BytesLiteral(node) => AnyNodeRef::ExprBytesLiteral(node), - Expr::NumberLiteral(node) => AnyNodeRef::ExprNumberLiteral(node), - Expr::BooleanLiteral(node) => AnyNodeRef::ExprBooleanLiteral(node), - Expr::NoneLiteral(node) => AnyNodeRef::ExprNoneLiteral(node), - Expr::EllipsisLiteral(node) => AnyNodeRef::ExprEllipsisLiteral(node), - Expr::Attribute(node) => AnyNodeRef::ExprAttribute(node), - Expr::Subscript(node) => AnyNodeRef::ExprSubscript(node), - Expr::Starred(node) => AnyNodeRef::ExprStarred(node), - Expr::Name(node) => AnyNodeRef::ExprName(node), - Expr::List(node) => AnyNodeRef::ExprList(node), - Expr::Tuple(node) => AnyNodeRef::ExprTuple(node), - Expr::Slice(node) => AnyNodeRef::ExprSlice(node), - Expr::IpyEscapeCommand(node) => AnyNodeRef::ExprIpyEscapeCommand(node), +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a Expr>) -> AnyNodeRef<'a> { + match node.node { + Expr::BoolOp(n) => AnyNodeRef::ExprBoolOp(node.ast.wrap(n)), + Expr::Named(n) => AnyNodeRef::ExprNamed(node.ast.wrap(n)), + Expr::BinOp(n) => AnyNodeRef::ExprBinOp(node.ast.wrap(n)), + Expr::UnaryOp(n) => AnyNodeRef::ExprUnaryOp(node.ast.wrap(n)), + Expr::Lambda(n) => AnyNodeRef::ExprLambda(node.ast.wrap(n)), + Expr::If(n) => AnyNodeRef::ExprIf(node.ast.wrap(n)), + Expr::Dict(n) => AnyNodeRef::ExprDict(node.ast.wrap(n)), + Expr::Set(n) => AnyNodeRef::ExprSet(node.ast.wrap(n)), + Expr::ListComp(n) => AnyNodeRef::ExprListComp(node.ast.wrap(n)), + Expr::SetComp(n) => AnyNodeRef::ExprSetComp(node.ast.wrap(n)), + Expr::DictComp(n) => AnyNodeRef::ExprDictComp(node.ast.wrap(n)), + Expr::Generator(n) => AnyNodeRef::ExprGenerator(node.ast.wrap(n)), + Expr::Await(n) => AnyNodeRef::ExprAwait(node.ast.wrap(n)), + Expr::Yield(n) => AnyNodeRef::ExprYield(node.ast.wrap(n)), + Expr::YieldFrom(n) => AnyNodeRef::ExprYieldFrom(node.ast.wrap(n)), + Expr::Compare(n) => AnyNodeRef::ExprCompare(node.ast.wrap(n)), + Expr::Call(n) => AnyNodeRef::ExprCall(node.ast.wrap(n)), + Expr::FString(n) => AnyNodeRef::ExprFString(node.ast.wrap(n)), + Expr::StringLiteral(n) => AnyNodeRef::ExprStringLiteral(node.ast.wrap(n)), + Expr::BytesLiteral(n) => AnyNodeRef::ExprBytesLiteral(node.ast.wrap(n)), + Expr::NumberLiteral(n) => AnyNodeRef::ExprNumberLiteral(node.ast.wrap(n)), + Expr::BooleanLiteral(n) => AnyNodeRef::ExprBooleanLiteral(node.ast.wrap(n)), + Expr::NoneLiteral(n) => AnyNodeRef::ExprNoneLiteral(node.ast.wrap(n)), + Expr::EllipsisLiteral(n) => AnyNodeRef::ExprEllipsisLiteral(node.ast.wrap(n)), + Expr::Attribute(n) => AnyNodeRef::ExprAttribute(node.ast.wrap(n)), + Expr::Subscript(n) => AnyNodeRef::ExprSubscript(node.ast.wrap(n)), + Expr::Starred(n) => AnyNodeRef::ExprStarred(node.ast.wrap(n)), + Expr::Name(n) => AnyNodeRef::ExprName(node.ast.wrap(n)), + Expr::List(n) => AnyNodeRef::ExprList(node.ast.wrap(n)), + Expr::Tuple(n) => AnyNodeRef::ExprTuple(node.ast.wrap(n)), + Expr::Slice(n) => AnyNodeRef::ExprSlice(node.ast.wrap(n)), + Expr::IpyEscapeCommand(n) => AnyNodeRef::ExprIpyEscapeCommand(node.ast.wrap(n)), } } } @@ -2529,10 +5975,12 @@ impl<'a> From> for AnyNodeRef<'a> { } } -impl<'a> From<&'a ExceptHandler> for AnyNodeRef<'a> { - fn from(node: &'a ExceptHandler) -> AnyNodeRef<'a> { - match node { - ExceptHandler::ExceptHandler(node) => AnyNodeRef::ExceptHandlerExceptHandler(node), +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a ExceptHandler>) -> AnyNodeRef<'a> { + match node.node { + ExceptHandler::ExceptHandler(n) => { + AnyNodeRef::ExceptHandlerExceptHandler(node.ast.wrap(n)) + } } } } @@ -2545,11 +5993,11 @@ impl<'a> From> for AnyNodeRef<'a> { } } -impl<'a> From<&'a FStringElement> for AnyNodeRef<'a> { - fn from(node: &'a FStringElement) -> AnyNodeRef<'a> { - match node { - FStringElement::Expression(node) => AnyNodeRef::FStringExpressionElement(node), - FStringElement::Literal(node) => AnyNodeRef::FStringLiteralElement(node), +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a FStringElement>) -> AnyNodeRef<'a> { + match node.node { + FStringElement::Expression(n) => AnyNodeRef::FStringExpressionElement(node.ast.wrap(n)), + FStringElement::Literal(n) => AnyNodeRef::FStringLiteralElement(node.ast.wrap(n)), } } } @@ -2563,17 +6011,17 @@ impl<'a> From> for AnyNodeRef<'a> { } } -impl<'a> From<&'a Pattern> for AnyNodeRef<'a> { - fn from(node: &'a Pattern) -> AnyNodeRef<'a> { - match node { - Pattern::MatchValue(node) => AnyNodeRef::PatternMatchValue(node), - Pattern::MatchSingleton(node) => AnyNodeRef::PatternMatchSingleton(node), - Pattern::MatchSequence(node) => AnyNodeRef::PatternMatchSequence(node), - Pattern::MatchMapping(node) => AnyNodeRef::PatternMatchMapping(node), - Pattern::MatchClass(node) => AnyNodeRef::PatternMatchClass(node), - Pattern::MatchStar(node) => AnyNodeRef::PatternMatchStar(node), - Pattern::MatchAs(node) => AnyNodeRef::PatternMatchAs(node), - Pattern::MatchOr(node) => AnyNodeRef::PatternMatchOr(node), +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a Pattern>) -> AnyNodeRef<'a> { + match node.node { + Pattern::MatchValue(n) => AnyNodeRef::PatternMatchValue(node.ast.wrap(n)), + Pattern::MatchSingleton(n) => AnyNodeRef::PatternMatchSingleton(node.ast.wrap(n)), + Pattern::MatchSequence(n) => AnyNodeRef::PatternMatchSequence(node.ast.wrap(n)), + Pattern::MatchMapping(n) => AnyNodeRef::PatternMatchMapping(node.ast.wrap(n)), + Pattern::MatchClass(n) => AnyNodeRef::PatternMatchClass(node.ast.wrap(n)), + Pattern::MatchStar(n) => AnyNodeRef::PatternMatchStar(node.ast.wrap(n)), + Pattern::MatchAs(n) => AnyNodeRef::PatternMatchAs(node.ast.wrap(n)), + Pattern::MatchOr(n) => AnyNodeRef::PatternMatchOr(node.ast.wrap(n)), } } } @@ -2593,12 +6041,12 @@ impl<'a> From> for AnyNodeRef<'a> { } } -impl<'a> From<&'a TypeParam> for AnyNodeRef<'a> { - fn from(node: &'a TypeParam) -> AnyNodeRef<'a> { - match node { - TypeParam::TypeVar(node) => AnyNodeRef::TypeParamTypeVar(node), - TypeParam::TypeVarTuple(node) => AnyNodeRef::TypeParamTypeVarTuple(node), - TypeParam::ParamSpec(node) => AnyNodeRef::TypeParamParamSpec(node), +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a TypeParam>) -> AnyNodeRef<'a> { + match node.node { + TypeParam::TypeVar(n) => AnyNodeRef::TypeParamTypeVar(node.ast.wrap(n)), + TypeParam::TypeVarTuple(n) => AnyNodeRef::TypeParamTypeVarTuple(node.ast.wrap(n)), + TypeParam::ParamSpec(n) => AnyNodeRef::TypeParamParamSpec(node.ast.wrap(n)), } } } @@ -2613,554 +6061,554 @@ impl<'a> From> for AnyNodeRef<'a> { } } -impl<'a> From<&'a crate::ModModule> for AnyNodeRef<'a> { - fn from(node: &'a crate::ModModule) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ModModule>) -> AnyNodeRef<'a> { AnyNodeRef::ModModule(node) } } -impl<'a> From<&'a crate::ModExpression> for AnyNodeRef<'a> { - fn from(node: &'a crate::ModExpression) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ModExpression>) -> AnyNodeRef<'a> { AnyNodeRef::ModExpression(node) } } -impl<'a> From<&'a crate::StmtFunctionDef> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtFunctionDef) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtFunctionDef>) -> AnyNodeRef<'a> { AnyNodeRef::StmtFunctionDef(node) } } -impl<'a> From<&'a crate::StmtClassDef> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtClassDef) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtClassDef>) -> AnyNodeRef<'a> { AnyNodeRef::StmtClassDef(node) } } -impl<'a> From<&'a crate::StmtReturn> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtReturn) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtReturn>) -> AnyNodeRef<'a> { AnyNodeRef::StmtReturn(node) } } -impl<'a> From<&'a crate::StmtDelete> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtDelete) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtDelete>) -> AnyNodeRef<'a> { AnyNodeRef::StmtDelete(node) } } -impl<'a> From<&'a crate::StmtTypeAlias> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtTypeAlias) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtTypeAlias>) -> AnyNodeRef<'a> { AnyNodeRef::StmtTypeAlias(node) } } -impl<'a> From<&'a crate::StmtAssign> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtAssign) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAssign>) -> AnyNodeRef<'a> { AnyNodeRef::StmtAssign(node) } } -impl<'a> From<&'a crate::StmtAugAssign> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtAugAssign) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAugAssign>) -> AnyNodeRef<'a> { AnyNodeRef::StmtAugAssign(node) } } -impl<'a> From<&'a crate::StmtAnnAssign> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtAnnAssign) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAnnAssign>) -> AnyNodeRef<'a> { AnyNodeRef::StmtAnnAssign(node) } } -impl<'a> From<&'a crate::StmtFor> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtFor) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtFor>) -> AnyNodeRef<'a> { AnyNodeRef::StmtFor(node) } } -impl<'a> From<&'a crate::StmtWhile> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtWhile) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtWhile>) -> AnyNodeRef<'a> { AnyNodeRef::StmtWhile(node) } } -impl<'a> From<&'a crate::StmtIf> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtIf) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtIf>) -> AnyNodeRef<'a> { AnyNodeRef::StmtIf(node) } } -impl<'a> From<&'a crate::StmtWith> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtWith) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtWith>) -> AnyNodeRef<'a> { AnyNodeRef::StmtWith(node) } } -impl<'a> From<&'a crate::StmtMatch> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtMatch) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtMatch>) -> AnyNodeRef<'a> { AnyNodeRef::StmtMatch(node) } } -impl<'a> From<&'a crate::StmtRaise> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtRaise) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtRaise>) -> AnyNodeRef<'a> { AnyNodeRef::StmtRaise(node) } } -impl<'a> From<&'a crate::StmtTry> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtTry) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtTry>) -> AnyNodeRef<'a> { AnyNodeRef::StmtTry(node) } } -impl<'a> From<&'a crate::StmtAssert> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtAssert) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtAssert>) -> AnyNodeRef<'a> { AnyNodeRef::StmtAssert(node) } } -impl<'a> From<&'a crate::StmtImport> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtImport) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtImport>) -> AnyNodeRef<'a> { AnyNodeRef::StmtImport(node) } } -impl<'a> From<&'a crate::StmtImportFrom> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtImportFrom) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtImportFrom>) -> AnyNodeRef<'a> { AnyNodeRef::StmtImportFrom(node) } } -impl<'a> From<&'a crate::StmtGlobal> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtGlobal) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtGlobal>) -> AnyNodeRef<'a> { AnyNodeRef::StmtGlobal(node) } } -impl<'a> From<&'a crate::StmtNonlocal> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtNonlocal) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtNonlocal>) -> AnyNodeRef<'a> { AnyNodeRef::StmtNonlocal(node) } } -impl<'a> From<&'a crate::StmtExpr> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtExpr) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtExpr>) -> AnyNodeRef<'a> { AnyNodeRef::StmtExpr(node) } } -impl<'a> From<&'a crate::StmtPass> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtPass) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtPass>) -> AnyNodeRef<'a> { AnyNodeRef::StmtPass(node) } } -impl<'a> From<&'a crate::StmtBreak> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtBreak) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtBreak>) -> AnyNodeRef<'a> { AnyNodeRef::StmtBreak(node) } } -impl<'a> From<&'a crate::StmtContinue> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtContinue) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtContinue>) -> AnyNodeRef<'a> { AnyNodeRef::StmtContinue(node) } } -impl<'a> From<&'a crate::StmtIpyEscapeCommand> for AnyNodeRef<'a> { - fn from(node: &'a crate::StmtIpyEscapeCommand) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StmtIpyEscapeCommand>) -> AnyNodeRef<'a> { AnyNodeRef::StmtIpyEscapeCommand(node) } } -impl<'a> From<&'a crate::ExprBoolOp> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprBoolOp) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBoolOp>) -> AnyNodeRef<'a> { AnyNodeRef::ExprBoolOp(node) } } -impl<'a> From<&'a crate::ExprNamed> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprNamed) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprNamed>) -> AnyNodeRef<'a> { AnyNodeRef::ExprNamed(node) } } -impl<'a> From<&'a crate::ExprBinOp> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprBinOp) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBinOp>) -> AnyNodeRef<'a> { AnyNodeRef::ExprBinOp(node) } } -impl<'a> From<&'a crate::ExprUnaryOp> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprUnaryOp) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprUnaryOp>) -> AnyNodeRef<'a> { AnyNodeRef::ExprUnaryOp(node) } } -impl<'a> From<&'a crate::ExprLambda> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprLambda) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprLambda>) -> AnyNodeRef<'a> { AnyNodeRef::ExprLambda(node) } } -impl<'a> From<&'a crate::ExprIf> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprIf) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprIf>) -> AnyNodeRef<'a> { AnyNodeRef::ExprIf(node) } } -impl<'a> From<&'a crate::ExprDict> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprDict) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprDict>) -> AnyNodeRef<'a> { AnyNodeRef::ExprDict(node) } } -impl<'a> From<&'a crate::ExprSet> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprSet) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSet>) -> AnyNodeRef<'a> { AnyNodeRef::ExprSet(node) } } -impl<'a> From<&'a crate::ExprListComp> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprListComp) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprListComp>) -> AnyNodeRef<'a> { AnyNodeRef::ExprListComp(node) } } -impl<'a> From<&'a crate::ExprSetComp> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprSetComp) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSetComp>) -> AnyNodeRef<'a> { AnyNodeRef::ExprSetComp(node) } } -impl<'a> From<&'a crate::ExprDictComp> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprDictComp) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprDictComp>) -> AnyNodeRef<'a> { AnyNodeRef::ExprDictComp(node) } } -impl<'a> From<&'a crate::ExprGenerator> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprGenerator) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprGenerator>) -> AnyNodeRef<'a> { AnyNodeRef::ExprGenerator(node) } } -impl<'a> From<&'a crate::ExprAwait> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprAwait) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprAwait>) -> AnyNodeRef<'a> { AnyNodeRef::ExprAwait(node) } } -impl<'a> From<&'a crate::ExprYield> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprYield) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprYield>) -> AnyNodeRef<'a> { AnyNodeRef::ExprYield(node) } } -impl<'a> From<&'a crate::ExprYieldFrom> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprYieldFrom) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprYieldFrom>) -> AnyNodeRef<'a> { AnyNodeRef::ExprYieldFrom(node) } } -impl<'a> From<&'a crate::ExprCompare> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprCompare) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprCompare>) -> AnyNodeRef<'a> { AnyNodeRef::ExprCompare(node) } } -impl<'a> From<&'a crate::ExprCall> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprCall) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprCall>) -> AnyNodeRef<'a> { AnyNodeRef::ExprCall(node) } } -impl<'a> From<&'a crate::ExprFString> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprFString) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprFString>) -> AnyNodeRef<'a> { AnyNodeRef::ExprFString(node) } } -impl<'a> From<&'a crate::ExprStringLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprStringLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprStringLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::ExprStringLiteral(node) } } -impl<'a> From<&'a crate::ExprBytesLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprBytesLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBytesLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::ExprBytesLiteral(node) } } -impl<'a> From<&'a crate::ExprNumberLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprNumberLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprNumberLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::ExprNumberLiteral(node) } } -impl<'a> From<&'a crate::ExprBooleanLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprBooleanLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprBooleanLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::ExprBooleanLiteral(node) } } -impl<'a> From<&'a crate::ExprNoneLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprNoneLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprNoneLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::ExprNoneLiteral(node) } } -impl<'a> From<&'a crate::ExprEllipsisLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprEllipsisLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprEllipsisLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::ExprEllipsisLiteral(node) } } -impl<'a> From<&'a crate::ExprAttribute> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprAttribute) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprAttribute>) -> AnyNodeRef<'a> { AnyNodeRef::ExprAttribute(node) } } -impl<'a> From<&'a crate::ExprSubscript> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprSubscript) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSubscript>) -> AnyNodeRef<'a> { AnyNodeRef::ExprSubscript(node) } } -impl<'a> From<&'a crate::ExprStarred> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprStarred) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprStarred>) -> AnyNodeRef<'a> { AnyNodeRef::ExprStarred(node) } } -impl<'a> From<&'a crate::ExprName> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprName) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprName>) -> AnyNodeRef<'a> { AnyNodeRef::ExprName(node) } } -impl<'a> From<&'a crate::ExprList> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprList) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprList>) -> AnyNodeRef<'a> { AnyNodeRef::ExprList(node) } } -impl<'a> From<&'a crate::ExprTuple> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprTuple) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprTuple>) -> AnyNodeRef<'a> { AnyNodeRef::ExprTuple(node) } } -impl<'a> From<&'a crate::ExprSlice> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprSlice) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprSlice>) -> AnyNodeRef<'a> { AnyNodeRef::ExprSlice(node) } } -impl<'a> From<&'a crate::ExprIpyEscapeCommand> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExprIpyEscapeCommand) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExprIpyEscapeCommand>) -> AnyNodeRef<'a> { AnyNodeRef::ExprIpyEscapeCommand(node) } } -impl<'a> From<&'a crate::ExceptHandlerExceptHandler> for AnyNodeRef<'a> { - fn from(node: &'a crate::ExceptHandlerExceptHandler) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ExceptHandlerExceptHandler>) -> AnyNodeRef<'a> { AnyNodeRef::ExceptHandlerExceptHandler(node) } } -impl<'a> From<&'a crate::FStringExpressionElement> for AnyNodeRef<'a> { - fn from(node: &'a crate::FStringExpressionElement) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::FStringExpressionElement>) -> AnyNodeRef<'a> { AnyNodeRef::FStringExpressionElement(node) } } -impl<'a> From<&'a crate::FStringLiteralElement> for AnyNodeRef<'a> { - fn from(node: &'a crate::FStringLiteralElement) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::FStringLiteralElement>) -> AnyNodeRef<'a> { AnyNodeRef::FStringLiteralElement(node) } } -impl<'a> From<&'a crate::PatternMatchValue> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchValue) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchValue>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchValue(node) } } -impl<'a> From<&'a crate::PatternMatchSingleton> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchSingleton) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchSingleton>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchSingleton(node) } } -impl<'a> From<&'a crate::PatternMatchSequence> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchSequence) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchSequence>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchSequence(node) } } -impl<'a> From<&'a crate::PatternMatchMapping> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchMapping) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchMapping>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchMapping(node) } } -impl<'a> From<&'a crate::PatternMatchClass> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchClass) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchClass>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchClass(node) } } -impl<'a> From<&'a crate::PatternMatchStar> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchStar) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchStar>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchStar(node) } } -impl<'a> From<&'a crate::PatternMatchAs> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchAs) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchAs>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchAs(node) } } -impl<'a> From<&'a crate::PatternMatchOr> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternMatchOr) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternMatchOr>) -> AnyNodeRef<'a> { AnyNodeRef::PatternMatchOr(node) } } -impl<'a> From<&'a crate::TypeParamTypeVar> for AnyNodeRef<'a> { - fn from(node: &'a crate::TypeParamTypeVar) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::TypeParamTypeVar>) -> AnyNodeRef<'a> { AnyNodeRef::TypeParamTypeVar(node) } } -impl<'a> From<&'a crate::TypeParamTypeVarTuple> for AnyNodeRef<'a> { - fn from(node: &'a crate::TypeParamTypeVarTuple) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::TypeParamTypeVarTuple>) -> AnyNodeRef<'a> { AnyNodeRef::TypeParamTypeVarTuple(node) } } -impl<'a> From<&'a crate::TypeParamParamSpec> for AnyNodeRef<'a> { - fn from(node: &'a crate::TypeParamParamSpec) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::TypeParamParamSpec>) -> AnyNodeRef<'a> { AnyNodeRef::TypeParamParamSpec(node) } } -impl<'a> From<&'a crate::FStringFormatSpec> for AnyNodeRef<'a> { - fn from(node: &'a crate::FStringFormatSpec) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::FStringFormatSpec>) -> AnyNodeRef<'a> { AnyNodeRef::FStringFormatSpec(node) } } -impl<'a> From<&'a crate::PatternArguments> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternArguments) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternArguments>) -> AnyNodeRef<'a> { AnyNodeRef::PatternArguments(node) } } -impl<'a> From<&'a crate::PatternKeyword> for AnyNodeRef<'a> { - fn from(node: &'a crate::PatternKeyword) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::PatternKeyword>) -> AnyNodeRef<'a> { AnyNodeRef::PatternKeyword(node) } } -impl<'a> From<&'a crate::Comprehension> for AnyNodeRef<'a> { - fn from(node: &'a crate::Comprehension) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Comprehension>) -> AnyNodeRef<'a> { AnyNodeRef::Comprehension(node) } } -impl<'a> From<&'a crate::Arguments> for AnyNodeRef<'a> { - fn from(node: &'a crate::Arguments) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Arguments>) -> AnyNodeRef<'a> { AnyNodeRef::Arguments(node) } } -impl<'a> From<&'a crate::Parameters> for AnyNodeRef<'a> { - fn from(node: &'a crate::Parameters) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Parameters>) -> AnyNodeRef<'a> { AnyNodeRef::Parameters(node) } } -impl<'a> From<&'a crate::Parameter> for AnyNodeRef<'a> { - fn from(node: &'a crate::Parameter) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Parameter>) -> AnyNodeRef<'a> { AnyNodeRef::Parameter(node) } } -impl<'a> From<&'a crate::ParameterWithDefault> for AnyNodeRef<'a> { - fn from(node: &'a crate::ParameterWithDefault) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ParameterWithDefault>) -> AnyNodeRef<'a> { AnyNodeRef::ParameterWithDefault(node) } } -impl<'a> From<&'a crate::Keyword> for AnyNodeRef<'a> { - fn from(node: &'a crate::Keyword) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Keyword>) -> AnyNodeRef<'a> { AnyNodeRef::Keyword(node) } } -impl<'a> From<&'a crate::Alias> for AnyNodeRef<'a> { - fn from(node: &'a crate::Alias) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Alias>) -> AnyNodeRef<'a> { AnyNodeRef::Alias(node) } } -impl<'a> From<&'a crate::WithItem> for AnyNodeRef<'a> { - fn from(node: &'a crate::WithItem) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::WithItem>) -> AnyNodeRef<'a> { AnyNodeRef::WithItem(node) } } -impl<'a> From<&'a crate::MatchCase> for AnyNodeRef<'a> { - fn from(node: &'a crate::MatchCase) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::MatchCase>) -> AnyNodeRef<'a> { AnyNodeRef::MatchCase(node) } } -impl<'a> From<&'a crate::Decorator> for AnyNodeRef<'a> { - fn from(node: &'a crate::Decorator) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Decorator>) -> AnyNodeRef<'a> { AnyNodeRef::Decorator(node) } } -impl<'a> From<&'a crate::ElifElseClause> for AnyNodeRef<'a> { - fn from(node: &'a crate::ElifElseClause) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::ElifElseClause>) -> AnyNodeRef<'a> { AnyNodeRef::ElifElseClause(node) } } -impl<'a> From<&'a crate::TypeParams> for AnyNodeRef<'a> { - fn from(node: &'a crate::TypeParams) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::TypeParams>) -> AnyNodeRef<'a> { AnyNodeRef::TypeParams(node) } } -impl<'a> From<&'a crate::FString> for AnyNodeRef<'a> { - fn from(node: &'a crate::FString) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::FString>) -> AnyNodeRef<'a> { AnyNodeRef::FString(node) } } -impl<'a> From<&'a crate::StringLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::StringLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::StringLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::StringLiteral(node) } } -impl<'a> From<&'a crate::BytesLiteral> for AnyNodeRef<'a> { - fn from(node: &'a crate::BytesLiteral) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::BytesLiteral>) -> AnyNodeRef<'a> { AnyNodeRef::BytesLiteral(node) } } -impl<'a> From<&'a crate::Identifier> for AnyNodeRef<'a> { - fn from(node: &'a crate::Identifier) -> AnyNodeRef<'a> { +impl<'a> From> for AnyNodeRef<'a> { + fn from(node: crate::Node<'a, &'a crate::Identifier>) -> AnyNodeRef<'a> { AnyNodeRef::Identifier(node) } } @@ -3267,98 +6715,108 @@ impl ruff_text_size::Ranged for AnyNodeRef<'_> { impl AnyNodeRef<'_> { pub fn as_ptr(&self) -> std::ptr::NonNull<()> { match self { - AnyNodeRef::ModModule(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ModExpression(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtFunctionDef(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtClassDef(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtReturn(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtDelete(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtTypeAlias(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtAssign(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtAugAssign(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtAnnAssign(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtFor(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtWhile(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtIf(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtWith(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtMatch(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtRaise(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtTry(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtAssert(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtImport(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtImportFrom(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtGlobal(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtNonlocal(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtExpr(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtPass(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtBreak(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtContinue(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StmtIpyEscapeCommand(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprBoolOp(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprNamed(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprBinOp(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprUnaryOp(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprLambda(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprIf(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprDict(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprSet(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprListComp(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprSetComp(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprDictComp(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprGenerator(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprAwait(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprYield(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprYieldFrom(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprCompare(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprCall(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprFString(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprStringLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprBytesLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprNumberLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprBooleanLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprNoneLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprEllipsisLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprAttribute(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprSubscript(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprStarred(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprName(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprList(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprTuple(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprSlice(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExprIpyEscapeCommand(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ExceptHandlerExceptHandler(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::FStringExpressionElement(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::FStringLiteralElement(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchValue(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchSingleton(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchSequence(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchMapping(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchClass(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchStar(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchAs(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternMatchOr(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::TypeParamTypeVar(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::TypeParamTypeVarTuple(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::TypeParamParamSpec(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::FStringFormatSpec(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternArguments(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::PatternKeyword(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Comprehension(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Arguments(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Parameters(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Parameter(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ParameterWithDefault(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Keyword(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Alias(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::WithItem(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::MatchCase(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Decorator(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::ElifElseClause(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::TypeParams(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::FString(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::StringLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::BytesLiteral(node) => std::ptr::NonNull::from(*node).cast(), - AnyNodeRef::Identifier(node) => std::ptr::NonNull::from(*node).cast(), + AnyNodeRef::ModModule(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ModExpression(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtFunctionDef(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtClassDef(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtReturn(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtDelete(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtTypeAlias(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtAssign(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtAugAssign(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtAnnAssign(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtFor(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtWhile(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtIf(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtWith(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtMatch(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtRaise(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtTry(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtAssert(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtImport(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtImportFrom(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtGlobal(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtNonlocal(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtExpr(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtPass(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtBreak(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtContinue(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StmtIpyEscapeCommand(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprBoolOp(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprNamed(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprBinOp(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprUnaryOp(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprLambda(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprIf(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprDict(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprSet(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprListComp(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprSetComp(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprDictComp(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprGenerator(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprAwait(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprYield(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprYieldFrom(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprCompare(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprCall(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprFString(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprStringLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprBytesLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprNumberLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprBooleanLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprNoneLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprEllipsisLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprAttribute(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprSubscript(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprStarred(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprName(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprList(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprTuple(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprSlice(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExprIpyEscapeCommand(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ExceptHandlerExceptHandler(node) => { + std::ptr::NonNull::from(node.as_ref()).cast() + } + AnyNodeRef::FStringExpressionElement(node) => { + std::ptr::NonNull::from(node.as_ref()).cast() + } + AnyNodeRef::FStringLiteralElement(node) => { + std::ptr::NonNull::from(node.as_ref()).cast() + } + AnyNodeRef::PatternMatchValue(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternMatchSingleton(node) => { + std::ptr::NonNull::from(node.as_ref()).cast() + } + AnyNodeRef::PatternMatchSequence(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternMatchMapping(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternMatchClass(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternMatchStar(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternMatchAs(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternMatchOr(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::TypeParamTypeVar(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::TypeParamTypeVarTuple(node) => { + std::ptr::NonNull::from(node.as_ref()).cast() + } + AnyNodeRef::TypeParamParamSpec(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::FStringFormatSpec(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternArguments(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::PatternKeyword(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Comprehension(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Arguments(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Parameters(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Parameter(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ParameterWithDefault(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Keyword(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Alias(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::WithItem(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::MatchCase(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Decorator(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::ElifElseClause(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::TypeParams(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::FString(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::StringLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::BytesLiteral(node) => std::ptr::NonNull::from(node.as_ref()).cast(), + AnyNodeRef::Identifier(node) => std::ptr::NonNull::from(node.as_ref()).cast(), } } } diff --git a/crates/ruff_python_ast/src/lib.rs b/crates/ruff_python_ast/src/lib.rs index 6f7ab46296..bc03fe04ad 100644 --- a/crates/ruff_python_ast/src/lib.rs +++ b/crates/ruff_python_ast/src/lib.rs @@ -1,11 +1,13 @@ use std::ffi::OsStr; use std::path::Path; +pub use ast::{Ast, Node}; pub use expression::*; pub use generated::*; pub use int::*; pub use nodes::*; +pub mod ast; pub mod comparable; pub mod docstrings; mod expression; diff --git a/crates/ruff_python_ast/src/node.rs b/crates/ruff_python_ast/src/node.rs index a3bbb669d6..b7ce9b0929 100644 --- a/crates/ruff_python_ast/src/node.rs +++ b/crates/ruff_python_ast/src/node.rs @@ -1,31 +1,31 @@ use crate::visitor::source_order::SourceOrderVisitor; use crate::{ - self as ast, Alias, AnyNodeRef, AnyParameterRef, ArgOrKeyword, MatchCase, PatternArguments, - PatternKeyword, + self as ast, Alias, AnyNodeRef, AnyParameterRef, ArgOrKeyword, MatchCase, Node, + PatternArguments, PatternKeyword, }; -impl ast::ModModule { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ModModule> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ModModule { body, range: _ } = self; + let ast::ModModule { body, range: _ } = self.as_ref(); visitor.visit_body(body); } } -impl ast::ModExpression { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ModExpression> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ModExpression { body, range: _ } = self; + let ast::ModExpression { body, range: _ } = self.as_ref(); visitor.visit_expr(body); } } -impl ast::StmtFunctionDef { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtFunctionDef> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -36,7 +36,7 @@ impl ast::StmtFunctionDef { returns, type_params, .. - } = self; + } = self.as_ref(); for decorator in decorator_list { visitor.visit_decorator(decorator); @@ -56,8 +56,8 @@ impl ast::StmtFunctionDef { } } -impl ast::StmtClassDef { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtClassDef> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -67,7 +67,7 @@ impl ast::StmtClassDef { decorator_list, type_params, .. - } = self; + } = self.as_ref(); for decorator in decorator_list { visitor.visit_decorator(decorator); @@ -85,32 +85,32 @@ impl ast::StmtClassDef { } } -impl ast::StmtReturn { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtReturn> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtReturn { value, range: _ } = self; + let ast::StmtReturn { value, range: _ } = self.as_ref(); if let Some(expr) = value { visitor.visit_expr(expr); } } } -impl ast::StmtDelete { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtDelete> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtDelete { targets, range: _ } = self; + let ast::StmtDelete { targets, range: _ } = self.as_ref(); for expr in targets { visitor.visit_expr(expr); } } } -impl ast::StmtTypeAlias { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtTypeAlias> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -119,7 +119,7 @@ impl ast::StmtTypeAlias { name, type_params, value, - } = self; + } = self.as_ref(); visitor.visit_expr(name); if let Some(type_params) = type_params { @@ -129,8 +129,8 @@ impl ast::StmtTypeAlias { } } -impl ast::StmtAssign { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtAssign> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -138,7 +138,7 @@ impl ast::StmtAssign { targets, value, range: _, - } = self; + } = self.as_ref(); for expr in targets { visitor.visit_expr(expr); @@ -148,8 +148,8 @@ impl ast::StmtAssign { } } -impl ast::StmtAugAssign { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtAugAssign> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -158,7 +158,7 @@ impl ast::StmtAugAssign { op, value, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(target); visitor.visit_operator(op); @@ -166,8 +166,8 @@ impl ast::StmtAugAssign { } } -impl ast::StmtAnnAssign { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtAnnAssign> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -177,7 +177,7 @@ impl ast::StmtAnnAssign { value, range: _, simple: _, - } = self; + } = self.as_ref(); visitor.visit_expr(target); visitor.visit_annotation(annotation); @@ -187,8 +187,8 @@ impl ast::StmtAnnAssign { } } -impl ast::StmtFor { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtFor> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -198,7 +198,7 @@ impl ast::StmtFor { body, orelse, .. - } = self; + } = self.as_ref(); visitor.visit_expr(target); visitor.visit_expr(iter); @@ -207,8 +207,8 @@ impl ast::StmtFor { } } -impl ast::StmtWhile { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtWhile> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -217,7 +217,7 @@ impl ast::StmtWhile { body, orelse, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(test); visitor.visit_body(body); @@ -225,8 +225,8 @@ impl ast::StmtWhile { } } -impl ast::StmtIf { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtIf> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -235,7 +235,7 @@ impl ast::StmtIf { body, elif_else_clauses, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(test); visitor.visit_body(body); @@ -245,8 +245,8 @@ impl ast::StmtIf { } } -impl ast::ElifElseClause { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ElifElseClause> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -254,7 +254,7 @@ impl ast::ElifElseClause { range: _, test, body, - } = self; + } = self.as_ref(); if let Some(test) = test { visitor.visit_expr(test); } @@ -262,8 +262,8 @@ impl ast::ElifElseClause { } } -impl ast::StmtWith { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtWith> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -272,7 +272,7 @@ impl ast::StmtWith { body, is_async: _, range: _, - } = self; + } = self.as_ref(); for with_item in items { visitor.visit_with_item(with_item); @@ -281,8 +281,8 @@ impl ast::StmtWith { } } -impl ast::StmtMatch { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtMatch> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -290,7 +290,7 @@ impl ast::StmtMatch { subject, cases, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(subject); for match_case in cases { @@ -299,8 +299,8 @@ impl ast::StmtMatch { } } -impl ast::StmtRaise { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtRaise> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -308,7 +308,7 @@ impl ast::StmtRaise { exc, cause, range: _, - } = self; + } = self.as_ref(); if let Some(expr) = exc { visitor.visit_expr(expr); @@ -319,8 +319,8 @@ impl ast::StmtRaise { } } -impl ast::StmtTry { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtTry> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -331,7 +331,7 @@ impl ast::StmtTry { finalbody, is_star: _, range: _, - } = self; + } = self.as_ref(); visitor.visit_body(body); for except_handler in handlers { @@ -342,8 +342,8 @@ impl ast::StmtTry { } } -impl ast::StmtAssert { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtAssert> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -351,7 +351,7 @@ impl ast::StmtAssert { test, msg, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(test); if let Some(expr) = msg { visitor.visit_expr(expr); @@ -359,12 +359,12 @@ impl ast::StmtAssert { } } -impl ast::StmtImport { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtImport> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtImport { names, range: _ } = self; + let ast::StmtImport { names, range: _ } = self.as_ref(); for alias in names { visitor.visit_alias(alias); @@ -372,8 +372,8 @@ impl ast::StmtImport { } } -impl ast::StmtImportFrom { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtImportFrom> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -382,7 +382,7 @@ impl ast::StmtImportFrom { module: _, names, level: _, - } = self; + } = self.as_ref(); for alias in names { visitor.visit_alias(alias); @@ -390,69 +390,69 @@ impl ast::StmtImportFrom { } } -impl ast::StmtGlobal { +impl<'a> Node<'a, &'a ast::StmtGlobal> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtGlobal { range: _, names: _ } = self; + let ast::StmtGlobal { range: _, names: _ } = self.as_ref(); } } -impl ast::StmtNonlocal { +impl<'a> Node<'a, &'a ast::StmtNonlocal> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtNonlocal { range: _, names: _ } = self; + let ast::StmtNonlocal { range: _, names: _ } = self.as_ref(); } } -impl ast::StmtExpr { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::StmtExpr> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtExpr { value, range: _ } = self; + let ast::StmtExpr { value, range: _ } = self.as_ref(); visitor.visit_expr(value); } } -impl ast::StmtPass { +impl<'a> Node<'a, &'a ast::StmtPass> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtPass { range: _ } = self; + let ast::StmtPass { range: _ } = self.as_ref(); } } -impl ast::StmtBreak { +impl<'a> Node<'a, &'a ast::StmtBreak> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtBreak { range: _ } = self; + let ast::StmtBreak { range: _ } = self.as_ref(); } } -impl ast::StmtContinue { +impl<'a> Node<'a, &'a ast::StmtContinue> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::StmtContinue { range: _ } = self; + let ast::StmtContinue { range: _ } = self.as_ref(); } } -impl ast::StmtIpyEscapeCommand { +impl<'a> Node<'a, &'a ast::StmtIpyEscapeCommand> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -460,12 +460,12 @@ impl ast::StmtIpyEscapeCommand { range: _, kind: _, value: _, - } = self; + } = self.as_ref(); } } -impl ast::ExprBoolOp { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprBoolOp> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -473,7 +473,7 @@ impl ast::ExprBoolOp { op, values, range: _, - } = self; + } = self.as_ref(); match values.as_slice() { [left, rest @ ..] => { visitor.visit_expr(left); @@ -489,8 +489,8 @@ impl ast::ExprBoolOp { } } -impl ast::ExprNamed { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprNamed> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -498,14 +498,14 @@ impl ast::ExprNamed { target, value, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(target); visitor.visit_expr(value); } } -impl ast::ExprBinOp { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprBinOp> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -514,15 +514,15 @@ impl ast::ExprBinOp { op, right, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(left); visitor.visit_operator(op); visitor.visit_expr(right); } } -impl ast::ExprUnaryOp { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprUnaryOp> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -530,15 +530,15 @@ impl ast::ExprUnaryOp { op, operand, range: _, - } = self; + } = self.as_ref(); visitor.visit_unary_op(op); visitor.visit_expr(operand); } } -impl ast::ExprLambda { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprLambda> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -546,7 +546,7 @@ impl ast::ExprLambda { parameters, body, range: _, - } = self; + } = self.as_ref(); if let Some(parameters) = parameters { visitor.visit_parameters(parameters); @@ -555,8 +555,8 @@ impl ast::ExprLambda { } } -impl ast::ExprIf { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprIf> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -565,7 +565,7 @@ impl ast::ExprIf { body, orelse, range: _, - } = self; + } = self.as_ref(); // `body if test else orelse` visitor.visit_expr(body); @@ -574,12 +574,12 @@ impl ast::ExprIf { } } -impl ast::ExprDict { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprDict> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprDict { items, range: _ } = self; + let ast::ExprDict { items, range: _ } = self.as_ref(); for ast::DictItem { key, value } in items { if let Some(key) = key { @@ -590,12 +590,12 @@ impl ast::ExprDict { } } -impl ast::ExprSet { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprSet> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprSet { elts, range: _ } = self; + let ast::ExprSet { elts, range: _ } = self.as_ref(); for expr in elts { visitor.visit_expr(expr); @@ -603,8 +603,8 @@ impl ast::ExprSet { } } -impl ast::ExprListComp { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprListComp> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -612,7 +612,7 @@ impl ast::ExprListComp { elt, generators, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(elt); for comprehension in generators { @@ -621,8 +621,8 @@ impl ast::ExprListComp { } } -impl ast::ExprSetComp { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprSetComp> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -630,7 +630,7 @@ impl ast::ExprSetComp { elt, generators, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(elt); for comprehension in generators { @@ -639,8 +639,8 @@ impl ast::ExprSetComp { } } -impl ast::ExprDictComp { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprDictComp> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -649,7 +649,7 @@ impl ast::ExprDictComp { value, generators, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(key); visitor.visit_expr(value); @@ -660,8 +660,8 @@ impl ast::ExprDictComp { } } -impl ast::ExprGenerator { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprGenerator> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -670,7 +670,7 @@ impl ast::ExprGenerator { generators, range: _, parenthesized: _, - } = self; + } = self.as_ref(); visitor.visit_expr(elt); for comprehension in generators { visitor.visit_comprehension(comprehension); @@ -678,40 +678,40 @@ impl ast::ExprGenerator { } } -impl ast::ExprAwait { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprAwait> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprAwait { value, range: _ } = self; + let ast::ExprAwait { value, range: _ } = self.as_ref(); visitor.visit_expr(value); } } -impl ast::ExprYield { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprYield> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprYield { value, range: _ } = self; + let ast::ExprYield { value, range: _ } = self.as_ref(); if let Some(expr) = value { visitor.visit_expr(expr); } } } -impl ast::ExprYieldFrom { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprYieldFrom> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprYieldFrom { value, range: _ } = self; + let ast::ExprYieldFrom { value, range: _ } = self.as_ref(); visitor.visit_expr(value); } } -impl ast::ExprCompare { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprCompare> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -720,7 +720,7 @@ impl ast::ExprCompare { ops, comparators, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(left); @@ -731,8 +731,8 @@ impl ast::ExprCompare { } } -impl ast::ExprCall { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprCall> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -740,14 +740,14 @@ impl ast::ExprCall { func, arguments, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(func); visitor.visit_arguments(arguments); } } -impl ast::FStringFormatSpec { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::FStringFormatSpec> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -766,7 +766,7 @@ impl ast::FStringExpressionElement { expression, format_spec, .. - } = self; + } = self.as_ref(); visitor.visit_expr(expression); if let Some(format_spec) = format_spec { @@ -777,21 +777,21 @@ impl ast::FStringExpressionElement { } } -impl ast::FStringLiteralElement { - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) +impl<'a> Node<'a, &'a ast::FStringLiteralElement> { + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::FStringLiteralElement { range: _, value: _ } = self; + let ast::FStringLiteralElement { range: _, value: _ } = self.as_ref(); } } -impl ast::ExprFString { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprFString> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprFString { value, range: _ } = self; + let ast::ExprFString { value, range: _ } = self.as_ref(); for f_string_part in value { match f_string_part { @@ -806,12 +806,12 @@ impl ast::ExprFString { } } -impl ast::ExprStringLiteral { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprStringLiteral> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprStringLiteral { value, range: _ } = self; + let ast::ExprStringLiteral { value, range: _ } = self.as_ref(); for string_literal in value { visitor.visit_string_literal(string_literal); @@ -819,12 +819,12 @@ impl ast::ExprStringLiteral { } } -impl ast::ExprBytesLiteral { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprBytesLiteral> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprBytesLiteral { value, range: _ } = self; + let ast::ExprBytesLiteral { value, range: _ } = self.as_ref(); for bytes_literal in value { visitor.visit_bytes_literal(bytes_literal); @@ -832,48 +832,48 @@ impl ast::ExprBytesLiteral { } } -impl ast::ExprNumberLiteral { +impl<'a> Node<'a, &'a ast::ExprNumberLiteral> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprNumberLiteral { range: _, value: _ } = self; + let ast::ExprNumberLiteral { range: _, value: _ } = self.as_ref(); } } -impl ast::ExprBooleanLiteral { +impl<'a> Node<'a, &'a ast::ExprBooleanLiteral> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprBooleanLiteral { range: _, value: _ } = self; + let ast::ExprBooleanLiteral { range: _, value: _ } = self.as_ref(); } } -impl ast::ExprNoneLiteral { +impl<'a> Node<'a, &'a ast::ExprNoneLiteral> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprNoneLiteral { range: _ } = self; + let ast::ExprNoneLiteral { range: _ } = self.as_ref(); } } -impl ast::ExprEllipsisLiteral { +impl<'a> Node<'a, &'a ast::ExprEllipsisLiteral> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::ExprEllipsisLiteral { range: _ } = self; + let ast::ExprEllipsisLiteral { range: _ } = self.as_ref(); } } -impl ast::ExprAttribute { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprAttribute> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -882,14 +882,14 @@ impl ast::ExprAttribute { attr: _, ctx: _, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(value); } } -impl ast::ExprSubscript { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprSubscript> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -898,14 +898,14 @@ impl ast::ExprSubscript { slice, ctx: _, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(value); visitor.visit_expr(slice); } } -impl ast::ExprStarred { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprStarred> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -913,15 +913,15 @@ impl ast::ExprStarred { value, ctx: _, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(value); } } -impl ast::ExprName { +impl<'a> Node<'a, &'a ast::ExprName> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -929,12 +929,12 @@ impl ast::ExprName { range: _, id: _, ctx: _, - } = self; + } = self.as_ref(); } } -impl ast::ExprList { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprList> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -942,7 +942,7 @@ impl ast::ExprList { elts, ctx: _, range: _, - } = self; + } = self.as_ref(); for expr in elts { visitor.visit_expr(expr); @@ -950,8 +950,8 @@ impl ast::ExprList { } } -impl ast::ExprTuple { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprTuple> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -960,7 +960,7 @@ impl ast::ExprTuple { ctx: _, range: _, parenthesized: _, - } = self; + } = self.as_ref(); for expr in elts { visitor.visit_expr(expr); @@ -968,8 +968,8 @@ impl ast::ExprTuple { } } -impl ast::ExprSlice { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExprSlice> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -978,7 +978,7 @@ impl ast::ExprSlice { upper, step, range: _, - } = self; + } = self.as_ref(); if let Some(expr) = lower { visitor.visit_expr(expr); @@ -992,9 +992,9 @@ impl ast::ExprSlice { } } -impl ast::ExprIpyEscapeCommand { +impl<'a> Node<'a, &'a ast::ExprIpyEscapeCommand> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1002,12 +1002,12 @@ impl ast::ExprIpyEscapeCommand { range: _, kind: _, value: _, - } = self; + } = self.as_ref(); } } -impl ast::ExceptHandlerExceptHandler { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ExceptHandlerExceptHandler> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1016,7 +1016,7 @@ impl ast::ExceptHandlerExceptHandler { type_, name: _, body, - } = self; + } = self.as_ref(); if let Some(expr) = type_ { visitor.visit_expr(expr); } @@ -1024,40 +1024,40 @@ impl ast::ExceptHandlerExceptHandler { } } -impl ast::PatternMatchValue { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternMatchValue> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::PatternMatchValue { value, range: _ } = self; + let ast::PatternMatchValue { value, range: _ } = self.as_ref(); visitor.visit_expr(value); } } -impl ast::PatternMatchSingleton { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternMatchSingleton> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::PatternMatchSingleton { value, range: _ } = self; + let ast::PatternMatchSingleton { value, range: _ } = self.as_ref(); visitor.visit_singleton(value); } } -impl ast::PatternMatchSequence { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternMatchSequence> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::PatternMatchSequence { patterns, range: _ } = self; + let ast::PatternMatchSequence { patterns, range: _ } = self.as_ref(); for pattern in patterns { visitor.visit_pattern(pattern); } } } -impl ast::PatternMatchMapping { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternMatchMapping> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1066,7 +1066,7 @@ impl ast::PatternMatchMapping { patterns, range: _, rest: _, - } = self; + } = self.as_ref(); for (key, pattern) in keys.iter().zip(patterns) { visitor.visit_expr(key); visitor.visit_pattern(pattern); @@ -1074,8 +1074,8 @@ impl ast::PatternMatchMapping { } } -impl ast::PatternMatchClass { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternMatchClass> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1083,24 +1083,24 @@ impl ast::PatternMatchClass { cls, arguments: parameters, range: _, - } = self; + } = self.as_ref(); visitor.visit_expr(cls); visitor.visit_pattern_arguments(parameters); } } -impl ast::PatternMatchStar { +impl<'a> Node<'a, &'a ast::PatternMatchStar> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::PatternMatchStar { range: _, name: _ } = self; + let ast::PatternMatchStar { range: _, name: _ } = self.as_ref(); } } -impl ast::PatternMatchAs { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternMatchAs> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1108,27 +1108,27 @@ impl ast::PatternMatchAs { pattern, range: _, name: _, - } = self; + } = self.as_ref(); if let Some(pattern) = pattern { visitor.visit_pattern(pattern); } } } -impl ast::PatternMatchOr { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternMatchOr> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::PatternMatchOr { patterns, range: _ } = self; + let ast::PatternMatchOr { patterns, range: _ } = self.as_ref(); for pattern in patterns { visitor.visit_pattern(pattern); } } } -impl ast::PatternArguments { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternArguments> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1136,7 +1136,7 @@ impl ast::PatternArguments { range: _, patterns, keywords, - } = self; + } = self.as_ref(); for pattern in patterns { visitor.visit_pattern(pattern); @@ -1148,8 +1148,8 @@ impl ast::PatternArguments { } } -impl ast::PatternKeyword { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::PatternKeyword> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1157,14 +1157,14 @@ impl ast::PatternKeyword { range: _, attr: _, pattern, - } = self; + } = self.as_ref(); visitor.visit_pattern(pattern); } } -impl ast::Comprehension { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::Comprehension> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1174,7 +1174,7 @@ impl ast::Comprehension { iter, ifs, is_async: _, - } = self; + } = self.as_ref(); visitor.visit_expr(target); visitor.visit_expr(iter); @@ -1184,8 +1184,8 @@ impl ast::Comprehension { } } -impl ast::Arguments { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::Arguments> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1198,8 +1198,8 @@ impl ast::Arguments { } } -impl ast::Parameters { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::Parameters> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1214,8 +1214,8 @@ impl ast::Parameters { } } -impl ast::Parameter { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::Parameter> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1223,7 +1223,7 @@ impl ast::Parameter { range: _, name: _, annotation, - } = self; + } = self.as_ref(); if let Some(expr) = annotation { visitor.visit_annotation(expr); @@ -1231,8 +1231,8 @@ impl ast::Parameter { } } -impl ast::ParameterWithDefault { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::ParameterWithDefault> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1240,7 +1240,7 @@ impl ast::ParameterWithDefault { range: _, parameter, default, - } = self; + } = self.as_ref(); visitor.visit_parameter(parameter); if let Some(expr) = default { visitor.visit_expr(expr); @@ -1248,8 +1248,8 @@ impl ast::ParameterWithDefault { } } -impl ast::Keyword { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::Keyword> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1257,15 +1257,15 @@ impl ast::Keyword { range: _, arg: _, value, - } = self; + } = self.as_ref(); visitor.visit_expr(value); } } -impl Alias { +impl<'a> Node<'a, &'a Alias> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1273,12 +1273,12 @@ impl Alias { range: _, name: _, asname: _, - } = self; + } = self.as_ref(); } } -impl ast::WithItem { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::WithItem> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1286,7 +1286,7 @@ impl ast::WithItem { range: _, context_expr, optional_vars, - } = self; + } = self.as_ref(); visitor.visit_expr(context_expr); @@ -1296,8 +1296,8 @@ impl ast::WithItem { } } -impl ast::MatchCase { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::MatchCase> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1306,7 +1306,7 @@ impl ast::MatchCase { pattern, guard, body, - } = self; + } = self.as_ref(); visitor.visit_pattern(pattern); if let Some(expr) = guard { @@ -1316,29 +1316,29 @@ impl ast::MatchCase { } } -impl ast::Decorator { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::Decorator> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { let ast::Decorator { range: _, expression, - } = self; + } = self.as_ref(); visitor.visit_expr(expression); } } -impl ast::TypeParams { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::TypeParams> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { let ast::TypeParams { range: _, type_params, - } = self; + } = self.as_ref(); for type_param in type_params { visitor.visit_type_param(type_param); @@ -1346,8 +1346,8 @@ impl ast::TypeParams { } } -impl ast::TypeParamTypeVar { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::TypeParamTypeVar> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1356,7 +1356,7 @@ impl ast::TypeParamTypeVar { default, name: _, range: _, - } = self; + } = self.as_ref(); if let Some(expr) = bound { visitor.visit_expr(expr); @@ -1367,9 +1367,9 @@ impl ast::TypeParamTypeVar { } } -impl ast::TypeParamTypeVarTuple { +impl<'a> Node<'a, &'a ast::TypeParamTypeVarTuple> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1377,16 +1377,16 @@ impl ast::TypeParamTypeVarTuple { range: _, name: _, default, - } = self; + } = self.as_ref(); if let Some(expr) = default { visitor.visit_expr(expr); } } } -impl ast::TypeParamParamSpec { +impl<'a> Node<'a, &'a ast::TypeParamParamSpec> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1394,15 +1394,15 @@ impl ast::TypeParamParamSpec { range: _, name: _, default, - } = self; + } = self.as_ref(); if let Some(expr) = default { visitor.visit_expr(expr); } } } -impl ast::FString { - pub(crate) fn visit_source_order<'a, V>(&'a self, visitor: &mut V) +impl<'a> Node<'a, &'a ast::FString> { + pub(crate) fn visit_source_order(self, visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1410,7 +1410,7 @@ impl ast::FString { elements, range: _, flags: _, - } = self; + } = self.as_ref(); for fstring_element in elements { visitor.visit_f_string_element(fstring_element); @@ -1418,9 +1418,9 @@ impl ast::FString { } } -impl ast::StringLiteral { +impl<'a> Node<'a, &'a ast::StringLiteral> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1428,13 +1428,13 @@ impl ast::StringLiteral { range: _, value: _, flags: _, - } = self; + } = self.as_ref(); } } -impl ast::BytesLiteral { +impl<'a> Node<'a, &'a ast::BytesLiteral> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { @@ -1442,17 +1442,17 @@ impl ast::BytesLiteral { range: _, value: _, flags: _, - } = self; + } = self.as_ref(); } } -impl ast::Identifier { +impl<'a> Node<'a, &'a ast::Identifier> { #[inline] - pub(crate) fn visit_source_order<'a, V>(&'a self, _visitor: &mut V) + pub(crate) fn visit_source_order(self, _visitor: &mut V) where V: SourceOrderVisitor<'a> + ?Sized, { - let ast::Identifier { range: _, id: _ } = self; + let ast::Identifier { range: _, id: _ } = self.as_ref(); } } diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index ac779c56a6..eda7ab25b8 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -13,28 +13,90 @@ use itertools::Itertools; use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; +use crate::ast::AstId; use crate::name::Name; use crate::{ int, str::Quote, str_prefix::{AnyStringPrefix, ByteStringPrefix, FStringPrefix, StringLiteralPrefix}, - ExceptHandler, Expr, FStringElement, LiteralExpressionRef, Pattern, Stmt, TypeParam, + Ast, DecoratorId, ExceptHandler, Expr, ExprId, FStringElement, IdentifierId, + LiteralExpressionRef, Node, ParametersId, Pattern, Stmt, StmtId, TypeParam, TypeParamsId, }; +macro_rules! accessor { + ($ty:ty, $field:ident, $ref_ty:ty) => { + impl $ty { + pub fn $field<'a>(&'a self, ast: &'a Ast) -> Node<'a, <$ref_ty as AstId>::Output<'a>> { + ast.wrap(ast.node(self.$field)) + } + } + + impl<'a> Node<'a, &'a $ty> { + pub fn $field(self) -> Node<'a, <$ref_ty as AstId>::Output<'a>> { + self.node.$field(self.ast) + } + } + }; +} + +macro_rules! option_accessor { + ($ty:ty, $field:ident, $ref_ty:ty) => { + impl $ty { + pub fn $field<'a>( + &'a self, + ast: &'a Ast, + ) -> Option::Output<'a>>> { + self.$field.map(|id| ast.wrap(ast.node(*id))) + } + } + + impl<'a> Node<'a, &'a $ty> { + pub fn $field(self) -> Option::Output<'a>>> { + self.node.$field(self.ast) + } + } + }; +} + +macro_rules! vec_accessor { + ($ty:ty, $field:ident, $ref_ty:ty) => { + impl $ty { + pub fn $field<'a>( + &'a self, + ast: &'a Ast, + ) -> impl Iterator::Output<'a>>> + 'a { + self.$field.iter().map(|id| ast.wrap(ast.node(*id))) + } + } + + impl<'a> Node<'a, &'a $ty> { + pub fn $field( + self, + ) -> impl Iterator::Output<'a>>> + 'a { + self.node.$field(self.ast) + } + } + }; +} + /// See also [Module](https://docs.python.org/3/library/ast.html#ast.Module) #[derive(Clone, Debug, PartialEq)] pub struct ModModule { pub range: TextRange, - pub body: Vec, + pub body: Vec, } +vec_accessor!(ModModule, body, StmtId); + /// See also [Expression](https://docs.python.org/3/library/ast.html#ast.Expression) #[derive(Clone, Debug, PartialEq)] pub struct ModExpression { pub range: TextRange, - pub body: Box, + pub body: ExprId, } +accessor!(ModExpression, body, ExprId); + /// An AST node used to represent a IPython escape command at the statement level. /// /// For example, @@ -104,20 +166,27 @@ pub struct StmtIpyEscapeCommand { pub struct StmtFunctionDef { pub range: TextRange, pub is_async: bool, - pub decorator_list: Vec, - pub name: Identifier, - pub type_params: Option>, - pub parameters: Box, - pub returns: Option>, - pub body: Vec, + pub decorator_list: Vec, + pub name: IdentifierId, + pub type_params: Option, + pub parameters: ParametersId, + pub returns: Option, + pub body: Vec, } +vec_accessor!(StmtFunctionDef, decorator_list, DecoratorId); +accessor!(StmtFunctionDef, name, IdentifierId); +option_accessor!(StmtFunctionDef, type_params, TypeParamsId); +accessor!(StmtFunctionDef, parameters, ParametersId); +option_accessor!(StmtFunctionDef, returns, ExprId); +vec_accessor!(StmtFunctionDef, body, StmtId); + /// See also [ClassDef](https://docs.python.org/3/library/ast.html#ast.ClassDef) #[derive(Clone, Debug, PartialEq)] pub struct StmtClassDef { pub range: TextRange, pub decorator_list: Vec, - pub name: Identifier, + pub name: IdentifierId, pub type_params: Option>, pub arguments: Option>, pub body: Vec, diff --git a/crates/ruff_python_ast/src/visitor/source_order.rs b/crates/ruff_python_ast/src/visitor/source_order.rs index 9092cbc2af..1e45e549ca 100644 --- a/crates/ruff_python_ast/src/visitor/source_order.rs +++ b/crates/ruff_python_ast/src/visitor/source_order.rs @@ -1,9 +1,9 @@ use crate::AnyNodeRef; use crate::{ Alias, Arguments, BoolOp, BytesLiteral, CmpOp, Comprehension, Decorator, ElifElseClause, - ExceptHandler, Expr, FString, FStringElement, Keyword, MatchCase, Mod, Operator, Parameter, - ParameterWithDefault, Parameters, Pattern, PatternArguments, PatternKeyword, Singleton, Stmt, - StringLiteral, TypeParam, TypeParams, UnaryOp, WithItem, + ExceptHandler, Expr, FString, FStringElement, Keyword, MatchCase, Mod, ModId, Node, Operator, + Parameter, ParameterWithDefault, Parameters, Pattern, PatternArguments, PatternKeyword, + Singleton, Stmt, StringLiteral, TypeParam, TypeParams, UnaryOp, WithItem, }; /// Visitor that traverses all nodes recursively in the order they appear in the source. @@ -20,8 +20,8 @@ pub trait SourceOrderVisitor<'a> { fn leave_node(&mut self, _node: AnyNodeRef<'a>) {} #[inline] - fn visit_mod(&mut self, module: &'a Mod) { - walk_module(self, module); + fn visit_mod(&mut self, module: Node<'a, ModId>) { + walk_module(self, module.node()); } #[inline] @@ -172,7 +172,7 @@ pub trait SourceOrderVisitor<'a> { } } -pub fn walk_module<'a, V>(visitor: &mut V, module: &'a Mod) +pub fn walk_module<'a, V>(visitor: &mut V, module: Node<'a, &'a Mod>) where V: SourceOrderVisitor<'a> + ?Sized, { diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index 3571804bad..4f100512b0 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -73,7 +73,8 @@ pub use crate::token::{Token, TokenKind}; use crate::parser::Parser; use ruff_python_ast::{ - Expr, Mod, ModExpression, ModModule, PySourceType, StringFlags, StringLiteral, Suite, + Ast, Expr, Mod, ModExpression, ModId, ModModule, ModModuleId, PySourceType, StringFlags, + StringLiteral, Suite, }; use ruff_python_trivia::CommentRanges; use ruff_text_size::{Ranged, TextRange, TextSize}; @@ -109,7 +110,7 @@ pub mod typing; /// let module = parse_module(source); /// assert!(module.is_ok()); /// ``` -pub fn parse_module(source: &str) -> Result, ParseError> { +pub fn parse_module(source: &str) -> Result, ParseError> { Parser::new(source, Mode::Module) .parse() .try_into_module() @@ -132,7 +133,7 @@ pub fn parse_module(source: &str) -> Result, ParseError> { /// let expr = parse_expression("1 + 2"); /// assert!(expr.is_ok()); /// ``` -pub fn parse_expression(source: &str) -> Result, ParseError> { +pub fn parse_expression(source: &str) -> Result, ParseError> { Parser::new(source, Mode::Expression) .parse() .try_into_expression() @@ -159,7 +160,7 @@ pub fn parse_expression(source: &str) -> Result, ParseErro pub fn parse_expression_range( source: &str, range: TextRange, -) -> Result, ParseError> { +) -> Result, ParseError> { let source = &source[..range.end().to_usize()]; Parser::new_starts_at(source, Mode::Expression, range.start()) .parse() @@ -273,7 +274,7 @@ pub fn parse_string_annotation( /// let parsed = parse(source, Mode::Ipython); /// assert!(parsed.is_ok()); /// ``` -pub fn parse(source: &str, mode: Mode) -> Result, ParseError> { +pub fn parse(source: &str, mode: Mode) -> Result, ParseError> { parse_unchecked(source, mode).into_result() } @@ -281,12 +282,12 @@ pub fn parse(source: &str, mode: Mode) -> Result, ParseError> { /// /// This is same as the [`parse`] function except that it doesn't check for any [`ParseError`] /// and returns the [`Parsed`] as is. -pub fn parse_unchecked(source: &str, mode: Mode) -> Parsed { +pub fn parse_unchecked(source: &str, mode: Mode) -> Parsed { Parser::new(source, mode).parse() } /// Parse the given Python source code using the specified [`PySourceType`]. -pub fn parse_unchecked_source(source: &str, source_type: PySourceType) -> Parsed { +pub fn parse_unchecked_source(source: &str, source_type: PySourceType) -> Parsed { // SAFETY: Safe because `PySourceType` always parses to a `ModModule` Parser::new(source, source_type.as_mode()) .parse() @@ -297,12 +298,18 @@ pub fn parse_unchecked_source(source: &str, source_type: PySourceType) -> Parsed /// Represents the parsed source code. #[derive(Debug, PartialEq, Clone)] pub struct Parsed { + ast: Ast, syntax: T, tokens: Tokens, errors: Vec, } impl Parsed { + /// Returns the AST for the parsed output. + pub fn ast(&self) -> &Ast { + &self.ast + } + /// Returns the syntax node represented by this parsed output. pub fn syntax(&self) -> &T { &self.syntax @@ -354,7 +361,7 @@ impl Parsed { } } -impl Parsed { +impl Parsed { /// Attempts to convert the [`Parsed`] into a [`Parsed`]. /// /// This method checks if the `syntax` field of the output is a [`Mod::Module`]. If it is, the @@ -362,14 +369,15 @@ impl Parsed { /// returns [`None`]. /// /// [`Some(Parsed)`]: Some - pub fn try_into_module(self) -> Option> { + pub fn try_into_module(self) -> Option> { match self.syntax { - Mod::Module(module) => Some(Parsed { + ModId::Module(module) => Some(Parsed { + ast: self.ast, syntax: module, tokens: self.tokens, errors: self.errors, }), - Mod::Expression(_) => None, + ModId::Expression(_) => None, } } @@ -380,10 +388,11 @@ impl Parsed { /// Otherwise, it returns [`None`]. /// /// [`Some(Parsed)`]: Some - pub fn try_into_expression(self) -> Option> { + pub fn try_into_expression(self) -> Option> { match self.syntax { - Mod::Module(_) => None, - Mod::Expression(expression) => Some(Parsed { + ModId::Module(_) => None, + ModId::Expression(expression) => Some(Parsed { + ast: self.ast, syntax: expression, tokens: self.tokens, errors: self.errors, @@ -392,32 +401,22 @@ impl Parsed { } } -impl Parsed { +impl Parsed { /// Returns the module body contained in this parsed output as a [`Suite`]. pub fn suite(&self) -> &Suite { - &self.syntax.body - } - - /// Consumes the [`Parsed`] output and returns the module body as a [`Suite`]. - pub fn into_suite(self) -> Suite { - self.syntax.body + &self.ast[self.syntax].body } } -impl Parsed { +impl Parsed { /// Returns the expression contained in this parsed output. pub fn expr(&self) -> &Expr { - &self.syntax.body + &self.ast[self.syntax].body } /// Returns a mutable reference to the expression contained in this parsed output. pub fn expr_mut(&mut self) -> &mut Expr { - &mut self.syntax.body - } - - /// Consumes the [`Parsed`] output and returns the contained [`Expr`]. - pub fn into_expr(self) -> Expr { - *self.syntax.body + &mut self.ast[self.syntax].body } } diff --git a/crates/ruff_python_parser/src/parser/mod.rs b/crates/ruff_python_parser/src/parser/mod.rs index d4528c8c3c..4845172c5c 100644 --- a/crates/ruff_python_parser/src/parser/mod.rs +++ b/crates/ruff_python_parser/src/parser/mod.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; use bitflags::bitflags; -use ruff_python_ast::{Mod, ModExpression, ModModule}; +use ruff_python_ast::{Ast, ModExpression, ModId, ModModule}; use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::parser::expression::ExpressionContext; @@ -47,6 +47,9 @@ pub(crate) struct Parser<'src> { /// The start offset in the source code from which to start parsing at. start_offset: TextSize, + + /// The AST that we are constructing. + ast: Ast, } impl<'src> Parser<'src> { @@ -68,16 +71,21 @@ impl<'src> Parser<'src> { prev_token_end: TextSize::new(0), start_offset, current_token_id: TokenId::default(), + ast: Ast::default(), } } /// Consumes the [`Parser`] and returns the parsed [`Parsed`]. - pub(crate) fn parse(mut self) -> Parsed { + pub(crate) fn parse(mut self) -> Parsed { let syntax = match self.mode { Mode::Expression | Mode::ParenthesizedExpression => { - Mod::Expression(self.parse_single_expression()) + let expr = self.parse_single_expression(); + self.ast.add_mod_expression(expr) + } + Mode::Module | Mode::Ipython => { + let module = self.parse_module(); + self.ast.add_mod_module(module) } - Mode::Module | Mode::Ipython => Mod::Module(self.parse_module()), }; self.finish(syntax) @@ -140,7 +148,7 @@ impl<'src> Parser<'src> { } } - fn finish(self, syntax: Mod) -> Parsed { + fn finish(self, syntax: ModId) -> Parsed { assert_eq!( self.current_token_kind(), TokenKind::EndOfFile, @@ -156,6 +164,7 @@ impl<'src> Parser<'src> { // always results in a parse error. if lex_errors.is_empty() { return Parsed { + ast: self.ast, syntax, tokens: Tokens::new(tokens), errors: parse_errors, @@ -187,6 +196,7 @@ impl<'src> Parser<'src> { merged.extend(lex_errors.map(ParseError::from)); Parsed { + ast: self.ast, syntax, tokens: Tokens::new(tokens), errors: merged, diff --git a/crates/ruff_python_parser/src/typing.rs b/crates/ruff_python_parser/src/typing.rs index ffc7dce741..57bde25a91 100644 --- a/crates/ruff_python_parser/src/typing.rs +++ b/crates/ruff_python_parser/src/typing.rs @@ -2,7 +2,7 @@ use ruff_python_ast::relocate::relocate_expr; use ruff_python_ast::str::raw_contents; -use ruff_python_ast::{Expr, ExprStringLiteral, ModExpression, StringLiteral}; +use ruff_python_ast::{Expr, ExprStringLiteral, ModExpressionId, StringLiteral}; use ruff_text_size::Ranged; use crate::{parse_expression, parse_string_annotation, ParseError, Parsed}; @@ -11,12 +11,12 @@ type AnnotationParseResult = Result; #[derive(Debug)] pub struct ParsedAnnotation { - parsed: Parsed, + parsed: Parsed, kind: AnnotationKind, } impl ParsedAnnotation { - pub fn parsed(&self) -> &Parsed { + pub fn parsed(&self) -> &Parsed { &self.parsed }