diff --git a/ast/asdl_rs.py b/ast/asdl_rs.py index 588eba7..7f0edd2 100755 --- a/ast/asdl_rs.py +++ b/ast/asdl_rs.py @@ -322,6 +322,16 @@ class StructVisitor(EmitVisitor): const FIELD_NAMES: &'static [&'static str] = &[]; } """, 0) + for dfn in mod.dfns: + rust_name = rust_type_name(dfn.name) + generics = "" if self.type_info[dfn.name].is_simple else "" + self.emit(f""" + impl From<{rust_name}{generics}> for Ast {{ + fn from(node: {rust_name}{generics}) -> Self {{ + Ast::{rust_name}(node) + }} + }} + """, 0) for dfn in mod.dfns: self.visit(dfn) @@ -385,6 +395,11 @@ class StructVisitor(EmitVisitor): {rust_name}::{cons.name} }} }} + impl From<{rust_name}{cons.name}> for Ast {{ + fn from(_: {rust_name}{cons.name}) -> Self {{ + {rust_name}::{cons.name}.into() + }} + }} impl Node for {rust_name}{cons.name} {{ const NAME: &'static str = "{cons.name}"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -447,6 +462,11 @@ class StructVisitor(EmitVisitor): {rust_name}::{t.name}(payload) }} }} + impl From<{payload_name}> for Ast {{ + fn from(payload: {payload_name}) -> Self {{ + {rust_name}::from(payload).into() + }} + }} """, depth, ) diff --git a/ast/src/gen/generic.rs b/ast/src/gen/generic.rs index 67d9979..77cc7e8 100644 --- a/ast/src/gen/generic.rs +++ b/ast/src/gen/generic.rs @@ -29,6 +29,114 @@ impl Node for Ast { const FIELD_NAMES: &'static [&'static str] = &[]; } +impl From> for Ast { + fn from(node: Mod) -> Self { + Ast::Mod(node) + } +} + +impl From> for Ast { + fn from(node: Stmt) -> Self { + Ast::Stmt(node) + } +} + +impl From> for Ast { + fn from(node: Expr) -> Self { + Ast::Expr(node) + } +} + +impl From for Ast { + fn from(node: ExprContext) -> Self { + Ast::ExprContext(node) + } +} + +impl From for Ast { + fn from(node: Boolop) -> Self { + Ast::Boolop(node) + } +} + +impl From for Ast { + fn from(node: Operator) -> Self { + Ast::Operator(node) + } +} + +impl From for Ast { + fn from(node: Unaryop) -> Self { + Ast::Unaryop(node) + } +} + +impl From for Ast { + fn from(node: Cmpop) -> Self { + Ast::Cmpop(node) + } +} + +impl From> for Ast { + fn from(node: Comprehension) -> Self { + Ast::Comprehension(node) + } +} + +impl From> for Ast { + fn from(node: Excepthandler) -> Self { + Ast::Excepthandler(node) + } +} + +impl From> for Ast { + fn from(node: Arguments) -> Self { + Ast::Arguments(node) + } +} + +impl From> for Ast { + fn from(node: Arg) -> Self { + Ast::Arg(node) + } +} + +impl From> for Ast { + fn from(node: Keyword) -> Self { + Ast::Keyword(node) + } +} + +impl From> for Ast { + fn from(node: Alias) -> Self { + Ast::Alias(node) + } +} + +impl From> for Ast { + fn from(node: Withitem) -> Self { + Ast::Withitem(node) + } +} + +impl From> for Ast { + fn from(node: MatchCase) -> Self { + Ast::MatchCase(node) + } +} + +impl From> for Ast { + fn from(node: Pattern) -> Self { + Ast::Pattern(node) + } +} + +impl From> for Ast { + fn from(node: TypeIgnore) -> Self { + Ast::TypeIgnore(node) + } +} + #[derive(Clone, Debug, PartialEq)] pub struct ModModule { pub range: OptionalRange, @@ -45,6 +153,11 @@ impl From> for Mod { Mod::Module(payload) } } +impl From> for Ast { + fn from(payload: ModModule) -> Self { + Mod::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ModInteractive { @@ -61,6 +174,11 @@ impl From> for Mod { Mod::Interactive(payload) } } +impl From> for Ast { + fn from(payload: ModInteractive) -> Self { + Mod::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ModExpression { @@ -77,6 +195,11 @@ impl From> for Mod { Mod::Expression(payload) } } +impl From> for Ast { + fn from(payload: ModExpression) -> Self { + Mod::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ModFunctionType { @@ -94,6 +217,11 @@ impl From> for Mod { Mod::FunctionType(payload) } } +impl From> for Ast { + fn from(payload: ModFunctionType) -> Self { + Mod::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Mod { @@ -135,6 +263,11 @@ impl From> for Stmt { Stmt::FunctionDef(payload) } } +impl From> for Ast { + fn from(payload: StmtFunctionDef) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtAsyncFunctionDef { @@ -163,6 +296,11 @@ impl From> for Stmt { Stmt::AsyncFunctionDef(payload) } } +impl From> for Ast { + fn from(payload: StmtAsyncFunctionDef) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtClassDef { @@ -184,6 +322,11 @@ impl From> for Stmt { Stmt::ClassDef(payload) } } +impl From> for Ast { + fn from(payload: StmtClassDef) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtReturn { @@ -200,6 +343,11 @@ impl From> for Stmt { Stmt::Return(payload) } } +impl From> for Ast { + fn from(payload: StmtReturn) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtDelete { @@ -216,6 +364,11 @@ impl From> for Stmt { Stmt::Delete(payload) } } +impl From> for Ast { + fn from(payload: StmtDelete) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtAssign { @@ -234,6 +387,11 @@ impl From> for Stmt { Stmt::Assign(payload) } } +impl From> for Ast { + fn from(payload: StmtAssign) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtAugAssign { @@ -252,6 +410,11 @@ impl From> for Stmt { Stmt::AugAssign(payload) } } +impl From> for Ast { + fn from(payload: StmtAugAssign) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtAnnAssign { @@ -271,6 +434,11 @@ impl From> for Stmt { Stmt::AnnAssign(payload) } } +impl From> for Ast { + fn from(payload: StmtAnnAssign) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtFor { @@ -292,6 +460,11 @@ impl From> for Stmt { Stmt::For(payload) } } +impl From> for Ast { + fn from(payload: StmtFor) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtAsyncFor { @@ -313,6 +486,11 @@ impl From> for Stmt { Stmt::AsyncFor(payload) } } +impl From> for Ast { + fn from(payload: StmtAsyncFor) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtWhile { @@ -331,6 +509,11 @@ impl From> for Stmt { Stmt::While(payload) } } +impl From> for Ast { + fn from(payload: StmtWhile) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtIf { @@ -349,6 +532,11 @@ impl From> for Stmt { Stmt::If(payload) } } +impl From> for Ast { + fn from(payload: StmtIf) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtWith { @@ -367,6 +555,11 @@ impl From> for Stmt { Stmt::With(payload) } } +impl From> for Ast { + fn from(payload: StmtWith) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtAsyncWith { @@ -385,6 +578,11 @@ impl From> for Stmt { Stmt::AsyncWith(payload) } } +impl From> for Ast { + fn from(payload: StmtAsyncWith) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtMatch { @@ -402,6 +600,11 @@ impl From> for Stmt { Stmt::Match(payload) } } +impl From> for Ast { + fn from(payload: StmtMatch) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtRaise { @@ -419,6 +622,11 @@ impl From> for Stmt { Stmt::Raise(payload) } } +impl From> for Ast { + fn from(payload: StmtRaise) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtTry { @@ -438,6 +646,11 @@ impl From> for Stmt { Stmt::Try(payload) } } +impl From> for Ast { + fn from(payload: StmtTry) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtTryStar { @@ -457,6 +670,11 @@ impl From> for Stmt { Stmt::TryStar(payload) } } +impl From> for Ast { + fn from(payload: StmtTryStar) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtAssert { @@ -474,6 +692,11 @@ impl From> for Stmt { Stmt::Assert(payload) } } +impl From> for Ast { + fn from(payload: StmtAssert) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtImport { @@ -490,6 +713,11 @@ impl From> for Stmt { Stmt::Import(payload) } } +impl From> for Ast { + fn from(payload: StmtImport) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtImportFrom { @@ -508,6 +736,11 @@ impl From> for Stmt { Stmt::ImportFrom(payload) } } +impl From> for Ast { + fn from(payload: StmtImportFrom) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtGlobal { @@ -524,6 +757,11 @@ impl From> for Stmt { Stmt::Global(payload) } } +impl From> for Ast { + fn from(payload: StmtGlobal) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtNonlocal { @@ -540,6 +778,11 @@ impl From> for Stmt { Stmt::Nonlocal(payload) } } +impl From> for Ast { + fn from(payload: StmtNonlocal) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtExpr { @@ -556,6 +799,11 @@ impl From> for Stmt { Stmt::Expr(payload) } } +impl From> for Ast { + fn from(payload: StmtExpr) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtPass { @@ -571,6 +819,11 @@ impl From> for Stmt { Stmt::Pass(payload) } } +impl From> for Ast { + fn from(payload: StmtPass) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtBreak { @@ -586,6 +839,11 @@ impl From> for Stmt { Stmt::Break(payload) } } +impl From> for Ast { + fn from(payload: StmtBreak) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct StmtContinue { @@ -601,6 +859,11 @@ impl From> for Stmt { Stmt::Continue(payload) } } +impl From> for Ast { + fn from(payload: StmtContinue) -> Self { + Stmt::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Stmt { @@ -681,6 +944,11 @@ impl From> for Expr { Expr::BoolOp(payload) } } +impl From> for Ast { + fn from(payload: ExprBoolOp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprNamedExpr { @@ -698,6 +966,11 @@ impl From> for Expr { Expr::NamedExpr(payload) } } +impl From> for Ast { + fn from(payload: ExprNamedExpr) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprBinOp { @@ -716,6 +989,11 @@ impl From> for Expr { Expr::BinOp(payload) } } +impl From> for Ast { + fn from(payload: ExprBinOp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprUnaryOp { @@ -733,6 +1011,11 @@ impl From> for Expr { Expr::UnaryOp(payload) } } +impl From> for Ast { + fn from(payload: ExprUnaryOp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprLambda { @@ -750,6 +1033,11 @@ impl From> for Expr { Expr::Lambda(payload) } } +impl From> for Ast { + fn from(payload: ExprLambda) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprIfExp { @@ -768,6 +1056,11 @@ impl From> for Expr { Expr::IfExp(payload) } } +impl From> for Ast { + fn from(payload: ExprIfExp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprDict { @@ -785,6 +1078,11 @@ impl From> for Expr { Expr::Dict(payload) } } +impl From> for Ast { + fn from(payload: ExprDict) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprSet { @@ -801,6 +1099,11 @@ impl From> for Expr { Expr::Set(payload) } } +impl From> for Ast { + fn from(payload: ExprSet) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprListComp { @@ -818,6 +1121,11 @@ impl From> for Expr { Expr::ListComp(payload) } } +impl From> for Ast { + fn from(payload: ExprListComp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprSetComp { @@ -835,6 +1143,11 @@ impl From> for Expr { Expr::SetComp(payload) } } +impl From> for Ast { + fn from(payload: ExprSetComp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprDictComp { @@ -853,6 +1166,11 @@ impl From> for Expr { Expr::DictComp(payload) } } +impl From> for Ast { + fn from(payload: ExprDictComp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprGeneratorExp { @@ -870,6 +1188,11 @@ impl From> for Expr { Expr::GeneratorExp(payload) } } +impl From> for Ast { + fn from(payload: ExprGeneratorExp) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprAwait { @@ -886,6 +1209,11 @@ impl From> for Expr { Expr::Await(payload) } } +impl From> for Ast { + fn from(payload: ExprAwait) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprYield { @@ -902,6 +1230,11 @@ impl From> for Expr { Expr::Yield(payload) } } +impl From> for Ast { + fn from(payload: ExprYield) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprYieldFrom { @@ -918,6 +1251,11 @@ impl From> for Expr { Expr::YieldFrom(payload) } } +impl From> for Ast { + fn from(payload: ExprYieldFrom) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprCompare { @@ -936,6 +1274,11 @@ impl From> for Expr { Expr::Compare(payload) } } +impl From> for Ast { + fn from(payload: ExprCompare) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprCall { @@ -954,6 +1297,11 @@ impl From> for Expr { Expr::Call(payload) } } +impl From> for Ast { + fn from(payload: ExprCall) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprFormattedValue { @@ -972,6 +1320,11 @@ impl From> for Expr { Expr::FormattedValue(payload) } } +impl From> for Ast { + fn from(payload: ExprFormattedValue) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprJoinedStr { @@ -988,6 +1341,11 @@ impl From> for Expr { Expr::JoinedStr(payload) } } +impl From> for Ast { + fn from(payload: ExprJoinedStr) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprConstant { @@ -1005,6 +1363,11 @@ impl From> for Expr { Expr::Constant(payload) } } +impl From> for Ast { + fn from(payload: ExprConstant) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprAttribute { @@ -1023,6 +1386,11 @@ impl From> for Expr { Expr::Attribute(payload) } } +impl From> for Ast { + fn from(payload: ExprAttribute) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprSubscript { @@ -1041,6 +1409,11 @@ impl From> for Expr { Expr::Subscript(payload) } } +impl From> for Ast { + fn from(payload: ExprSubscript) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprStarred { @@ -1058,6 +1431,11 @@ impl From> for Expr { Expr::Starred(payload) } } +impl From> for Ast { + fn from(payload: ExprStarred) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprName { @@ -1075,6 +1453,11 @@ impl From> for Expr { Expr::Name(payload) } } +impl From> for Ast { + fn from(payload: ExprName) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprList { @@ -1092,6 +1475,11 @@ impl From> for Expr { Expr::List(payload) } } +impl From> for Ast { + fn from(payload: ExprList) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprTuple { @@ -1109,6 +1497,11 @@ impl From> for Expr { Expr::Tuple(payload) } } +impl From> for Ast { + fn from(payload: ExprTuple) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct ExprSlice { @@ -1127,6 +1520,11 @@ impl From> for Expr { Expr::Slice(payload) } } +impl From> for Ast { + fn from(payload: ExprSlice) -> Self { + Expr::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Expr { @@ -1229,6 +1627,11 @@ impl From for ExprContext { ExprContext::Load } } +impl From for Ast { + fn from(_: ExprContextLoad) -> Self { + ExprContext::Load.into() + } +} impl Node for ExprContextLoad { const NAME: &'static str = "Load"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1246,6 +1649,11 @@ impl From for ExprContext { ExprContext::Store } } +impl From for Ast { + fn from(_: ExprContextStore) -> Self { + ExprContext::Store.into() + } +} impl Node for ExprContextStore { const NAME: &'static str = "Store"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1263,6 +1671,11 @@ impl From for ExprContext { ExprContext::Del } } +impl From for Ast { + fn from(_: ExprContextDel) -> Self { + ExprContext::Del.into() + } +} impl Node for ExprContextDel { const NAME: &'static str = "Del"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1308,6 +1721,11 @@ impl From for Boolop { Boolop::And } } +impl From for Ast { + fn from(_: BoolopAnd) -> Self { + Boolop::And.into() + } +} impl Node for BoolopAnd { const NAME: &'static str = "And"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1325,6 +1743,11 @@ impl From for Boolop { Boolop::Or } } +impl From for Ast { + fn from(_: BoolopOr) -> Self { + Boolop::Or.into() + } +} impl Node for BoolopOr { const NAME: &'static str = "Or"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1469,6 +1892,11 @@ impl From for Operator { Operator::Add } } +impl From for Ast { + fn from(_: OperatorAdd) -> Self { + Operator::Add.into() + } +} impl Node for OperatorAdd { const NAME: &'static str = "Add"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1486,6 +1914,11 @@ impl From for Operator { Operator::Sub } } +impl From for Ast { + fn from(_: OperatorSub) -> Self { + Operator::Sub.into() + } +} impl Node for OperatorSub { const NAME: &'static str = "Sub"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1503,6 +1936,11 @@ impl From for Operator { Operator::Mult } } +impl From for Ast { + fn from(_: OperatorMult) -> Self { + Operator::Mult.into() + } +} impl Node for OperatorMult { const NAME: &'static str = "Mult"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1520,6 +1958,11 @@ impl From for Operator { Operator::MatMult } } +impl From for Ast { + fn from(_: OperatorMatMult) -> Self { + Operator::MatMult.into() + } +} impl Node for OperatorMatMult { const NAME: &'static str = "MatMult"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1537,6 +1980,11 @@ impl From for Operator { Operator::Div } } +impl From for Ast { + fn from(_: OperatorDiv) -> Self { + Operator::Div.into() + } +} impl Node for OperatorDiv { const NAME: &'static str = "Div"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1554,6 +2002,11 @@ impl From for Operator { Operator::Mod } } +impl From for Ast { + fn from(_: OperatorMod) -> Self { + Operator::Mod.into() + } +} impl Node for OperatorMod { const NAME: &'static str = "Mod"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1571,6 +2024,11 @@ impl From for Operator { Operator::Pow } } +impl From for Ast { + fn from(_: OperatorPow) -> Self { + Operator::Pow.into() + } +} impl Node for OperatorPow { const NAME: &'static str = "Pow"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1588,6 +2046,11 @@ impl From for Operator { Operator::LShift } } +impl From for Ast { + fn from(_: OperatorLShift) -> Self { + Operator::LShift.into() + } +} impl Node for OperatorLShift { const NAME: &'static str = "LShift"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1605,6 +2068,11 @@ impl From for Operator { Operator::RShift } } +impl From for Ast { + fn from(_: OperatorRShift) -> Self { + Operator::RShift.into() + } +} impl Node for OperatorRShift { const NAME: &'static str = "RShift"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1622,6 +2090,11 @@ impl From for Operator { Operator::BitOr } } +impl From for Ast { + fn from(_: OperatorBitOr) -> Self { + Operator::BitOr.into() + } +} impl Node for OperatorBitOr { const NAME: &'static str = "BitOr"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1639,6 +2112,11 @@ impl From for Operator { Operator::BitXor } } +impl From for Ast { + fn from(_: OperatorBitXor) -> Self { + Operator::BitXor.into() + } +} impl Node for OperatorBitXor { const NAME: &'static str = "BitXor"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1656,6 +2134,11 @@ impl From for Operator { Operator::BitAnd } } +impl From for Ast { + fn from(_: OperatorBitAnd) -> Self { + Operator::BitAnd.into() + } +} impl Node for OperatorBitAnd { const NAME: &'static str = "BitAnd"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1673,6 +2156,11 @@ impl From for Operator { Operator::FloorDiv } } +impl From for Ast { + fn from(_: OperatorFloorDiv) -> Self { + Operator::FloorDiv.into() + } +} impl Node for OperatorFloorDiv { const NAME: &'static str = "FloorDiv"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1736,6 +2224,11 @@ impl From for Unaryop { Unaryop::Invert } } +impl From for Ast { + fn from(_: UnaryopInvert) -> Self { + Unaryop::Invert.into() + } +} impl Node for UnaryopInvert { const NAME: &'static str = "Invert"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1753,6 +2246,11 @@ impl From for Unaryop { Unaryop::Not } } +impl From for Ast { + fn from(_: UnaryopNot) -> Self { + Unaryop::Not.into() + } +} impl Node for UnaryopNot { const NAME: &'static str = "Not"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1770,6 +2268,11 @@ impl From for Unaryop { Unaryop::UAdd } } +impl From for Ast { + fn from(_: UnaryopUAdd) -> Self { + Unaryop::UAdd.into() + } +} impl Node for UnaryopUAdd { const NAME: &'static str = "UAdd"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1787,6 +2290,11 @@ impl From for Unaryop { Unaryop::USub } } +impl From for Ast { + fn from(_: UnaryopUSub) -> Self { + Unaryop::USub.into() + } +} impl Node for UnaryopUSub { const NAME: &'static str = "USub"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1904,6 +2412,11 @@ impl From for Cmpop { Cmpop::Eq } } +impl From for Ast { + fn from(_: CmpopEq) -> Self { + Cmpop::Eq.into() + } +} impl Node for CmpopEq { const NAME: &'static str = "Eq"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1921,6 +2434,11 @@ impl From for Cmpop { Cmpop::NotEq } } +impl From for Ast { + fn from(_: CmpopNotEq) -> Self { + Cmpop::NotEq.into() + } +} impl Node for CmpopNotEq { const NAME: &'static str = "NotEq"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1938,6 +2456,11 @@ impl From for Cmpop { Cmpop::Lt } } +impl From for Ast { + fn from(_: CmpopLt) -> Self { + Cmpop::Lt.into() + } +} impl Node for CmpopLt { const NAME: &'static str = "Lt"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1955,6 +2478,11 @@ impl From for Cmpop { Cmpop::LtE } } +impl From for Ast { + fn from(_: CmpopLtE) -> Self { + Cmpop::LtE.into() + } +} impl Node for CmpopLtE { const NAME: &'static str = "LtE"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1972,6 +2500,11 @@ impl From for Cmpop { Cmpop::Gt } } +impl From for Ast { + fn from(_: CmpopGt) -> Self { + Cmpop::Gt.into() + } +} impl Node for CmpopGt { const NAME: &'static str = "Gt"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -1989,6 +2522,11 @@ impl From for Cmpop { Cmpop::GtE } } +impl From for Ast { + fn from(_: CmpopGtE) -> Self { + Cmpop::GtE.into() + } +} impl Node for CmpopGtE { const NAME: &'static str = "GtE"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -2006,6 +2544,11 @@ impl From for Cmpop { Cmpop::Is } } +impl From for Ast { + fn from(_: CmpopIs) -> Self { + Cmpop::Is.into() + } +} impl Node for CmpopIs { const NAME: &'static str = "Is"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -2023,6 +2566,11 @@ impl From for Cmpop { Cmpop::IsNot } } +impl From for Ast { + fn from(_: CmpopIsNot) -> Self { + Cmpop::IsNot.into() + } +} impl Node for CmpopIsNot { const NAME: &'static str = "IsNot"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -2040,6 +2588,11 @@ impl From for Cmpop { Cmpop::In } } +impl From for Ast { + fn from(_: CmpopIn) -> Self { + Cmpop::In.into() + } +} impl Node for CmpopIn { const NAME: &'static str = "In"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -2057,6 +2610,11 @@ impl From for Cmpop { Cmpop::NotIn } } +impl From for Ast { + fn from(_: CmpopNotIn) -> Self { + Cmpop::NotIn.into() + } +} impl Node for CmpopNotIn { const NAME: &'static str = "NotIn"; const FIELD_NAMES: &'static [&'static str] = &[]; @@ -2104,6 +2662,11 @@ impl From> for Excepthandler { Excepthandler::ExceptHandler(payload) } } +impl From> for Ast { + fn from(payload: ExcepthandlerExceptHandler) -> Self { + Excepthandler::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Excepthandler { @@ -2217,6 +2780,11 @@ impl From> for Pattern { Pattern::MatchValue(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchValue) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchSingleton { @@ -2233,6 +2801,11 @@ impl From> for Pattern { Pattern::MatchSingleton(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchSingleton) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchSequence { @@ -2249,6 +2822,11 @@ impl From> for Pattern { Pattern::MatchSequence(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchSequence) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchMapping { @@ -2267,6 +2845,11 @@ impl From> for Pattern { Pattern::MatchMapping(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchMapping) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchClass { @@ -2286,6 +2869,11 @@ impl From> for Pattern { Pattern::MatchClass(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchClass) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchStar { @@ -2302,6 +2890,11 @@ impl From> for Pattern { Pattern::MatchStar(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchStar) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchAs { @@ -2319,6 +2912,11 @@ impl From> for Pattern { Pattern::MatchAs(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchAs) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq)] pub struct PatternMatchOr { @@ -2335,6 +2933,11 @@ impl From> for Pattern { Pattern::MatchOr(payload) } } +impl From> for Ast { + fn from(payload: PatternMatchOr) -> Self { + Pattern::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Pattern { @@ -2369,6 +2972,11 @@ impl From> for TypeIgnore { TypeIgnore::TypeIgnore(payload) } } +impl From> for Ast { + fn from(payload: TypeIgnoreTypeIgnore) -> Self { + TypeIgnore::from(payload).into() + } +} #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum TypeIgnore {