Combine Expr::Field and Expr::TupleField into one variant
diff --git a/src/expr.rs b/src/expr.rs
index e7b35b1..4e7efe4 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -1,5 +1,9 @@
use super::*;
use delimited::Delimited;
+#[cfg(feature = "full")]
+use proc_macro2::Span;
+#[cfg(feature = "full")]
+use std::hash::{Hash, Hasher};
ast_struct! {
/// An expression.
@@ -229,20 +233,12 @@
pub right: Box<Expr>,
}),
- /// Access of a named struct field (`obj.foo`)
+ /// Access of a named struct field (`obj.foo`) or unnamed tuple struct
+ /// field (`obj.0`).
pub Field(ExprField #full {
- pub expr: Box<Expr>,
- pub field: Ident,
+ pub base: Box<Expr>,
pub dot_token: Token![.],
- }),
-
- /// Access of an unnamed field of a struct or tuple-struct
- ///
- /// For example, `foo.0`.
- pub TupleField(ExprTupleField #full {
- pub expr: Box<Expr>,
- pub field: Lit,
- pub dot_token: Token![.],
+ pub member: Member,
}),
/// An indexing operation (`foo[2]`)
@@ -363,11 +359,54 @@
}
#[cfg(feature = "full")]
+ast_enum! {
+ /// A struct or tuple struct field accessed in a struct literal or field
+ /// expression.
+ pub enum Member {
+ /// A named field like `self.x`.
+ Named(Ident),
+ /// An unnamed field like `self.0`.
+ Unnamed(Index),
+ }
+}
+
+#[cfg(feature = "full")]
+ast_struct! {
+ /// The index of an unnamed tuple struct field.
+ pub struct Index #manual_extra_traits {
+ pub index: u32,
+ pub span: Span,
+ }
+}
+
+#[cfg(feature = "full")]
+impl Eq for Index {}
+
+#[cfg(feature = "full")]
+impl PartialEq for Index {
+ fn eq(&self, other: &Self) -> bool {
+ self.index == other.index
+ }
+}
+
+#[cfg(feature = "full")]
+impl Hash for Index {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.index.hash(state);
+ }
+}
+
+#[cfg(feature = "full")]
ast_struct! {
/// A field-value pair in a struct literal.
pub struct FieldValue {
- /// Name of the field.
- pub ident: Ident,
+ /// Attributes tagged on the field.
+ pub attrs: Vec<Attribute>,
+
+ /// Name or index of the field.
+ pub member: Member,
+
+ pub colon_token: Option<Token![:]>,
/// Value of the field.
pub expr: Expr,
@@ -375,11 +414,6 @@
/// Whether this is a shorthand field, e.g. `Struct { x }`
/// instead of `Struct { x: x }`.
pub is_shorthand: bool,
-
- /// Attributes tagged on the field.
- pub attrs: Vec<Attribute>,
-
- pub colon_token: Option<Token![:]>,
}
}
@@ -606,7 +640,7 @@
/// except `is_shorthand` is true
pub struct FieldPat {
/// The identifier for the field
- pub ident: Ident,
+ pub member: Member,
/// The pattern the field is destructured to
pub pat: Box<Pat>,
pub is_shorthand: bool,
@@ -659,7 +693,7 @@
use ty::parsing::qpath;
#[cfg(feature = "full")]
- use proc_macro2::{Delimiter, Span, Term, TokenNode, TokenStream};
+ use proc_macro2::{Delimiter, Span, TokenNode, TokenStream};
use synom::Synom;
use cursor::Cursor;
#[cfg(feature = "full")]
@@ -1080,20 +1114,11 @@
})
|
tap!(field: and_field => {
- let (field, token) = field;
+ let (token, member) = field;
e = ExprField {
- expr: Box::new(e.into()),
- field: field,
+ base: Box::new(e.into()),
dot_token: token,
- }.into();
- })
- |
- tap!(field: and_tup_field => {
- let (field, token) = field;
- e = ExprTupleField {
- expr: Box::new(e.into()),
- field: field,
- dot_token: token,
+ member: member,
}.into();
})
|
@@ -1693,11 +1718,11 @@
impl Synom for FieldValue {
named!(parse -> Self, alt!(
do_parse!(
- ident: field_ident >>
+ member: syn!(Member) >>
colon: punct!(:) >>
value: syn!(Expr) >>
(FieldValue {
- ident: ident,
+ member: member,
expr: value,
is_shorthand: false,
attrs: Vec::new(),
@@ -1706,7 +1731,7 @@
)
|
map!(syn!(Ident), |name| FieldValue {
- ident: name,
+ member: Member::Named(name),
expr: ExprKind::Path(ExprPath { qself: None, path: name.into() }).into(),
is_shorthand: true,
attrs: Vec::new(),
@@ -1786,12 +1811,7 @@
}
#[cfg(feature = "full")]
- named!(and_field -> (Ident, Token![.]),
- map!(tuple!(punct!(.), syn!(Ident)), |(a, b)| (b, a)));
-
- #[cfg(feature = "full")]
- named!(and_tup_field -> (Lit, Token![.]),
- map!(tuple!(punct!(.), syn!(Lit)), |(a, b)| (b, a)));
+ named!(and_field -> (Token![.], Member), tuple!(punct!(.), syn!(Member)));
named!(and_index -> (Expr, token::Bracket), brackets!(syn!(Expr)));
@@ -2034,11 +2054,11 @@
impl Synom for FieldPat {
named!(parse -> Self, alt!(
do_parse!(
- ident: field_ident >>
+ member: syn!(Member) >>
colon: punct!(:) >>
pat: syn!(Pat) >>
(FieldPat {
- ident: ident,
+ member: member,
pat: Box::new(pat),
is_shorthand: false,
attrs: Vec::new(),
@@ -2069,7 +2089,7 @@
}.into();
}
FieldPat {
- ident: ident,
+ member: Member::Named(ident),
pat: Box::new(pat),
is_shorthand: true,
attrs: Vec::new(),
@@ -2081,21 +2101,27 @@
}
#[cfg(feature = "full")]
- named!(field_ident -> Ident, alt!(
- syn!(Ident)
- |
- do_parse!(
+ impl Synom for Member {
+ named!(parse -> Self, alt!(
+ syn!(Ident) => { Member::Named }
+ |
+ syn!(Index) => { Member::Unnamed }
+ ));
+ }
+
+ #[cfg(feature = "full")]
+ impl Synom for Index {
+ named!(parse -> Self, do_parse!(
lit: syn!(Lit) >>
({
- let s = lit.to_string();
- if s.parse::<usize>().is_ok() {
- Ident::new(Term::intern(&s), lit.span)
+ if let Ok(i) = lit.value.to_string().parse() {
+ Index { index: i, span: lit.span }
} else {
return parse_error();
}
})
- )
- ));
+ ));
+ }
#[cfg(feature = "full")]
impl Synom for PatPath {
@@ -2268,6 +2294,8 @@
#[cfg(feature = "full")]
use attr::FilterAttrs;
use quote::{ToTokens, Tokens};
+ #[cfg(feature = "full")]
+ use proc_macro2::{TokenTree, TokenNode, Literal};
// If the given expression is a bare `ExprStruct`, wraps it in parenthesis
// before appending it to `Tokens`.
@@ -2614,20 +2642,29 @@
#[cfg(feature = "full")]
impl ToTokens for ExprField {
fn to_tokens(&self, tokens: &mut Tokens) {
- self.expr.to_tokens(tokens);
+ self.base.to_tokens(tokens);
self.dot_token.to_tokens(tokens);
- // XXX: I don't think we can do anything if someone shoves a
- // nonsense Lit in here.
- self.field.to_tokens(tokens);
+ self.member.to_tokens(tokens);
}
}
#[cfg(feature = "full")]
- impl ToTokens for ExprTupleField {
+ impl ToTokens for Member {
fn to_tokens(&self, tokens: &mut Tokens) {
- self.expr.to_tokens(tokens);
- self.dot_token.to_tokens(tokens);
- self.field.to_tokens(tokens);
+ match *self {
+ Member::Named(ident) => ident.to_tokens(tokens),
+ Member::Unnamed(ref index) => index.to_tokens(tokens),
+ }
+ }
+ }
+
+ #[cfg(feature = "full")]
+ impl ToTokens for Index {
+ fn to_tokens(&self, tokens: &mut Tokens) {
+ tokens.append(TokenTree {
+ span: self.span,
+ kind: TokenNode::Literal(Literal::integer(self.index as i64)),
+ });
}
}
@@ -2744,7 +2781,7 @@
#[cfg(feature = "full")]
impl ToTokens for FieldValue {
fn to_tokens(&self, tokens: &mut Tokens) {
- self.ident.to_tokens(tokens);
+ self.member.to_tokens(tokens);
// XXX: Override self.is_shorthand if expr is not an IdentExpr with
// the ident self.ident?
if !self.is_shorthand {
@@ -2917,7 +2954,7 @@
fn to_tokens(&self, tokens: &mut Tokens) {
// XXX: Override is_shorthand if it was wrong?
if !self.is_shorthand {
- self.ident.to_tokens(tokens);
+ self.member.to_tokens(tokens);
TokensOrDefault(&self.colon_token).to_tokens(tokens);
}
self.pat.to_tokens(tokens);
diff --git a/src/gen/fold.rs b/src/gen/fold.rs
index 88f6ab2..d6939aa 100644
--- a/src/gen/fold.rs
+++ b/src/gen/fold.rs
@@ -174,8 +174,6 @@
fn fold_expr_try(&mut self, i: ExprTry) -> ExprTry { fold_expr_try(self, i) }
# [ cfg ( feature = "full" ) ]
fn fold_expr_tuple(&mut self, i: ExprTuple) -> ExprTuple { fold_expr_tuple(self, i) }
-# [ cfg ( feature = "full" ) ]
-fn fold_expr_tuple_field(&mut self, i: ExprTupleField) -> ExprTupleField { fold_expr_tuple_field(self, i) }
fn fold_expr_type(&mut self, i: ExprType) -> ExprType { fold_expr_type(self, i) }
@@ -231,6 +229,8 @@
# [ cfg ( feature = "full" ) ]
fn fold_in_place_kind(&mut self, i: InPlaceKind) -> InPlaceKind { fold_in_place_kind(self, i) }
# [ cfg ( feature = "full" ) ]
+fn fold_index(&mut self, i: Index) -> Index { fold_index(self, i) }
+# [ cfg ( feature = "full" ) ]
fn fold_item(&mut self, i: Item) -> Item { fold_item(self, i) }
# [ cfg ( feature = "full" ) ]
fn fold_item_const(&mut self, i: ItemConst) -> ItemConst { fold_item_const(self, i) }
@@ -272,6 +272,8 @@
fn fold_mac_stmt_style(&mut self, i: MacStmtStyle) -> MacStmtStyle { fold_mac_stmt_style(self, i) }
fn fold_macro(&mut self, i: Macro) -> Macro { fold_macro(self, i) }
+# [ cfg ( feature = "full" ) ]
+fn fold_member(&mut self, i: Member) -> Member { fold_member(self, i) }
fn fold_meta_item(&mut self, i: MetaItem) -> MetaItem { fold_meta_item(self, i) }
@@ -918,9 +920,9 @@
# [ cfg ( feature = "full" ) ]
pub fn fold_expr_field<V: Folder + ?Sized>(_visitor: &mut V, _i: ExprField) -> ExprField {
ExprField {
- expr: Box::new(_visitor.fold_expr(* _i . expr)),
- field: _visitor.fold_ident(_i . field),
+ base: Box::new(_visitor.fold_expr(* _i . base)),
dot_token: _i . dot_token,
+ member: _visitor.fold_member(_i . member),
}
}
# [ cfg ( feature = "full" ) ]
@@ -1105,11 +1107,6 @@
full!(_visitor.fold_expr_field(_binding_0)),
)
}
- TupleField(_binding_0, ) => {
- TupleField (
- full!(_visitor.fold_expr_tuple_field(_binding_0)),
- )
- }
Index(_binding_0, ) => {
Index (
_visitor.fold_expr_index(_binding_0),
@@ -1282,14 +1279,6 @@
lone_comma: _i . lone_comma,
}
}
-# [ cfg ( feature = "full" ) ]
-pub fn fold_expr_tuple_field<V: Folder + ?Sized>(_visitor: &mut V, _i: ExprTupleField) -> ExprTupleField {
- ExprTupleField {
- expr: Box::new(_visitor.fold_expr(* _i . expr)),
- field: _i . field,
- dot_token: _i . dot_token,
- }
-}
pub fn fold_expr_type<V: Folder + ?Sized>(_visitor: &mut V, _i: ExprType) -> ExprType {
ExprType {
@@ -1355,7 +1344,7 @@
# [ cfg ( feature = "full" ) ]
pub fn fold_field_pat<V: Folder + ?Sized>(_visitor: &mut V, _i: FieldPat) -> FieldPat {
FieldPat {
- ident: _visitor.fold_ident(_i . ident),
+ member: _visitor.fold_member(_i . member),
pat: Box::new(_visitor.fold_pat(* _i . pat)),
is_shorthand: _i . is_shorthand,
colon_token: _i . colon_token,
@@ -1365,11 +1354,11 @@
# [ cfg ( feature = "full" ) ]
pub fn fold_field_value<V: Folder + ?Sized>(_visitor: &mut V, _i: FieldValue) -> FieldValue {
FieldValue {
- ident: _visitor.fold_ident(_i . ident),
+ attrs: FoldHelper::lift(_i . attrs, |it| { _visitor.fold_attribute(it) }),
+ member: _visitor.fold_member(_i . member),
+ colon_token: _i . colon_token,
expr: _visitor.fold_expr(_i . expr),
is_shorthand: _i . is_shorthand,
- attrs: FoldHelper::lift(_i . attrs, |it| { _visitor.fold_attribute(it) }),
- colon_token: _i . colon_token,
}
}
# [ cfg ( feature = "full" ) ]
@@ -1633,6 +1622,13 @@
}
}
# [ cfg ( feature = "full" ) ]
+pub fn fold_index<V: Folder + ?Sized>(_visitor: &mut V, _i: Index) -> Index {
+ Index {
+ index: _i . index,
+ span: _visitor.fold_span(_i . span),
+ }
+}
+# [ cfg ( feature = "full" ) ]
pub fn fold_item<V: Folder + ?Sized>(_visitor: &mut V, _i: Item) -> Item {
use ::Item::*;
match _i {
@@ -1956,6 +1952,22 @@
tokens: _i . tokens,
}
}
+# [ cfg ( feature = "full" ) ]
+pub fn fold_member<V: Folder + ?Sized>(_visitor: &mut V, _i: Member) -> Member {
+ use ::Member::*;
+ match _i {
+ Named(_binding_0, ) => {
+ Named (
+ _visitor.fold_ident(_binding_0),
+ )
+ }
+ Unnamed(_binding_0, ) => {
+ Unnamed (
+ _visitor.fold_index(_binding_0),
+ )
+ }
+ }
+}
pub fn fold_meta_item<V: Folder + ?Sized>(_visitor: &mut V, _i: MetaItem) -> MetaItem {
use ::MetaItem::*;
diff --git a/src/gen/visit.rs b/src/gen/visit.rs
index 9caab14..a9021c7 100644
--- a/src/gen/visit.rs
+++ b/src/gen/visit.rs
@@ -148,8 +148,6 @@
fn visit_expr_try(&mut self, i: &'ast ExprTry) { visit_expr_try(self, i) }
# [ cfg ( feature = "full" ) ]
fn visit_expr_tuple(&mut self, i: &'ast ExprTuple) { visit_expr_tuple(self, i) }
-# [ cfg ( feature = "full" ) ]
-fn visit_expr_tuple_field(&mut self, i: &'ast ExprTupleField) { visit_expr_tuple_field(self, i) }
fn visit_expr_type(&mut self, i: &'ast ExprType) { visit_expr_type(self, i) }
@@ -205,6 +203,8 @@
# [ cfg ( feature = "full" ) ]
fn visit_in_place_kind(&mut self, i: &'ast InPlaceKind) { visit_in_place_kind(self, i) }
# [ cfg ( feature = "full" ) ]
+fn visit_index(&mut self, i: &'ast Index) { visit_index(self, i) }
+# [ cfg ( feature = "full" ) ]
fn visit_item(&mut self, i: &'ast Item) { visit_item(self, i) }
# [ cfg ( feature = "full" ) ]
fn visit_item_const(&mut self, i: &'ast ItemConst) { visit_item_const(self, i) }
@@ -246,6 +246,8 @@
fn visit_mac_stmt_style(&mut self, i: &'ast MacStmtStyle) { visit_mac_stmt_style(self, i) }
fn visit_macro(&mut self, i: &'ast Macro) { visit_macro(self, i) }
+# [ cfg ( feature = "full" ) ]
+fn visit_member(&mut self, i: &'ast Member) { visit_member(self, i) }
fn visit_meta_item(&mut self, i: &'ast MetaItem) { visit_meta_item(self, i) }
@@ -755,9 +757,9 @@
}
# [ cfg ( feature = "full" ) ]
pub fn visit_expr_field<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprField) {
- _visitor.visit_expr(& _i . expr);
- _visitor.visit_ident(& _i . field);
+ _visitor.visit_expr(& _i . base);
// Skipped field _i . dot_token;
+ _visitor.visit_member(& _i . member);
}
# [ cfg ( feature = "full" ) ]
pub fn visit_expr_for_loop<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprForLoop) {
@@ -881,9 +883,6 @@
Field(ref _binding_0, ) => {
full!(_visitor.visit_expr_field(_binding_0));
}
- TupleField(ref _binding_0, ) => {
- full!(_visitor.visit_expr_tuple_field(_binding_0));
- }
Index(ref _binding_0, ) => {
_visitor.visit_expr_index(_binding_0);
}
@@ -1004,12 +1003,6 @@
// Skipped field _i . paren_token;
// Skipped field _i . lone_comma;
}
-# [ cfg ( feature = "full" ) ]
-pub fn visit_expr_tuple_field<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprTupleField) {
- _visitor.visit_expr(& _i . expr);
- // Skipped field _i . field;
- // Skipped field _i . dot_token;
-}
pub fn visit_expr_type<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprType) {
_visitor.visit_expr(& _i . expr);
@@ -1060,7 +1053,7 @@
}
# [ cfg ( feature = "full" ) ]
pub fn visit_field_pat<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldPat) {
- _visitor.visit_ident(& _i . ident);
+ _visitor.visit_member(& _i . member);
_visitor.visit_pat(& _i . pat);
// Skipped field _i . is_shorthand;
// Skipped field _i . colon_token;
@@ -1068,11 +1061,11 @@
}
# [ cfg ( feature = "full" ) ]
pub fn visit_field_value<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldValue) {
- _visitor.visit_ident(& _i . ident);
+ for it in & _i . attrs { _visitor.visit_attribute(it) };
+ _visitor.visit_member(& _i . member);
+ // Skipped field _i . colon_token;
_visitor.visit_expr(& _i . expr);
// Skipped field _i . is_shorthand;
- for it in & _i . attrs { _visitor.visit_attribute(it) };
- // Skipped field _i . colon_token;
}
# [ cfg ( feature = "full" ) ]
pub fn visit_file<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast File) {
@@ -1272,6 +1265,11 @@
}
}
# [ cfg ( feature = "full" ) ]
+pub fn visit_index<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Index) {
+ // Skipped field _i . index;
+ _visitor.visit_span(& _i . span);
+}
+# [ cfg ( feature = "full" ) ]
pub fn visit_item<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Item) {
use ::Item::*;
match *_i {
@@ -1523,6 +1521,18 @@
// Skipped field _i . bang_token;
// Skipped field _i . tokens;
}
+# [ cfg ( feature = "full" ) ]
+pub fn visit_member<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Member) {
+ use ::Member::*;
+ match *_i {
+ Named(ref _binding_0, ) => {
+ _visitor.visit_ident(_binding_0);
+ }
+ Unnamed(ref _binding_0, ) => {
+ _visitor.visit_index(_binding_0);
+ }
+ }
+}
pub fn visit_meta_item<'ast, V: Visitor<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast MetaItem) {
use ::MetaItem::*;
diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs
index 3034f90..b75114c 100644
--- a/src/gen/visit_mut.rs
+++ b/src/gen/visit_mut.rs
@@ -148,8 +148,6 @@
fn visit_expr_try_mut(&mut self, i: &mut ExprTry) { visit_expr_try_mut(self, i) }
# [ cfg ( feature = "full" ) ]
fn visit_expr_tuple_mut(&mut self, i: &mut ExprTuple) { visit_expr_tuple_mut(self, i) }
-# [ cfg ( feature = "full" ) ]
-fn visit_expr_tuple_field_mut(&mut self, i: &mut ExprTupleField) { visit_expr_tuple_field_mut(self, i) }
fn visit_expr_type_mut(&mut self, i: &mut ExprType) { visit_expr_type_mut(self, i) }
@@ -205,6 +203,8 @@
# [ cfg ( feature = "full" ) ]
fn visit_in_place_kind_mut(&mut self, i: &mut InPlaceKind) { visit_in_place_kind_mut(self, i) }
# [ cfg ( feature = "full" ) ]
+fn visit_index_mut(&mut self, i: &mut Index) { visit_index_mut(self, i) }
+# [ cfg ( feature = "full" ) ]
fn visit_item_mut(&mut self, i: &mut Item) { visit_item_mut(self, i) }
# [ cfg ( feature = "full" ) ]
fn visit_item_const_mut(&mut self, i: &mut ItemConst) { visit_item_const_mut(self, i) }
@@ -246,6 +246,8 @@
fn visit_mac_stmt_style_mut(&mut self, i: &mut MacStmtStyle) { visit_mac_stmt_style_mut(self, i) }
fn visit_macro_mut(&mut self, i: &mut Macro) { visit_macro_mut(self, i) }
+# [ cfg ( feature = "full" ) ]
+fn visit_member_mut(&mut self, i: &mut Member) { visit_member_mut(self, i) }
fn visit_meta_item_mut(&mut self, i: &mut MetaItem) { visit_meta_item_mut(self, i) }
@@ -755,9 +757,9 @@
}
# [ cfg ( feature = "full" ) ]
pub fn visit_expr_field_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut ExprField) {
- _visitor.visit_expr_mut(& mut _i . expr);
- _visitor.visit_ident_mut(& mut _i . field);
+ _visitor.visit_expr_mut(& mut _i . base);
// Skipped field _i . dot_token;
+ _visitor.visit_member_mut(& mut _i . member);
}
# [ cfg ( feature = "full" ) ]
pub fn visit_expr_for_loop_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut ExprForLoop) {
@@ -881,9 +883,6 @@
Field(ref mut _binding_0, ) => {
full!(_visitor.visit_expr_field_mut(_binding_0));
}
- TupleField(ref mut _binding_0, ) => {
- full!(_visitor.visit_expr_tuple_field_mut(_binding_0));
- }
Index(ref mut _binding_0, ) => {
_visitor.visit_expr_index_mut(_binding_0);
}
@@ -1004,12 +1003,6 @@
// Skipped field _i . paren_token;
// Skipped field _i . lone_comma;
}
-# [ cfg ( feature = "full" ) ]
-pub fn visit_expr_tuple_field_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut ExprTupleField) {
- _visitor.visit_expr_mut(& mut _i . expr);
- // Skipped field _i . field;
- // Skipped field _i . dot_token;
-}
pub fn visit_expr_type_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut ExprType) {
_visitor.visit_expr_mut(& mut _i . expr);
@@ -1060,7 +1053,7 @@
}
# [ cfg ( feature = "full" ) ]
pub fn visit_field_pat_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut FieldPat) {
- _visitor.visit_ident_mut(& mut _i . ident);
+ _visitor.visit_member_mut(& mut _i . member);
_visitor.visit_pat_mut(& mut _i . pat);
// Skipped field _i . is_shorthand;
// Skipped field _i . colon_token;
@@ -1068,11 +1061,11 @@
}
# [ cfg ( feature = "full" ) ]
pub fn visit_field_value_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut FieldValue) {
- _visitor.visit_ident_mut(& mut _i . ident);
+ for mut it in & mut _i . attrs { _visitor.visit_attribute_mut(it) };
+ _visitor.visit_member_mut(& mut _i . member);
+ // Skipped field _i . colon_token;
_visitor.visit_expr_mut(& mut _i . expr);
// Skipped field _i . is_shorthand;
- for mut it in & mut _i . attrs { _visitor.visit_attribute_mut(it) };
- // Skipped field _i . colon_token;
}
# [ cfg ( feature = "full" ) ]
pub fn visit_file_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut File) {
@@ -1272,6 +1265,11 @@
}
}
# [ cfg ( feature = "full" ) ]
+pub fn visit_index_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut Index) {
+ // Skipped field _i . index;
+ _visitor.visit_span_mut(& mut _i . span);
+}
+# [ cfg ( feature = "full" ) ]
pub fn visit_item_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut Item) {
use ::Item::*;
match *_i {
@@ -1523,6 +1521,18 @@
// Skipped field _i . bang_token;
// Skipped field _i . tokens;
}
+# [ cfg ( feature = "full" ) ]
+pub fn visit_member_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut Member) {
+ use ::Member::*;
+ match *_i {
+ Named(ref mut _binding_0, ) => {
+ _visitor.visit_ident_mut(_binding_0);
+ }
+ Unnamed(ref mut _binding_0, ) => {
+ _visitor.visit_index_mut(_binding_0);
+ }
+ }
+}
pub fn visit_meta_item_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut MetaItem) {
use ::MetaItem::*;
diff --git a/src/ident.rs b/src/ident.rs
index 1e717c9..0e2d521 100644
--- a/src/ident.rs
+++ b/src/ident.rs
@@ -219,7 +219,7 @@
impl Hash for Ident {
fn hash<H: Hasher>(&self, h: &mut H) {
- self.as_ref().hash(h)
+ self.as_ref().hash(h);
}
}
diff --git a/src/lib.rs b/src/lib.rs
index c2a7822..678a1c7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -38,12 +38,12 @@
ExprBox, ExprBreak, ExprCall, ExprCast, ExprCatch, ExprClosure, ExprContinue,
ExprField, ExprForLoop, ExprGroup, ExprIf, ExprIfLet, ExprInPlace, ExprIndex,
ExprKind, ExprLoop, ExprMatch, ExprMethodCall, ExprParen, ExprPath, ExprRange,
- ExprRepeat, ExprRet, ExprStruct, ExprTry, ExprTupleField, ExprTuple, ExprType,
+ ExprRepeat, ExprRet, ExprStruct, ExprTry, ExprTuple, ExprType,
ExprUnary, ExprUnsafe, ExprWhile, ExprWhileLet, ExprYield};
#[cfg(feature = "full")]
-pub use expr::{Arm, BindingMode, Block, CaptureBy, FieldPat, FieldValue, InPlaceKind, Local,
- MacStmtStyle, Pat, PatBox, PatIdent, PatLit, PatPath, PatRange, PatRef, PatSlice,
+pub use expr::{Arm, BindingMode, Block, CaptureBy, FieldPat, FieldValue, Index, InPlaceKind, Local,
+ MacStmtStyle, Member, Pat, PatBox, PatIdent, PatLit, PatPath, PatRange, PatRef, PatSlice,
PatStruct, PatTuple, PatTupleStruct, PatWild, RangeLimits, Stmt};
mod generics;