Extern types
diff --git a/src/gen/fold.rs b/src/gen/fold.rs
index 4ab418a..c12d2d2 100644
--- a/src/gen/fold.rs
+++ b/src/gen/fold.rs
@@ -199,6 +199,8 @@
fn fold_foreign_item_fn(&mut self, i: ForeignItemFn) -> ForeignItemFn { fold_foreign_item_fn(self, i) }
# [ cfg ( feature = "full" ) ]
fn fold_foreign_item_static(&mut self, i: ForeignItemStatic) -> ForeignItemStatic { fold_foreign_item_static(self, i) }
+# [ cfg ( feature = "full" ) ]
+fn fold_foreign_item_type(&mut self, i: ForeignItemType) -> ForeignItemType { fold_foreign_item_type(self, i) }
fn fold_generics(&mut self, i: Generics) -> Generics { fold_generics(self, i) }
# [ cfg ( feature = "full" ) ]
@@ -1394,6 +1396,11 @@
_visitor.fold_foreign_item_static(_binding_0),
)
}
+ Type(_binding_0, ) => {
+ Type (
+ _visitor.fold_foreign_item_type(_binding_0),
+ )
+ }
}
}
# [ cfg ( feature = "full" ) ]
@@ -1419,6 +1426,16 @@
semi_token: _i . semi_token,
}
}
+# [ cfg ( feature = "full" ) ]
+pub fn fold_foreign_item_type<V: Folder + ?Sized>(_visitor: &mut V, _i: ForeignItemType) -> ForeignItemType {
+ ForeignItemType {
+ attrs: FoldHelper::lift(_i . attrs, |it| { _visitor.fold_attribute(it) }),
+ vis: _visitor.fold_visibility(_i . vis),
+ type_token: _i . type_token,
+ ident: _i . ident,
+ semi_token: _i . semi_token,
+ }
+}
pub fn fold_generics<V: Folder + ?Sized>(_visitor: &mut V, _i: Generics) -> Generics {
Generics {
diff --git a/src/gen/visit.rs b/src/gen/visit.rs
index 3e52f7c..8b6b816 100644
--- a/src/gen/visit.rs
+++ b/src/gen/visit.rs
@@ -172,6 +172,8 @@
fn visit_foreign_item_fn(&mut self, i: &ForeignItemFn) { visit_foreign_item_fn(self, i) }
# [ cfg ( feature = "full" ) ]
fn visit_foreign_item_static(&mut self, i: &ForeignItemStatic) { visit_foreign_item_static(self, i) }
+# [ cfg ( feature = "full" ) ]
+fn visit_foreign_item_type(&mut self, i: &ForeignItemType) { visit_foreign_item_type(self, i) }
fn visit_generics(&mut self, i: &Generics) { visit_generics(self, i) }
# [ cfg ( feature = "full" ) ]
@@ -1085,6 +1087,9 @@
Static(ref _binding_0, ) => {
_visitor.visit_foreign_item_static(&* _binding_0);
}
+ Type(ref _binding_0, ) => {
+ _visitor.visit_foreign_item_type(&* _binding_0);
+ }
}
}
# [ cfg ( feature = "full" ) ]
@@ -1106,6 +1111,14 @@
_visitor.visit_type(&_i . ty);
// Skipped field _i . semi_token;
}
+# [ cfg ( feature = "full" ) ]
+pub fn visit_foreign_item_type<V: Visitor + ?Sized>(_visitor: &mut V, _i: &ForeignItemType) {
+ for it in (_i . attrs).iter() { _visitor.visit_attribute(&it) };
+ _visitor.visit_visibility(&_i . vis);
+ // Skipped field _i . type_token;
+ // Skipped field _i . ident;
+ // Skipped field _i . semi_token;
+}
pub fn visit_generics<V: Visitor + ?Sized>(_visitor: &mut V, _i: &Generics) {
// Skipped field _i . lt_token;
diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs
index e35470a..42462d4 100644
--- a/src/gen/visit_mut.rs
+++ b/src/gen/visit_mut.rs
@@ -172,6 +172,8 @@
fn visit_foreign_item_fn_mut(&mut self, i: &mut ForeignItemFn) { visit_foreign_item_fn_mut(self, i) }
# [ cfg ( feature = "full" ) ]
fn visit_foreign_item_static_mut(&mut self, i: &mut ForeignItemStatic) { visit_foreign_item_static_mut(self, i) }
+# [ cfg ( feature = "full" ) ]
+fn visit_foreign_item_type_mut(&mut self, i: &mut ForeignItemType) { visit_foreign_item_type_mut(self, i) }
fn visit_generics_mut(&mut self, i: &mut Generics) { visit_generics_mut(self, i) }
# [ cfg ( feature = "full" ) ]
@@ -1085,6 +1087,9 @@
Static(ref mut _binding_0, ) => {
_visitor.visit_foreign_item_static_mut(&mut * _binding_0);
}
+ Type(ref mut _binding_0, ) => {
+ _visitor.visit_foreign_item_type_mut(&mut * _binding_0);
+ }
}
}
# [ cfg ( feature = "full" ) ]
@@ -1106,6 +1111,14 @@
_visitor.visit_type_mut(&mut _i . ty);
// Skipped field _i . semi_token;
}
+# [ cfg ( feature = "full" ) ]
+pub fn visit_foreign_item_type_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut ForeignItemType) {
+ for mut it in (_i . attrs).iter_mut() { _visitor.visit_attribute_mut(&mut it) };
+ _visitor.visit_visibility_mut(&mut _i . vis);
+ // Skipped field _i . type_token;
+ // Skipped field _i . ident;
+ // Skipped field _i . semi_token;
+}
pub fn visit_generics_mut<V: VisitorMut + ?Sized>(_visitor: &mut V, _i: &mut Generics) {
// Skipped field _i . lt_token;
diff --git a/src/item.rs b/src/item.rs
index 30a4a58..ff36380 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -297,6 +297,14 @@
pub ty: Box<Type>,
pub semi_token: Token![;],
}),
+ /// A foreign type
+ pub Type(ForeignItemType {
+ pub attrs: Vec<Attribute>,
+ pub vis: Visibility,
+ pub type_token: Token![type],
+ pub ident: Ident,
+ pub semi_token: Token![;],
+ }),
}
}
@@ -814,6 +822,8 @@
syn!(ForeignItemFn) => { ForeignItem::Fn }
|
syn!(ForeignItemStatic) => { ForeignItem::Static }
+ |
+ syn!(ForeignItemType) => { ForeignItem::Type }
));
impl_synom!(ForeignItemFn "foreign function" do_parse!(
@@ -876,6 +886,21 @@
})
));
+ impl_synom!(ForeignItemType "foreign type" do_parse!(
+ attrs: many0!(call!(Attribute::parse_outer)) >>
+ vis: syn!(Visibility) >>
+ type_: keyword!(type) >>
+ ident: syn!(Ident) >>
+ semi: punct!(;) >>
+ (ForeignItemType {
+ attrs: attrs,
+ vis: vis,
+ type_token: type_,
+ ident: ident,
+ semi_token: semi,
+ })
+ ));
+
impl_synom!(ItemType "type item" do_parse!(
attrs: many0!(call!(Attribute::parse_outer)) >>
vis: syn!(Visibility) >>
@@ -1686,6 +1711,16 @@
}
}
+ impl ToTokens for ForeignItemType {
+ fn to_tokens(&self, tokens: &mut Tokens) {
+ tokens.append_all(self.attrs.outer());
+ self.vis.to_tokens(tokens);
+ self.type_token.to_tokens(tokens);
+ self.ident.to_tokens(tokens);
+ self.semi_token.to_tokens(tokens);
+ }
+ }
+
impl ToTokens for MethodSig {
fn to_tokens(&self, tokens: &mut Tokens) {
self.constness.to_tokens(tokens);
diff --git a/src/lib.rs b/src/lib.rs
index 8fad211..3cec269 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -57,7 +57,7 @@
TraitItem, ViewPath, ItemExternCrate, ItemUse,
ItemStatic, ItemConst, ItemFn, ItemMacro, ItemMod, ItemType, ItemEnum,
ItemStruct, ItemUnion, ItemTrait, ItemDefaultImpl, ItemImpl,
- PathSimple, PathGlob, PathList, ForeignItemFn, ForeignItemStatic,
+ PathSimple, PathGlob, PathList, ForeignItemFn, ForeignItemStatic, ForeignItemType,
TraitItemConst, TraitItemMacro, TraitItemMethod, TraitItemType,
ImplItemConst, ImplItemMacro, ImplItemMethod, ImplItemType, ArgSelfRef,
ArgSelf, ArgCaptured};