Upgrade RustPython (#4900)

This commit is contained in:
Micha Reiser 2023-06-08 07:53:14 +02:00 committed by GitHub
parent 4b78141f6b
commit 39a1f3980f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 416 additions and 320 deletions

View file

@ -2,6 +2,7 @@
//! ability to compare expressions for equality (via [`Eq`] and [`Hash`]).
use num_bigint::BigInt;
use rustpython_ast::Decorator;
use rustpython_parser::ast::{
self, Alias, Arg, Arguments, Boolop, Cmpop, Comprehension, Constant, ConversionFlag,
Excepthandler, Expr, ExprContext, Identifier, Int, Keyword, MatchCase, Operator, Pattern, Stmt,
@ -267,6 +268,19 @@ impl<'a> From<&'a MatchCase> for ComparableMatchCase<'a> {
}
}
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct ComparableDecorator<'a> {
pub expression: ComparableExpr<'a>,
}
impl<'a> From<&'a Decorator> for ComparableDecorator<'a> {
fn from(decorator: &'a Decorator) -> Self {
Self {
expression: (&decorator.expression).into(),
}
}
}
#[derive(Debug, PartialEq, Eq, Hash)]
pub enum ComparableConstant<'a> {
None,
@ -777,7 +791,7 @@ pub enum ComparableStmt<'a> {
name: &'a str,
args: ComparableArguments<'a>,
body: Vec<ComparableStmt<'a>>,
decorator_list: Vec<ComparableExpr<'a>>,
decorator_list: Vec<ComparableDecorator<'a>>,
returns: Option<ComparableExpr<'a>>,
type_comment: Option<&'a str>,
},
@ -785,7 +799,7 @@ pub enum ComparableStmt<'a> {
name: &'a str,
args: ComparableArguments<'a>,
body: Vec<ComparableStmt<'a>>,
decorator_list: Vec<ComparableExpr<'a>>,
decorator_list: Vec<ComparableDecorator<'a>>,
returns: Option<ComparableExpr<'a>>,
type_comment: Option<&'a str>,
},
@ -794,7 +808,7 @@ pub enum ComparableStmt<'a> {
bases: Vec<ComparableExpr<'a>>,
keywords: Vec<ComparableKeyword<'a>>,
body: Vec<ComparableStmt<'a>>,
decorator_list: Vec<ComparableExpr<'a>>,
decorator_list: Vec<ComparableDecorator<'a>>,
},
Return {
value: Option<ComparableExpr<'a>>,