mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-28 06:14:56 +00:00
Update auto-generated ast code
This commit is contained in:
parent
33092d8002
commit
385c522471
3 changed files with 56 additions and 12 deletions
|
@ -2896,13 +2896,24 @@ pub fn fold_type_param_type_var<U, F: Fold<U> + ?Sized>(
|
|||
#[allow(unused)] folder: &mut F,
|
||||
node: TypeParamTypeVar<U>,
|
||||
) -> Result<TypeParamTypeVar<F::TargetU>, F::Error> {
|
||||
let TypeParamTypeVar { name, bound, range } = node;
|
||||
let TypeParamTypeVar {
|
||||
name,
|
||||
bound,
|
||||
default_value,
|
||||
range,
|
||||
} = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
||||
let name = Foldable::fold(name, folder)?;
|
||||
let bound = Foldable::fold(bound, folder)?;
|
||||
let default_value = Foldable::fold(default_value, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(TypeParamTypeVar { name, bound, range })
|
||||
Ok(TypeParamTypeVar {
|
||||
name,
|
||||
bound,
|
||||
default_value,
|
||||
range,
|
||||
})
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for TypeParamParamSpec<T> {
|
||||
type Mapped = TypeParamParamSpec<U>;
|
||||
|
@ -2917,12 +2928,21 @@ pub fn fold_type_param_param_spec<U, F: Fold<U> + ?Sized>(
|
|||
#[allow(unused)] folder: &mut F,
|
||||
node: TypeParamParamSpec<U>,
|
||||
) -> Result<TypeParamParamSpec<F::TargetU>, F::Error> {
|
||||
let TypeParamParamSpec { name, range } = node;
|
||||
let TypeParamParamSpec {
|
||||
name,
|
||||
default_value,
|
||||
range,
|
||||
} = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
||||
let name = Foldable::fold(name, folder)?;
|
||||
let default_value = Foldable::fold(default_value, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(TypeParamParamSpec { name, range })
|
||||
Ok(TypeParamParamSpec {
|
||||
name,
|
||||
default_value,
|
||||
range,
|
||||
})
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for TypeParamTypeVarTuple<T> {
|
||||
type Mapped = TypeParamTypeVarTuple<U>;
|
||||
|
@ -2937,12 +2957,21 @@ pub fn fold_type_param_type_var_tuple<U, F: Fold<U> + ?Sized>(
|
|||
#[allow(unused)] folder: &mut F,
|
||||
node: TypeParamTypeVarTuple<U>,
|
||||
) -> Result<TypeParamTypeVarTuple<F::TargetU>, F::Error> {
|
||||
let TypeParamTypeVarTuple { name, range } = node;
|
||||
let TypeParamTypeVarTuple {
|
||||
name,
|
||||
default_value,
|
||||
range,
|
||||
} = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
||||
let name = Foldable::fold(name, folder)?;
|
||||
let default_value = Foldable::fold(default_value, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(TypeParamTypeVarTuple { name, range })
|
||||
Ok(TypeParamTypeVarTuple {
|
||||
name,
|
||||
default_value,
|
||||
range,
|
||||
})
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for ArgWithDefault<T> {
|
||||
type Mapped = ArgWithDefault<U>;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// File automatically generated by ast/asdl_rs.py.
|
||||
|
||||
use crate::text_size::TextRange;
|
||||
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(is_macro::Is)]
|
||||
pub enum Ast<R = TextRange> {
|
||||
#[is(name = "module")]
|
||||
Mod(Mod<R>),
|
||||
|
@ -3131,11 +3132,12 @@ pub struct TypeParamTypeVar<R = TextRange> {
|
|||
pub range: R,
|
||||
pub name: Identifier,
|
||||
pub bound: Option<Box<Expr<R>>>,
|
||||
pub default_value: Option<Box<Expr<R>>>,
|
||||
}
|
||||
|
||||
impl<R> Node for TypeParamTypeVar<R> {
|
||||
const NAME: &'static str = "TypeVar";
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name", "bound"];
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name", "bound", "default_value"];
|
||||
}
|
||||
impl<R> From<TypeParamTypeVar<R>> for TypeParam<R> {
|
||||
fn from(payload: TypeParamTypeVar<R>) -> Self {
|
||||
|
@ -3153,11 +3155,12 @@ impl<R> From<TypeParamTypeVar<R>> for Ast<R> {
|
|||
pub struct TypeParamParamSpec<R = TextRange> {
|
||||
pub range: R,
|
||||
pub name: Identifier,
|
||||
pub default_value: Option<Box<Expr<R>>>,
|
||||
}
|
||||
|
||||
impl<R> Node for TypeParamParamSpec<R> {
|
||||
const NAME: &'static str = "ParamSpec";
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name"];
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name", "default_value"];
|
||||
}
|
||||
impl<R> From<TypeParamParamSpec<R>> for TypeParam<R> {
|
||||
fn from(payload: TypeParamParamSpec<R>) -> Self {
|
||||
|
@ -3175,11 +3178,12 @@ impl<R> From<TypeParamParamSpec<R>> for Ast<R> {
|
|||
pub struct TypeParamTypeVarTuple<R = TextRange> {
|
||||
pub range: R,
|
||||
pub name: Identifier,
|
||||
pub default_value: Option<Box<Expr<R>>>,
|
||||
}
|
||||
|
||||
impl<R> Node for TypeParamTypeVarTuple<R> {
|
||||
const NAME: &'static str = "TypeVarTuple";
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name"];
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name", "default_value"];
|
||||
}
|
||||
impl<R> From<TypeParamTypeVarTuple<R>> for TypeParam<R> {
|
||||
fn from(payload: TypeParamTypeVarTuple<R>) -> Self {
|
||||
|
|
|
@ -853,13 +853,24 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
if let Some(value) = node.bound {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
if let Some(value) = node.default_value {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
}
|
||||
fn visit_type_param_param_spec(&mut self, node: TypeParamParamSpec<R>) {
|
||||
self.generic_visit_type_param_param_spec(node)
|
||||
}
|
||||
fn generic_visit_type_param_param_spec(&mut self, node: TypeParamParamSpec<R>) {}
|
||||
fn generic_visit_type_param_param_spec(&mut self, node: TypeParamParamSpec<R>) {
|
||||
if let Some(value) = node.default_value {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
}
|
||||
fn visit_type_param_type_var_tuple(&mut self, node: TypeParamTypeVarTuple<R>) {
|
||||
self.generic_visit_type_param_type_var_tuple(node)
|
||||
}
|
||||
fn generic_visit_type_param_type_var_tuple(&mut self, node: TypeParamTypeVarTuple<R>) {}
|
||||
fn generic_visit_type_param_type_var_tuple(&mut self, node: TypeParamTypeVarTuple<R>) {
|
||||
if let Some(value) = node.default_value {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue