Upgrade RustPython (#5334)

This commit is contained in:
Micha Reiser 2023-06-23 22:39:47 +02:00 committed by GitHub
parent f45d1c2b84
commit 6ba9d5d5a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 265 additions and 271 deletions

12
Cargo.lock generated
View file

@ -2102,7 +2102,7 @@ dependencies = [
[[package]] [[package]]
name = "ruff_text_size" name = "ruff_text_size"
version = "0.0.0" version = "0.0.0"
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11" source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
dependencies = [ dependencies = [
"schemars", "schemars",
"serde", "serde",
@ -2180,7 +2180,7 @@ dependencies = [
[[package]] [[package]]
name = "rustpython-ast" name = "rustpython-ast"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11" source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
dependencies = [ dependencies = [
"is-macro", "is-macro",
"num-bigint", "num-bigint",
@ -2191,7 +2191,7 @@ dependencies = [
[[package]] [[package]]
name = "rustpython-format" name = "rustpython-format"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11" source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
dependencies = [ dependencies = [
"bitflags 2.3.1", "bitflags 2.3.1",
"itertools", "itertools",
@ -2203,7 +2203,7 @@ dependencies = [
[[package]] [[package]]
name = "rustpython-literal" name = "rustpython-literal"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11" source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
dependencies = [ dependencies = [
"hexf-parse", "hexf-parse",
"is-macro", "is-macro",
@ -2215,7 +2215,7 @@ dependencies = [
[[package]] [[package]]
name = "rustpython-parser" name = "rustpython-parser"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11" source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"is-macro", "is-macro",
@ -2238,7 +2238,7 @@ dependencies = [
[[package]] [[package]]
name = "rustpython-parser-core" name = "rustpython-parser-core"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=f60e204b73b95bdb6ce87ccd0de34081b4a17c11#f60e204b73b95bdb6ce87ccd0de34081b4a17c11" source = "git+https://github.com/astral-sh/RustPython-Parser.git?rev=8078663b6c914c1cb86993e427764f7c422fc12c#8078663b6c914c1cb86993e427764f7c422fc12c"
dependencies = [ dependencies = [
"is-macro", "is-macro",
"memchr", "memchr",

View file

@ -49,16 +49,15 @@ toml = { version = "0.7.2" }
# v0.0.1 # v0.0.1
libcst = { git = "https://github.com/charliermarsh/LibCST", rev = "80e4c1399f95e5beb532fdd1e209ad2dbb470438" } libcst = { git = "https://github.com/charliermarsh/LibCST", rev = "80e4c1399f95e5beb532fdd1e209ad2dbb470438" }
# v0.0.3
ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" } # Please tag the RustPython version everytime you update its revision here.
# v0.0.3 # Tagging the version ensures that older ruff versions continue to build from source even when we rebase our RustPython fork.
rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" , default-features = false, features = ["all-nodes-with-ranges", "num-bigint"]} # Current tag: v0.0.6
# v0.0.3 ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c" }
rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11", default-features = false, features = ["num-bigint"] } rustpython-ast = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c" , default-features = false, features = ["num-bigint"]}
# v0.0.3 rustpython-format = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c", default-features = false, features = ["num-bigint"] }
rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11", default-features = false } rustpython-literal = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c", default-features = false }
# v0.0.3 rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "8078663b6c914c1cb86993e427764f7c422fc12c" , default-features = false, features = ["full-lexer", "num-bigint"] }
rustpython-parser = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" , default-features = false, features = ["full-lexer", "all-nodes-with-ranges", "num-bigint"] }
[profile.release] [profile.release]
lto = "fat" lto = "fat"

View file

@ -68,7 +68,7 @@ pub(crate) fn compare_to_empty_string(
let mut first = true; let mut first = true;
for ((lhs, rhs), op) in std::iter::once(left) for ((lhs, rhs), op) in std::iter::once(left)
.chain(comparators.iter()) .chain(comparators.iter())
.tuple_windows::<(&Expr<_>, &Expr<_>)>() .tuple_windows::<(&Expr, &Expr)>()
.zip(ops) .zip(ops)
{ {
if let Ok(op) = EmptyStringCmpOp::try_from(op) { if let Ok(op) = EmptyStringCmpOp::try_from(op) {

View file

@ -17,83 +17,83 @@ pub trait AstNode: Ranged {
#[derive(Clone, Debug, is_macro::Is, PartialEq)] #[derive(Clone, Debug, is_macro::Is, PartialEq)]
pub enum AnyNode { pub enum AnyNode {
ModModule(ModModule<TextRange>), ModModule(ModModule),
ModInteractive(ModInteractive<TextRange>), ModInteractive(ModInteractive),
ModExpression(ModExpression<TextRange>), ModExpression(ModExpression),
ModFunctionType(ModFunctionType<TextRange>), ModFunctionType(ModFunctionType),
StmtFunctionDef(StmtFunctionDef<TextRange>), StmtFunctionDef(StmtFunctionDef),
StmtAsyncFunctionDef(StmtAsyncFunctionDef<TextRange>), StmtAsyncFunctionDef(StmtAsyncFunctionDef),
StmtClassDef(StmtClassDef<TextRange>), StmtClassDef(StmtClassDef),
StmtReturn(StmtReturn<TextRange>), StmtReturn(StmtReturn),
StmtDelete(StmtDelete<TextRange>), StmtDelete(StmtDelete),
StmtAssign(StmtAssign<TextRange>), StmtAssign(StmtAssign),
StmtAugAssign(StmtAugAssign<TextRange>), StmtAugAssign(StmtAugAssign),
StmtAnnAssign(StmtAnnAssign<TextRange>), StmtAnnAssign(StmtAnnAssign),
StmtFor(StmtFor<TextRange>), StmtFor(StmtFor),
StmtAsyncFor(StmtAsyncFor<TextRange>), StmtAsyncFor(StmtAsyncFor),
StmtWhile(StmtWhile<TextRange>), StmtWhile(StmtWhile),
StmtIf(StmtIf<TextRange>), StmtIf(StmtIf),
StmtWith(StmtWith<TextRange>), StmtWith(StmtWith),
StmtAsyncWith(StmtAsyncWith<TextRange>), StmtAsyncWith(StmtAsyncWith),
StmtMatch(StmtMatch<TextRange>), StmtMatch(StmtMatch),
StmtRaise(StmtRaise<TextRange>), StmtRaise(StmtRaise),
StmtTry(StmtTry<TextRange>), StmtTry(StmtTry),
StmtTryStar(StmtTryStar<TextRange>), StmtTryStar(StmtTryStar),
StmtAssert(StmtAssert<TextRange>), StmtAssert(StmtAssert),
StmtImport(StmtImport<TextRange>), StmtImport(StmtImport),
StmtImportFrom(StmtImportFrom<TextRange>), StmtImportFrom(StmtImportFrom),
StmtGlobal(StmtGlobal<TextRange>), StmtGlobal(StmtGlobal),
StmtNonlocal(StmtNonlocal<TextRange>), StmtNonlocal(StmtNonlocal),
StmtExpr(StmtExpr<TextRange>), StmtExpr(StmtExpr),
StmtPass(StmtPass<TextRange>), StmtPass(StmtPass),
StmtBreak(StmtBreak<TextRange>), StmtBreak(StmtBreak),
StmtContinue(StmtContinue<TextRange>), StmtContinue(StmtContinue),
ExprBoolOp(ExprBoolOp<TextRange>), ExprBoolOp(ExprBoolOp),
ExprNamedExpr(ExprNamedExpr<TextRange>), ExprNamedExpr(ExprNamedExpr),
ExprBinOp(ExprBinOp<TextRange>), ExprBinOp(ExprBinOp),
ExprUnaryOp(ExprUnaryOp<TextRange>), ExprUnaryOp(ExprUnaryOp),
ExprLambda(ExprLambda<TextRange>), ExprLambda(ExprLambda),
ExprIfExp(ExprIfExp<TextRange>), ExprIfExp(ExprIfExp),
ExprDict(ExprDict<TextRange>), ExprDict(ExprDict),
ExprSet(ExprSet<TextRange>), ExprSet(ExprSet),
ExprListComp(ExprListComp<TextRange>), ExprListComp(ExprListComp),
ExprSetComp(ExprSetComp<TextRange>), ExprSetComp(ExprSetComp),
ExprDictComp(ExprDictComp<TextRange>), ExprDictComp(ExprDictComp),
ExprGeneratorExp(ExprGeneratorExp<TextRange>), ExprGeneratorExp(ExprGeneratorExp),
ExprAwait(ExprAwait<TextRange>), ExprAwait(ExprAwait),
ExprYield(ExprYield<TextRange>), ExprYield(ExprYield),
ExprYieldFrom(ExprYieldFrom<TextRange>), ExprYieldFrom(ExprYieldFrom),
ExprCompare(ExprCompare<TextRange>), ExprCompare(ExprCompare),
ExprCall(ExprCall<TextRange>), ExprCall(ExprCall),
ExprFormattedValue(ExprFormattedValue<TextRange>), ExprFormattedValue(ExprFormattedValue),
ExprJoinedStr(ExprJoinedStr<TextRange>), ExprJoinedStr(ExprJoinedStr),
ExprConstant(ExprConstant<TextRange>), ExprConstant(ExprConstant),
ExprAttribute(ExprAttribute<TextRange>), ExprAttribute(ExprAttribute),
ExprSubscript(ExprSubscript<TextRange>), ExprSubscript(ExprSubscript),
ExprStarred(ExprStarred<TextRange>), ExprStarred(ExprStarred),
ExprName(ExprName<TextRange>), ExprName(ExprName),
ExprList(ExprList<TextRange>), ExprList(ExprList),
ExprTuple(ExprTuple<TextRange>), ExprTuple(ExprTuple),
ExprSlice(ExprSlice<TextRange>), ExprSlice(ExprSlice),
ExceptHandlerExceptHandler(ExceptHandlerExceptHandler<TextRange>), ExceptHandlerExceptHandler(ExceptHandlerExceptHandler),
PatternMatchValue(PatternMatchValue<TextRange>), PatternMatchValue(PatternMatchValue),
PatternMatchSingleton(PatternMatchSingleton<TextRange>), PatternMatchSingleton(PatternMatchSingleton),
PatternMatchSequence(PatternMatchSequence<TextRange>), PatternMatchSequence(PatternMatchSequence),
PatternMatchMapping(PatternMatchMapping<TextRange>), PatternMatchMapping(PatternMatchMapping),
PatternMatchClass(PatternMatchClass<TextRange>), PatternMatchClass(PatternMatchClass),
PatternMatchStar(PatternMatchStar<TextRange>), PatternMatchStar(PatternMatchStar),
PatternMatchAs(PatternMatchAs<TextRange>), PatternMatchAs(PatternMatchAs),
PatternMatchOr(PatternMatchOr<TextRange>), PatternMatchOr(PatternMatchOr),
TypeIgnoreTypeIgnore(TypeIgnoreTypeIgnore<TextRange>), TypeIgnoreTypeIgnore(TypeIgnoreTypeIgnore),
Comprehension(Comprehension<TextRange>), Comprehension(Comprehension),
Arguments(Arguments<TextRange>), Arguments(Arguments),
Arg(Arg<TextRange>), Arg(Arg),
ArgWithDefault(ArgWithDefault<TextRange>), ArgWithDefault(ArgWithDefault),
Keyword(Keyword<TextRange>), Keyword(Keyword),
Alias(Alias<TextRange>), Alias(Alias),
WithItem(WithItem<TextRange>), WithItem(WithItem),
MatchCase(MatchCase<TextRange>), MatchCase(MatchCase),
Decorator(Decorator<TextRange>), Decorator(Decorator),
} }
impl AnyNode { impl AnyNode {
@ -707,7 +707,7 @@ impl AnyNode {
} }
} }
impl AstNode for ModModule<TextRange> { impl AstNode for ModModule {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -735,7 +735,7 @@ impl AstNode for ModModule<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ModInteractive<TextRange> { impl AstNode for ModInteractive {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -763,7 +763,7 @@ impl AstNode for ModInteractive<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ModExpression<TextRange> { impl AstNode for ModExpression {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -791,7 +791,7 @@ impl AstNode for ModExpression<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ModFunctionType<TextRange> { impl AstNode for ModFunctionType {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -819,7 +819,7 @@ impl AstNode for ModFunctionType<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtFunctionDef<TextRange> { impl AstNode for StmtFunctionDef {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -847,7 +847,7 @@ impl AstNode for StmtFunctionDef<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtAsyncFunctionDef<TextRange> { impl AstNode for StmtAsyncFunctionDef {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -875,7 +875,7 @@ impl AstNode for StmtAsyncFunctionDef<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtClassDef<TextRange> { impl AstNode for StmtClassDef {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -903,7 +903,7 @@ impl AstNode for StmtClassDef<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtReturn<TextRange> { impl AstNode for StmtReturn {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -931,7 +931,7 @@ impl AstNode for StmtReturn<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtDelete<TextRange> { impl AstNode for StmtDelete {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -959,7 +959,7 @@ impl AstNode for StmtDelete<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtAssign<TextRange> { impl AstNode for StmtAssign {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -987,7 +987,7 @@ impl AstNode for StmtAssign<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtAugAssign<TextRange> { impl AstNode for StmtAugAssign {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1015,7 +1015,7 @@ impl AstNode for StmtAugAssign<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtAnnAssign<TextRange> { impl AstNode for StmtAnnAssign {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1043,7 +1043,7 @@ impl AstNode for StmtAnnAssign<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtFor<TextRange> { impl AstNode for StmtFor {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1071,7 +1071,7 @@ impl AstNode for StmtFor<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtAsyncFor<TextRange> { impl AstNode for StmtAsyncFor {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1099,7 +1099,7 @@ impl AstNode for StmtAsyncFor<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtWhile<TextRange> { impl AstNode for StmtWhile {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1127,7 +1127,7 @@ impl AstNode for StmtWhile<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtIf<TextRange> { impl AstNode for StmtIf {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1155,7 +1155,7 @@ impl AstNode for StmtIf<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtWith<TextRange> { impl AstNode for StmtWith {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1183,7 +1183,7 @@ impl AstNode for StmtWith<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtAsyncWith<TextRange> { impl AstNode for StmtAsyncWith {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1211,7 +1211,7 @@ impl AstNode for StmtAsyncWith<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtMatch<TextRange> { impl AstNode for StmtMatch {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1239,7 +1239,7 @@ impl AstNode for StmtMatch<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtRaise<TextRange> { impl AstNode for StmtRaise {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1267,7 +1267,7 @@ impl AstNode for StmtRaise<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtTry<TextRange> { impl AstNode for StmtTry {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1295,7 +1295,7 @@ impl AstNode for StmtTry<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtTryStar<TextRange> { impl AstNode for StmtTryStar {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1323,7 +1323,7 @@ impl AstNode for StmtTryStar<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtAssert<TextRange> { impl AstNode for StmtAssert {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1351,7 +1351,7 @@ impl AstNode for StmtAssert<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtImport<TextRange> { impl AstNode for StmtImport {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1379,7 +1379,7 @@ impl AstNode for StmtImport<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtImportFrom<TextRange> { impl AstNode for StmtImportFrom {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1407,7 +1407,7 @@ impl AstNode for StmtImportFrom<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtGlobal<TextRange> { impl AstNode for StmtGlobal {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1435,7 +1435,7 @@ impl AstNode for StmtGlobal<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtNonlocal<TextRange> { impl AstNode for StmtNonlocal {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1463,7 +1463,7 @@ impl AstNode for StmtNonlocal<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtExpr<TextRange> { impl AstNode for StmtExpr {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1491,7 +1491,7 @@ impl AstNode for StmtExpr<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtPass<TextRange> { impl AstNode for StmtPass {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1519,7 +1519,7 @@ impl AstNode for StmtPass<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtBreak<TextRange> { impl AstNode for StmtBreak {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1547,7 +1547,7 @@ impl AstNode for StmtBreak<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for StmtContinue<TextRange> { impl AstNode for StmtContinue {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1575,7 +1575,7 @@ impl AstNode for StmtContinue<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprBoolOp<TextRange> { impl AstNode for ExprBoolOp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1603,7 +1603,7 @@ impl AstNode for ExprBoolOp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprNamedExpr<TextRange> { impl AstNode for ExprNamedExpr {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1631,7 +1631,7 @@ impl AstNode for ExprNamedExpr<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprBinOp<TextRange> { impl AstNode for ExprBinOp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1659,7 +1659,7 @@ impl AstNode for ExprBinOp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprUnaryOp<TextRange> { impl AstNode for ExprUnaryOp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1687,7 +1687,7 @@ impl AstNode for ExprUnaryOp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprLambda<TextRange> { impl AstNode for ExprLambda {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1715,7 +1715,7 @@ impl AstNode for ExprLambda<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprIfExp<TextRange> { impl AstNode for ExprIfExp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1743,7 +1743,7 @@ impl AstNode for ExprIfExp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprDict<TextRange> { impl AstNode for ExprDict {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1771,7 +1771,7 @@ impl AstNode for ExprDict<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprSet<TextRange> { impl AstNode for ExprSet {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1799,7 +1799,7 @@ impl AstNode for ExprSet<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprListComp<TextRange> { impl AstNode for ExprListComp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1827,7 +1827,7 @@ impl AstNode for ExprListComp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprSetComp<TextRange> { impl AstNode for ExprSetComp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1855,7 +1855,7 @@ impl AstNode for ExprSetComp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprDictComp<TextRange> { impl AstNode for ExprDictComp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1883,7 +1883,7 @@ impl AstNode for ExprDictComp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprGeneratorExp<TextRange> { impl AstNode for ExprGeneratorExp {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1911,7 +1911,7 @@ impl AstNode for ExprGeneratorExp<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprAwait<TextRange> { impl AstNode for ExprAwait {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1939,7 +1939,7 @@ impl AstNode for ExprAwait<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprYield<TextRange> { impl AstNode for ExprYield {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1967,7 +1967,7 @@ impl AstNode for ExprYield<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprYieldFrom<TextRange> { impl AstNode for ExprYieldFrom {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -1995,7 +1995,7 @@ impl AstNode for ExprYieldFrom<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprCompare<TextRange> { impl AstNode for ExprCompare {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2023,7 +2023,7 @@ impl AstNode for ExprCompare<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprCall<TextRange> { impl AstNode for ExprCall {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2051,7 +2051,7 @@ impl AstNode for ExprCall<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprFormattedValue<TextRange> { impl AstNode for ExprFormattedValue {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2079,7 +2079,7 @@ impl AstNode for ExprFormattedValue<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprJoinedStr<TextRange> { impl AstNode for ExprJoinedStr {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2107,7 +2107,7 @@ impl AstNode for ExprJoinedStr<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprConstant<TextRange> { impl AstNode for ExprConstant {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2135,7 +2135,7 @@ impl AstNode for ExprConstant<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprAttribute<TextRange> { impl AstNode for ExprAttribute {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2163,7 +2163,7 @@ impl AstNode for ExprAttribute<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprSubscript<TextRange> { impl AstNode for ExprSubscript {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2191,7 +2191,7 @@ impl AstNode for ExprSubscript<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprStarred<TextRange> { impl AstNode for ExprStarred {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2219,7 +2219,7 @@ impl AstNode for ExprStarred<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprName<TextRange> { impl AstNode for ExprName {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2247,7 +2247,7 @@ impl AstNode for ExprName<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprList<TextRange> { impl AstNode for ExprList {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2275,7 +2275,7 @@ impl AstNode for ExprList<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprTuple<TextRange> { impl AstNode for ExprTuple {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2303,7 +2303,7 @@ impl AstNode for ExprTuple<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExprSlice<TextRange> { impl AstNode for ExprSlice {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2331,7 +2331,7 @@ impl AstNode for ExprSlice<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ExceptHandlerExceptHandler<TextRange> { impl AstNode for ExceptHandlerExceptHandler {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2359,7 +2359,7 @@ impl AstNode for ExceptHandlerExceptHandler<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchValue<TextRange> { impl AstNode for PatternMatchValue {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2387,7 +2387,7 @@ impl AstNode for PatternMatchValue<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchSingleton<TextRange> { impl AstNode for PatternMatchSingleton {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2415,7 +2415,7 @@ impl AstNode for PatternMatchSingleton<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchSequence<TextRange> { impl AstNode for PatternMatchSequence {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2443,7 +2443,7 @@ impl AstNode for PatternMatchSequence<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchMapping<TextRange> { impl AstNode for PatternMatchMapping {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2471,7 +2471,7 @@ impl AstNode for PatternMatchMapping<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchClass<TextRange> { impl AstNode for PatternMatchClass {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2499,7 +2499,7 @@ impl AstNode for PatternMatchClass<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchStar<TextRange> { impl AstNode for PatternMatchStar {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2527,7 +2527,7 @@ impl AstNode for PatternMatchStar<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchAs<TextRange> { impl AstNode for PatternMatchAs {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2555,7 +2555,7 @@ impl AstNode for PatternMatchAs<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for PatternMatchOr<TextRange> { impl AstNode for PatternMatchOr {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2583,7 +2583,7 @@ impl AstNode for PatternMatchOr<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for TypeIgnoreTypeIgnore<TextRange> { impl AstNode for TypeIgnoreTypeIgnore {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2612,7 +2612,7 @@ impl AstNode for TypeIgnoreTypeIgnore<TextRange> {
} }
} }
impl AstNode for Comprehension<TextRange> { impl AstNode for Comprehension {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2640,7 +2640,7 @@ impl AstNode for Comprehension<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for Arguments<TextRange> { impl AstNode for Arguments {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2668,7 +2668,7 @@ impl AstNode for Arguments<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for Arg<TextRange> { impl AstNode for Arg {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2696,7 +2696,7 @@ impl AstNode for Arg<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for ArgWithDefault<TextRange> { impl AstNode for ArgWithDefault {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2724,7 +2724,7 @@ impl AstNode for ArgWithDefault<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for Keyword<TextRange> { impl AstNode for Keyword {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2752,7 +2752,7 @@ impl AstNode for Keyword<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for Alias<TextRange> { impl AstNode for Alias {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2780,7 +2780,7 @@ impl AstNode for Alias<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for WithItem<TextRange> { impl AstNode for WithItem {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2808,7 +2808,7 @@ impl AstNode for WithItem<TextRange> {
AnyNode::from(self) AnyNode::from(self)
} }
} }
impl AstNode for MatchCase<TextRange> { impl AstNode for MatchCase {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -2837,7 +2837,7 @@ impl AstNode for MatchCase<TextRange> {
} }
} }
impl AstNode for Decorator<TextRange> { impl AstNode for Decorator {
fn cast(kind: AnyNode) -> Option<Self> fn cast(kind: AnyNode) -> Option<Self>
where where
Self: Sized, Self: Sized,
@ -3516,83 +3516,83 @@ impl Ranged for AnyNode {
#[derive(Copy, Clone, Debug, is_macro::Is, PartialEq)] #[derive(Copy, Clone, Debug, is_macro::Is, PartialEq)]
pub enum AnyNodeRef<'a> { pub enum AnyNodeRef<'a> {
ModModule(&'a ModModule<TextRange>), ModModule(&'a ModModule),
ModInteractive(&'a ModInteractive<TextRange>), ModInteractive(&'a ModInteractive),
ModExpression(&'a ModExpression<TextRange>), ModExpression(&'a ModExpression),
ModFunctionType(&'a ModFunctionType<TextRange>), ModFunctionType(&'a ModFunctionType),
StmtFunctionDef(&'a StmtFunctionDef<TextRange>), StmtFunctionDef(&'a StmtFunctionDef),
StmtAsyncFunctionDef(&'a StmtAsyncFunctionDef<TextRange>), StmtAsyncFunctionDef(&'a StmtAsyncFunctionDef),
StmtClassDef(&'a StmtClassDef<TextRange>), StmtClassDef(&'a StmtClassDef),
StmtReturn(&'a StmtReturn<TextRange>), StmtReturn(&'a StmtReturn),
StmtDelete(&'a StmtDelete<TextRange>), StmtDelete(&'a StmtDelete),
StmtAssign(&'a StmtAssign<TextRange>), StmtAssign(&'a StmtAssign),
StmtAugAssign(&'a StmtAugAssign<TextRange>), StmtAugAssign(&'a StmtAugAssign),
StmtAnnAssign(&'a StmtAnnAssign<TextRange>), StmtAnnAssign(&'a StmtAnnAssign),
StmtFor(&'a StmtFor<TextRange>), StmtFor(&'a StmtFor),
StmtAsyncFor(&'a StmtAsyncFor<TextRange>), StmtAsyncFor(&'a StmtAsyncFor),
StmtWhile(&'a StmtWhile<TextRange>), StmtWhile(&'a StmtWhile),
StmtIf(&'a StmtIf<TextRange>), StmtIf(&'a StmtIf),
StmtWith(&'a StmtWith<TextRange>), StmtWith(&'a StmtWith),
StmtAsyncWith(&'a StmtAsyncWith<TextRange>), StmtAsyncWith(&'a StmtAsyncWith),
StmtMatch(&'a StmtMatch<TextRange>), StmtMatch(&'a StmtMatch),
StmtRaise(&'a StmtRaise<TextRange>), StmtRaise(&'a StmtRaise),
StmtTry(&'a StmtTry<TextRange>), StmtTry(&'a StmtTry),
StmtTryStar(&'a StmtTryStar<TextRange>), StmtTryStar(&'a StmtTryStar),
StmtAssert(&'a StmtAssert<TextRange>), StmtAssert(&'a StmtAssert),
StmtImport(&'a StmtImport<TextRange>), StmtImport(&'a StmtImport),
StmtImportFrom(&'a StmtImportFrom<TextRange>), StmtImportFrom(&'a StmtImportFrom),
StmtGlobal(&'a StmtGlobal<TextRange>), StmtGlobal(&'a StmtGlobal),
StmtNonlocal(&'a StmtNonlocal<TextRange>), StmtNonlocal(&'a StmtNonlocal),
StmtExpr(&'a StmtExpr<TextRange>), StmtExpr(&'a StmtExpr),
StmtPass(&'a StmtPass<TextRange>), StmtPass(&'a StmtPass),
StmtBreak(&'a StmtBreak<TextRange>), StmtBreak(&'a StmtBreak),
StmtContinue(&'a StmtContinue<TextRange>), StmtContinue(&'a StmtContinue),
ExprBoolOp(&'a ExprBoolOp<TextRange>), ExprBoolOp(&'a ExprBoolOp),
ExprNamedExpr(&'a ExprNamedExpr<TextRange>), ExprNamedExpr(&'a ExprNamedExpr),
ExprBinOp(&'a ExprBinOp<TextRange>), ExprBinOp(&'a ExprBinOp),
ExprUnaryOp(&'a ExprUnaryOp<TextRange>), ExprUnaryOp(&'a ExprUnaryOp),
ExprLambda(&'a ExprLambda<TextRange>), ExprLambda(&'a ExprLambda),
ExprIfExp(&'a ExprIfExp<TextRange>), ExprIfExp(&'a ExprIfExp),
ExprDict(&'a ExprDict<TextRange>), ExprDict(&'a ExprDict),
ExprSet(&'a ExprSet<TextRange>), ExprSet(&'a ExprSet),
ExprListComp(&'a ExprListComp<TextRange>), ExprListComp(&'a ExprListComp),
ExprSetComp(&'a ExprSetComp<TextRange>), ExprSetComp(&'a ExprSetComp),
ExprDictComp(&'a ExprDictComp<TextRange>), ExprDictComp(&'a ExprDictComp),
ExprGeneratorExp(&'a ExprGeneratorExp<TextRange>), ExprGeneratorExp(&'a ExprGeneratorExp),
ExprAwait(&'a ExprAwait<TextRange>), ExprAwait(&'a ExprAwait),
ExprYield(&'a ExprYield<TextRange>), ExprYield(&'a ExprYield),
ExprYieldFrom(&'a ExprYieldFrom<TextRange>), ExprYieldFrom(&'a ExprYieldFrom),
ExprCompare(&'a ExprCompare<TextRange>), ExprCompare(&'a ExprCompare),
ExprCall(&'a ExprCall<TextRange>), ExprCall(&'a ExprCall),
ExprFormattedValue(&'a ExprFormattedValue<TextRange>), ExprFormattedValue(&'a ExprFormattedValue),
ExprJoinedStr(&'a ExprJoinedStr<TextRange>), ExprJoinedStr(&'a ExprJoinedStr),
ExprConstant(&'a ExprConstant<TextRange>), ExprConstant(&'a ExprConstant),
ExprAttribute(&'a ExprAttribute<TextRange>), ExprAttribute(&'a ExprAttribute),
ExprSubscript(&'a ExprSubscript<TextRange>), ExprSubscript(&'a ExprSubscript),
ExprStarred(&'a ExprStarred<TextRange>), ExprStarred(&'a ExprStarred),
ExprName(&'a ExprName<TextRange>), ExprName(&'a ExprName),
ExprList(&'a ExprList<TextRange>), ExprList(&'a ExprList),
ExprTuple(&'a ExprTuple<TextRange>), ExprTuple(&'a ExprTuple),
ExprSlice(&'a ExprSlice<TextRange>), ExprSlice(&'a ExprSlice),
ExceptHandlerExceptHandler(&'a ExceptHandlerExceptHandler<TextRange>), ExceptHandlerExceptHandler(&'a ExceptHandlerExceptHandler),
PatternMatchValue(&'a PatternMatchValue<TextRange>), PatternMatchValue(&'a PatternMatchValue),
PatternMatchSingleton(&'a PatternMatchSingleton<TextRange>), PatternMatchSingleton(&'a PatternMatchSingleton),
PatternMatchSequence(&'a PatternMatchSequence<TextRange>), PatternMatchSequence(&'a PatternMatchSequence),
PatternMatchMapping(&'a PatternMatchMapping<TextRange>), PatternMatchMapping(&'a PatternMatchMapping),
PatternMatchClass(&'a PatternMatchClass<TextRange>), PatternMatchClass(&'a PatternMatchClass),
PatternMatchStar(&'a PatternMatchStar<TextRange>), PatternMatchStar(&'a PatternMatchStar),
PatternMatchAs(&'a PatternMatchAs<TextRange>), PatternMatchAs(&'a PatternMatchAs),
PatternMatchOr(&'a PatternMatchOr<TextRange>), PatternMatchOr(&'a PatternMatchOr),
TypeIgnoreTypeIgnore(&'a TypeIgnoreTypeIgnore<TextRange>), TypeIgnoreTypeIgnore(&'a TypeIgnoreTypeIgnore),
Comprehension(&'a Comprehension<TextRange>), Comprehension(&'a Comprehension),
Arguments(&'a Arguments<TextRange>), Arguments(&'a Arguments),
Arg(&'a Arg<TextRange>), Arg(&'a Arg),
ArgWithDefault(&'a ArgWithDefault<TextRange>), ArgWithDefault(&'a ArgWithDefault),
Keyword(&'a Keyword<TextRange>), Keyword(&'a Keyword),
Alias(&'a Alias<TextRange>), Alias(&'a Alias),
WithItem(&'a WithItem<TextRange>), WithItem(&'a WithItem),
MatchCase(&'a MatchCase<TextRange>), MatchCase(&'a MatchCase),
Decorator(&'a Decorator<TextRange>), Decorator(&'a Decorator),
} }
impl AnyNodeRef<'_> { impl AnyNodeRef<'_> {

View file

@ -132,7 +132,7 @@ impl<'a> Generator<'a> {
} }
} }
fn body<U>(&mut self, stmts: &[Stmt<U>]) { fn body(&mut self, stmts: &[Stmt]) {
self.indent_depth = self.indent_depth.saturating_add(1); self.indent_depth = self.indent_depth.saturating_add(1);
for stmt in stmts { for stmt in stmts {
self.unparse_stmt(stmt); self.unparse_stmt(stmt);
@ -184,13 +184,13 @@ impl<'a> Generator<'a> {
self.buffer self.buffer
} }
pub fn unparse_suite<U>(&mut self, suite: &Suite<U>) { pub fn unparse_suite(&mut self, suite: &Suite) {
for stmt in suite { for stmt in suite {
self.unparse_stmt(stmt); self.unparse_stmt(stmt);
} }
} }
pub(crate) fn unparse_stmt<U>(&mut self, ast: &Stmt<U>) { pub(crate) fn unparse_stmt(&mut self, ast: &Stmt) {
macro_rules! statement { macro_rules! statement {
($body:block) => {{ ($body:block) => {{
self.newline(); self.newline();
@ -467,7 +467,7 @@ impl<'a> Generator<'a> {
}); });
self.body(body); self.body(body);
let mut orelse_: &[Stmt<U>] = orelse; let mut orelse_: &[Stmt] = orelse;
loop { loop {
if orelse_.len() == 1 && matches!(orelse_[0], Stmt::If(_)) { if orelse_.len() == 1 && matches!(orelse_[0], Stmt::If(_)) {
if let Stmt::If(ast::StmtIf { if let Stmt::If(ast::StmtIf {
@ -718,7 +718,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_except_handler<U>(&mut self, ast: &ExceptHandler<U>, star: bool) { fn unparse_except_handler(&mut self, ast: &ExceptHandler, star: bool) {
match ast { match ast {
ExceptHandler::ExceptHandler(ast::ExceptHandlerExceptHandler { ExceptHandler::ExceptHandler(ast::ExceptHandlerExceptHandler {
type_, type_,
@ -744,7 +744,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_pattern<U>(&mut self, ast: &Pattern<U>) { fn unparse_pattern(&mut self, ast: &Pattern) {
match ast { match ast {
Pattern::MatchValue(ast::PatternMatchValue { Pattern::MatchValue(ast::PatternMatchValue {
value, value,
@ -831,7 +831,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_match_case<U>(&mut self, ast: &MatchCase<U>) { fn unparse_match_case(&mut self, ast: &MatchCase) {
self.p("case "); self.p("case ");
self.unparse_pattern(&ast.pattern); self.unparse_pattern(&ast.pattern);
if let Some(guard) = &ast.guard { if let Some(guard) = &ast.guard {
@ -842,7 +842,7 @@ impl<'a> Generator<'a> {
self.body(&ast.body); self.body(&ast.body);
} }
pub(crate) fn unparse_expr<U>(&mut self, ast: &Expr<U>, level: u8) { pub(crate) fn unparse_expr(&mut self, ast: &Expr, level: u8) {
macro_rules! opprec { macro_rules! opprec {
($opty:ident, $x:expr, $enu:path, $($var:ident($op:literal, $prec:ident)),*$(,)?) => { ($opty:ident, $x:expr, $enu:path, $($var:ident($op:literal, $prec:ident)),*$(,)?) => {
match $x { match $x {
@ -1289,7 +1289,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_args<U>(&mut self, args: &Arguments<U>) { fn unparse_args(&mut self, args: &Arguments) {
let mut first = true; let mut first = true;
for (i, arg_with_default) in args.posonlyargs.iter().chain(&args.args).enumerate() { for (i, arg_with_default) in args.posonlyargs.iter().chain(&args.args).enumerate() {
self.p_delim(&mut first, ", "); self.p_delim(&mut first, ", ");
@ -1314,7 +1314,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_arg<U>(&mut self, arg: &Arg<U>) { fn unparse_arg(&mut self, arg: &Arg) {
self.p_id(&arg.arg); self.p_id(&arg.arg);
if let Some(ann) = &arg.annotation { if let Some(ann) = &arg.annotation {
self.p(": "); self.p(": ");
@ -1322,7 +1322,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_arg_with_default<U>(&mut self, arg_with_default: &ArgWithDefault<U>) { fn unparse_arg_with_default(&mut self, arg_with_default: &ArgWithDefault) {
self.unparse_arg(&arg_with_default.def); self.unparse_arg(&arg_with_default.def);
if let Some(default) = &arg_with_default.default { if let Some(default) = &arg_with_default.default {
self.p("="); self.p("=");
@ -1330,7 +1330,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_comp<U>(&mut self, generators: &[Comprehension<U>]) { fn unparse_comp(&mut self, generators: &[Comprehension]) {
for comp in generators { for comp in generators {
self.p(if comp.is_async { self.p(if comp.is_async {
" async for " " async for "
@ -1347,18 +1347,13 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_fstring_body<U>(&mut self, values: &[Expr<U>], is_spec: bool) { fn unparse_fstring_body(&mut self, values: &[Expr], is_spec: bool) {
for value in values { for value in values {
self.unparse_fstring_elem(value, is_spec); self.unparse_fstring_elem(value, is_spec);
} }
} }
fn unparse_formatted<U>( fn unparse_formatted(&mut self, val: &Expr, conversion: ConversionFlag, spec: Option<&Expr>) {
&mut self,
val: &Expr<U>,
conversion: ConversionFlag,
spec: Option<&Expr<U>>,
) {
let mut generator = Generator::new(self.indent, self.quote, self.line_ending); let mut generator = Generator::new(self.indent, self.quote, self.line_ending);
generator.unparse_expr(val, precedence::FORMATTED_VALUE); generator.unparse_expr(val, precedence::FORMATTED_VALUE);
let brace = if generator.buffer.starts_with('{') { let brace = if generator.buffer.starts_with('{') {
@ -1384,7 +1379,7 @@ impl<'a> Generator<'a> {
self.p("}"); self.p("}");
} }
fn unparse_fstring_elem<U>(&mut self, expr: &Expr<U>, is_spec: bool) { fn unparse_fstring_elem(&mut self, expr: &Expr, is_spec: bool) {
match expr { match expr {
Expr::Constant(ast::ExprConstant { value, .. }) => { Expr::Constant(ast::ExprConstant { value, .. }) => {
if let Constant::Str(s) = value { if let Constant::Str(s) = value {
@ -1414,7 +1409,7 @@ impl<'a> Generator<'a> {
self.p(&s); self.p(&s);
} }
fn unparse_joinedstr<U>(&mut self, values: &[Expr<U>], is_spec: bool) { fn unparse_joinedstr(&mut self, values: &[Expr], is_spec: bool) {
if is_spec { if is_spec {
self.unparse_fstring_body(values, is_spec); self.unparse_fstring_body(values, is_spec);
} else { } else {
@ -1433,7 +1428,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_alias<U>(&mut self, alias: &Alias<U>) { fn unparse_alias(&mut self, alias: &Alias) {
self.p_id(&alias.name); self.p_id(&alias.name);
if let Some(asname) = &alias.asname { if let Some(asname) = &alias.asname {
self.p(" as "); self.p(" as ");
@ -1441,7 +1436,7 @@ impl<'a> Generator<'a> {
} }
} }
fn unparse_with_item<U>(&mut self, with_item: &WithItem<U>) { fn unparse_with_item(&mut self, with_item: &WithItem) {
self.unparse_expr(&with_item.context_expr, precedence::MAX); self.unparse_expr(&with_item.context_expr, precedence::MAX);
if let Some(optional_vars) = &with_item.optional_vars { if let Some(optional_vars) = &with_item.optional_vars {
self.p(" as "); self.p(" as ");