mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-04 02:39:22 +00:00
Fix range field order (#56)
* Skip validate_arguments when empty * Fix `range` field order * Fix unused variable
This commit is contained in:
parent
531e41ae2c
commit
6c5c311bab
38 changed files with 211 additions and 215 deletions
|
@ -471,10 +471,10 @@ class StructVisitor(EmitVisitor):
|
|||
self.emit_attrs(depth)
|
||||
|
||||
self.emit(f"pub struct {product_name}<R = TextRange> {{", depth)
|
||||
self.emit_range(product.attributes, depth + 1)
|
||||
for f in product.fields:
|
||||
self.visit(f, type_info, "pub ", depth + 1)
|
||||
assert bool(product.attributes) == type_info.no_cfg(self.type_info)
|
||||
self.emit_range(product.attributes, depth + 1)
|
||||
self.emit("}", depth)
|
||||
|
||||
field_names = [f'"{f.name}"' for f in product.fields]
|
||||
|
@ -505,7 +505,7 @@ class FoldTraitDefVisitor(EmitVisitor):
|
|||
self.will_map_user(user)
|
||||
}
|
||||
#[cfg(not(feature = "all-nodes-with-ranges"))]
|
||||
fn will_map_user_cfg(&mut self, user: &crate::EmptyRange<U>) -> crate::EmptyRange<Self::TargetU> {
|
||||
fn will_map_user_cfg(&mut self, _user: &crate::EmptyRange<U>) -> crate::EmptyRange<Self::TargetU> {
|
||||
crate::EmptyRange::default()
|
||||
}
|
||||
fn map_user(&mut self, user: U, context: Self::UserContext) -> Result<Self::TargetU, Self::Error>;
|
||||
|
|
|
@ -13,7 +13,7 @@ pub trait Fold<U> {
|
|||
#[cfg(not(feature = "all-nodes-with-ranges"))]
|
||||
fn will_map_user_cfg(
|
||||
&mut self,
|
||||
user: &crate::EmptyRange<U>,
|
||||
_user: &crate::EmptyRange<U>,
|
||||
) -> crate::EmptyRange<Self::TargetU> {
|
||||
crate::EmptyRange::default()
|
||||
}
|
||||
|
|
|
@ -2047,11 +2047,11 @@ impl Node for Cmpop {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Comprehension<R = TextRange> {
|
||||
pub range: OptionalRange<R>,
|
||||
pub target: Expr<R>,
|
||||
pub iter: Expr<R>,
|
||||
pub ifs: Vec<Expr<R>>,
|
||||
pub is_async: bool,
|
||||
pub range: OptionalRange<R>,
|
||||
}
|
||||
|
||||
impl<R> Node for Comprehension<R> {
|
||||
|
@ -2089,6 +2089,7 @@ impl<R> Node for Excepthandler<R> {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Arguments<R = TextRange> {
|
||||
pub range: OptionalRange<R>,
|
||||
pub posonlyargs: Vec<Arg<R>>,
|
||||
pub args: Vec<Arg<R>>,
|
||||
pub vararg: Option<Box<Arg<R>>>,
|
||||
|
@ -2096,7 +2097,6 @@ pub struct Arguments<R = TextRange> {
|
|||
pub kw_defaults: Vec<Expr<R>>,
|
||||
pub kwarg: Option<Box<Arg<R>>>,
|
||||
pub defaults: Vec<Expr<R>>,
|
||||
pub range: OptionalRange<R>,
|
||||
}
|
||||
|
||||
impl<R> Node for Arguments<R> {
|
||||
|
@ -2114,10 +2114,10 @@ impl<R> Node for Arguments<R> {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Arg<R = TextRange> {
|
||||
pub range: R,
|
||||
pub arg: Identifier,
|
||||
pub annotation: Option<Box<Expr<R>>>,
|
||||
pub type_comment: Option<String>,
|
||||
pub range: R,
|
||||
}
|
||||
|
||||
impl<R> Node for Arg<R> {
|
||||
|
@ -2127,9 +2127,9 @@ impl<R> Node for Arg<R> {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Keyword<R = TextRange> {
|
||||
pub range: R,
|
||||
pub arg: Option<Identifier>,
|
||||
pub value: Expr<R>,
|
||||
pub range: R,
|
||||
}
|
||||
|
||||
impl<R> Node for Keyword<R> {
|
||||
|
@ -2139,9 +2139,9 @@ impl<R> Node for Keyword<R> {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Alias<R = TextRange> {
|
||||
pub range: R,
|
||||
pub name: Identifier,
|
||||
pub asname: Option<Identifier>,
|
||||
pub range: R,
|
||||
}
|
||||
|
||||
impl<R> Node for Alias<R> {
|
||||
|
@ -2151,9 +2151,9 @@ impl<R> Node for Alias<R> {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Withitem<R = TextRange> {
|
||||
pub range: OptionalRange<R>,
|
||||
pub context_expr: Expr<R>,
|
||||
pub optional_vars: Option<Box<Expr<R>>>,
|
||||
pub range: OptionalRange<R>,
|
||||
}
|
||||
|
||||
impl<R> Node for Withitem<R> {
|
||||
|
@ -2163,10 +2163,10 @@ impl<R> Node for Withitem<R> {
|
|||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct MatchCase<R = TextRange> {
|
||||
pub range: OptionalRange<R>,
|
||||
pub pattern: Pattern<R>,
|
||||
pub guard: Option<Box<Expr<R>>>,
|
||||
pub body: Vec<Stmt<R>>,
|
||||
pub range: OptionalRange<R>,
|
||||
}
|
||||
|
||||
impl<R> Node for MatchCase<R> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue