Regenerate code with latest ASDL

This commit is contained in:
Zanie 2023-07-10 13:45:36 -05:00
parent 25b23998ad
commit df2b5dfed0
10 changed files with 9288 additions and 19364 deletions

View file

@ -1,8 +1,7 @@
// File automatically generated by ast/asdl_rs.py.
use crate::text_size::TextRange;
#[derive(Clone, Debug, PartialEq)]
#[derive(is_macro::Is)]
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
pub enum Ast<R = TextRange> {
#[is(name = "module")]
Mod(Mod<R>),
@ -23,6 +22,7 @@ pub enum Ast<R = TextRange> {
MatchCase(MatchCase<R>),
Pattern(Pattern<R>),
TypeIgnore(TypeIgnore<R>),
TypeParam(TypeParam<R>),
}
impl<R> Node for Ast<R> {
const NAME: &'static str = "AST";
@ -137,6 +137,12 @@ impl<R> From<TypeIgnore<R>> for Ast<R> {
}
}
impl<R> From<TypeParam<R>> for Ast<R> {
fn from(node: TypeParam<R>) -> Self {
Ast::TypeParam(node)
}
}
/// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod)
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
pub enum Mod<R = TextRange> {
@ -256,6 +262,8 @@ pub enum Stmt<R = TextRange> {
Delete(StmtDelete<R>),
#[is(name = "assign_stmt")]
Assign(StmtAssign<R>),
#[is(name = "type_alias_stmt")]
TypeAlias(StmtTypeAlias<R>),
#[is(name = "aug_assign_stmt")]
AugAssign(StmtAugAssign<R>),
#[is(name = "ann_assign_stmt")]
@ -310,6 +318,7 @@ pub struct StmtFunctionDef<R = TextRange> {
pub decorator_list: Vec<Expr<R>>,
pub returns: Option<Box<Expr<R>>>,
pub type_comment: Option<String>,
pub type_params: Vec<TypeParam<R>>,
}
impl<R> Node for StmtFunctionDef<R> {
@ -321,6 +330,7 @@ impl<R> Node for StmtFunctionDef<R> {
"decorator_list",
"returns",
"type_comment",
"type_params",
];
}
impl<R> From<StmtFunctionDef<R>> for Stmt<R> {
@ -344,6 +354,7 @@ pub struct StmtAsyncFunctionDef<R = TextRange> {
pub decorator_list: Vec<Expr<R>>,
pub returns: Option<Box<Expr<R>>>,
pub type_comment: Option<String>,
pub type_params: Vec<TypeParam<R>>,
}
impl<R> Node for StmtAsyncFunctionDef<R> {
@ -355,6 +366,7 @@ impl<R> Node for StmtAsyncFunctionDef<R> {
"decorator_list",
"returns",
"type_comment",
"type_params",
];
}
impl<R> From<StmtAsyncFunctionDef<R>> for Stmt<R> {
@ -377,12 +389,19 @@ pub struct StmtClassDef<R = TextRange> {
pub keywords: Vec<Keyword<R>>,
pub body: Vec<Stmt<R>>,
pub decorator_list: Vec<Expr<R>>,
pub type_params: Vec<TypeParam<R>>,
}
impl<R> Node for StmtClassDef<R> {
const NAME: &'static str = "ClassDef";
const FIELD_NAMES: &'static [&'static str] =
&["name", "bases", "keywords", "body", "decorator_list"];
const FIELD_NAMES: &'static [&'static str] = &[
"name",
"bases",
"keywords",
"body",
"decorator_list",
"type_params",
];
}
impl<R> From<StmtClassDef<R>> for Stmt<R> {
fn from(payload: StmtClassDef<R>) -> Self {
@ -463,6 +482,30 @@ impl<R> From<StmtAssign<R>> for Ast<R> {
}
}
/// See also [TypeAlias](https://docs.python.org/3/library/ast.html#ast.TypeAlias)
#[derive(Clone, Debug, PartialEq)]
pub struct StmtTypeAlias<R = TextRange> {
pub range: R,
pub name: Box<Expr<R>>,
pub type_params: Vec<TypeParam<R>>,
pub value: Box<Expr<R>>,
}
impl<R> Node for StmtTypeAlias<R> {
const NAME: &'static str = "TypeAlias";
const FIELD_NAMES: &'static [&'static str] = &["name", "type_params", "value"];
}
impl<R> From<StmtTypeAlias<R>> for Stmt<R> {
fn from(payload: StmtTypeAlias<R>) -> Self {
Stmt::TypeAlias(payload)
}
}
impl<R> From<StmtTypeAlias<R>> for Ast<R> {
fn from(payload: StmtTypeAlias<R>) -> Self {
Stmt::from(payload).into()
}
}
/// See also [AugAssign](https://docs.python.org/3/library/ast.html#ast.AugAssign)
#[derive(Clone, Debug, PartialEq)]
pub struct StmtAugAssign<R = TextRange> {
@ -3074,6 +3117,86 @@ impl<R> Node for TypeIgnore<R> {
const FIELD_NAMES: &'static [&'static str] = &[];
}
/// See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param)
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
pub enum TypeParam<R = TextRange> {
TypeVar(TypeParamTypeVar<R>),
ParamSpec(TypeParamParamSpec<R>),
TypeVarTuple(TypeParamTypeVarTuple<R>),
}
/// See also [TypeVar](https://docs.python.org/3/library/ast.html#ast.TypeVar)
#[derive(Clone, Debug, PartialEq)]
pub struct TypeParamTypeVar<R = TextRange> {
pub range: R,
pub name: Identifier,
pub bound: Option<Box<Expr<R>>>,
}
impl<R> Node for TypeParamTypeVar<R> {
const NAME: &'static str = "TypeVar";
const FIELD_NAMES: &'static [&'static str] = &["name", "bound"];
}
impl<R> From<TypeParamTypeVar<R>> for TypeParam<R> {
fn from(payload: TypeParamTypeVar<R>) -> Self {
TypeParam::TypeVar(payload)
}
}
impl<R> From<TypeParamTypeVar<R>> for Ast<R> {
fn from(payload: TypeParamTypeVar<R>) -> Self {
TypeParam::from(payload).into()
}
}
/// See also [ParamSpec](https://docs.python.org/3/library/ast.html#ast.ParamSpec)
#[derive(Clone, Debug, PartialEq)]
pub struct TypeParamParamSpec<R = TextRange> {
pub range: R,
pub name: Identifier,
}
impl<R> Node for TypeParamParamSpec<R> {
const NAME: &'static str = "ParamSpec";
const FIELD_NAMES: &'static [&'static str] = &["name"];
}
impl<R> From<TypeParamParamSpec<R>> for TypeParam<R> {
fn from(payload: TypeParamParamSpec<R>) -> Self {
TypeParam::ParamSpec(payload)
}
}
impl<R> From<TypeParamParamSpec<R>> for Ast<R> {
fn from(payload: TypeParamParamSpec<R>) -> Self {
TypeParam::from(payload).into()
}
}
/// See also [TypeVarTuple](https://docs.python.org/3/library/ast.html#ast.TypeVarTuple)
#[derive(Clone, Debug, PartialEq)]
pub struct TypeParamTypeVarTuple<R = TextRange> {
pub range: R,
pub name: Identifier,
}
impl<R> Node for TypeParamTypeVarTuple<R> {
const NAME: &'static str = "TypeVarTuple";
const FIELD_NAMES: &'static [&'static str] = &["name"];
}
impl<R> From<TypeParamTypeVarTuple<R>> for TypeParam<R> {
fn from(payload: TypeParamTypeVarTuple<R>) -> Self {
TypeParam::TypeVarTuple(payload)
}
}
impl<R> From<TypeParamTypeVarTuple<R>> for Ast<R> {
fn from(payload: TypeParamTypeVarTuple<R>) -> Self {
TypeParam::from(payload).into()
}
}
impl<R> Node for TypeParam<R> {
const NAME: &'static str = "type_param";
const FIELD_NAMES: &'static [&'static str] = &[];
}
/// An alternative type of AST `arguments`. This is parser-friendly and human-friendly definition of function arguments.
/// This form also has advantage to implement pre-order traverse.
/// `defaults` and `kw_defaults` fields are removed and the default values are placed under each `arg_with_default` typed argument.