impl Target {
fn from_item(item: &ast::Item) -> Target {
match item.node {
- ast::ItemFn(..) => Target::Fn,
- ast::ItemStruct(..) => Target::Struct,
- ast::ItemEnum(..) => Target::Enum,
+ ast::ItemKind::Fn(..) => Target::Fn,
+ ast::ItemKind::Struct(..) => Target::Struct,
+ ast::ItemKind::Enum(..) => Target::Enum,
_ => Target::Other,
}
}
}
impl fold::Folder for ReplaceBodyWithLoop {
- fn fold_item_underscore(&mut self, i: ast::Item_) -> ast::Item_ {
+ fn fold_item_kind(&mut self, i: ast::ItemKind) -> ast::ItemKind {
match i {
- ast::ItemStatic(..) | ast::ItemConst(..) => {
+ ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => {
self.within_static_or_const = true;
- let ret = fold::noop_fold_item_underscore(i, self);
+ let ret = fold::noop_fold_item_kind(i, self);
self.within_static_or_const = false;
return ret;
}
_ => {
- fold::noop_fold_item_underscore(i, self)
+ fold::noop_fold_item_kind(i, self)
}
}
}
})
}
-pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
+pub fn lower_item_kind(lctx: &LoweringContext, i: &ItemKind) -> hir::Item_ {
match *i {
- ItemExternCrate(string) => hir::ItemExternCrate(string),
- ItemUse(ref view_path) => {
+ ItemKind::ExternCrate(string) => hir::ItemExternCrate(string),
+ ItemKind::Use(ref view_path) => {
hir::ItemUse(lower_view_path(lctx, view_path))
}
- ItemStatic(ref t, m, ref e) => {
+ ItemKind::Static(ref t, m, ref e) => {
hir::ItemStatic(lower_ty(lctx, t),
lower_mutability(lctx, m),
lower_expr(lctx, e))
}
- ItemConst(ref t, ref e) => {
+ ItemKind::Const(ref t, ref e) => {
hir::ItemConst(lower_ty(lctx, t), lower_expr(lctx, e))
}
- ItemFn(ref decl, unsafety, constness, abi, ref generics, ref body) => {
+ ItemKind::Fn(ref decl, unsafety, constness, abi, ref generics, ref body) => {
hir::ItemFn(lower_fn_decl(lctx, decl),
lower_unsafety(lctx, unsafety),
lower_constness(lctx, constness),
lower_generics(lctx, generics),
lower_block(lctx, body))
}
- ItemMod(ref m) => hir::ItemMod(lower_mod(lctx, m)),
- ItemForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)),
- ItemTy(ref t, ref generics) => {
+ ItemKind::Mod(ref m) => hir::ItemMod(lower_mod(lctx, m)),
+ ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)),
+ ItemKind::Ty(ref t, ref generics) => {
hir::ItemTy(lower_ty(lctx, t), lower_generics(lctx, generics))
}
- ItemEnum(ref enum_definition, ref generics) => {
+ ItemKind::Enum(ref enum_definition, ref generics) => {
hir::ItemEnum(hir::EnumDef {
variants: enum_definition.variants
.iter()
},
lower_generics(lctx, generics))
}
- ItemStruct(ref struct_def, ref generics) => {
+ ItemKind::Struct(ref struct_def, ref generics) => {
let struct_def = lower_variant_data(lctx, struct_def);
hir::ItemStruct(struct_def, lower_generics(lctx, generics))
}
- ItemDefaultImpl(unsafety, ref trait_ref) => {
+ ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
hir::ItemDefaultImpl(lower_unsafety(lctx, unsafety),
lower_trait_ref(lctx, trait_ref))
}
- ItemImpl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => {
+ ItemKind::Impl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => {
let new_impl_items = impl_items.iter()
.map(|item| lower_impl_item(lctx, item))
.collect();
lower_ty(lctx, ty),
new_impl_items)
}
- ItemTrait(unsafety, ref generics, ref bounds, ref items) => {
+ ItemKind::Trait(unsafety, ref generics, ref bounds, ref items) => {
let bounds = lower_bounds(lctx, bounds);
let items = items.iter().map(|item| lower_trait_item(lctx, item)).collect();
hir::ItemTrait(lower_unsafety(lctx, unsafety),
bounds,
items)
}
- ItemMac(_) => panic!("Shouldn't still be around"),
+ ItemKind::Mac(_) => panic!("Shouldn't still be around"),
}
}
}
pub fn lower_item(lctx: &LoweringContext, i: &Item) -> hir::Item {
- let node = lower_item_underscore(lctx, &i.node);
+ let node = lower_item_kind(lctx, &i.node);
hir::Item {
id: i.id,
fn extract_crate_info(&self, i: &ast::Item) -> Option<CrateInfo> {
match i.node {
- ast::ItemExternCrate(ref path_opt) => {
+ ast::ItemKind::ExternCrate(ref path_opt) => {
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
i.ident, path_opt);
let name = match *path_opt {
// crate root, because `$crate` won't work properly. Identify these by
// spans, because the crate map isn't set up yet.
for item in &krate.module.items {
- if let ast::ItemExternCrate(_) = item.node {
+ if let ast::ItemKind::ExternCrate(_) = item.node {
loader.span_whitelist.insert(item.span);
}
}
fn visit_item(&mut self, item: &ast::Item) {
// We're only interested in `extern crate`.
match item.node {
- ast::ItemExternCrate(_) => {}
+ ast::ItemKind::ExternCrate(_) => {}
_ => {
visit::walk_item(self, item);
return;
fn visit_item(&mut self, i: &'v ast::Item) {
visit::walk_item(self, i);
match i.node {
- ast::ItemConst(_, ref e) => {
+ ast::ItemKind::Const(_, ref e) => {
CheckBlock{ sess: self.sess, kind: "constant"}.visit_expr(e)
},
- ast::ItemStatic(_, _, ref e) => {
+ ast::ItemKind::Static(_, _, ref e) => {
CheckBlock{ sess: self.sess, kind: "static"}.visit_expr(e)
},
_ => {},
impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
fn visit_item(&mut self, item: &ast::Item) {
+ use syntax::ast::ItemKind::*;
self.process_macro_use(item.span, item.id);
match item.node {
- ast::ItemUse(ref use_item) => {
+ Use(ref use_item) => {
match use_item.node {
ast::ViewPathSimple(ident, ref path) => {
let sub_span = self.span.span_for_last_ident(path.span);
}
}
}
- ast::ItemExternCrate(ref s) => {
+ ExternCrate(ref s) => {
let location = match *s {
Some(s) => s.to_string(),
None => item.ident.to_string(),
&location,
self.cur_scope);
}
- ast::ItemFn(ref decl, _, _, _, ref ty_params, ref body) =>
+ Fn(ref decl, _, _, _, ref ty_params, ref body) =>
self.process_fn(item, &**decl, ty_params, &**body),
- ast::ItemStatic(ref typ, _, ref expr) =>
+ Static(ref typ, _, ref expr) =>
self.process_static_or_const_item(item, typ, expr),
- ast::ItemConst(ref typ, ref expr) =>
+ Const(ref typ, ref expr) =>
self.process_static_or_const_item(item, &typ, &expr),
- ast::ItemStruct(ref def, ref ty_params) => self.process_struct(item, def, ty_params),
- ast::ItemEnum(ref def, ref ty_params) => self.process_enum(item, def, ty_params),
- ast::ItemImpl(_, _,
+ Struct(ref def, ref ty_params) => self.process_struct(item, def, ty_params),
+ Enum(ref def, ref ty_params) => self.process_enum(item, def, ty_params),
+ Impl(_, _,
ref ty_params,
ref trait_ref,
ref typ,
ref impl_items) => {
self.process_impl(item, ty_params, trait_ref, &typ, impl_items)
}
- ast::ItemTrait(_, ref generics, ref trait_refs, ref methods) =>
+ Trait(_, ref generics, ref trait_refs, ref methods) =>
self.process_trait(item, generics, trait_refs, methods),
- ast::ItemMod(ref m) => {
+ Mod(ref m) => {
self.process_mod(item);
self.nest(item.id, |v| visit::walk_mod(v, m));
}
- ast::ItemTy(ref ty, ref ty_params) => {
+ Ty(ref ty, ref ty_params) => {
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
let value = ty_to_string(&**ty);
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type);
self.visit_ty(&**ty);
self.process_generic_params(ty_params, item.span, &qualname, item.id);
}
- ast::ItemMac(_) => (),
+ Mac(_) => (),
_ => visit::walk_item(self, item),
}
}
pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
match item.node {
- ast::ItemFn(..) => {
+ ast::ItemKind::Fn(..) => {
let name = self.tcx.map.path_to_string(item.id);
let qualname = format!("::{}", name);
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Fn);
scope: self.enclosing_scope(item.id),
}))
}
- ast::ItemStatic(ref typ, mt, ref expr) => {
+ ast::ItemKind::Static(ref typ, mt, ref expr) => {
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
// If the variable is immutable, save the initialising expression.
type_value: ty_to_string(&typ),
}))
}
- ast::ItemConst(ref typ, ref expr) => {
+ ast::ItemKind::Const(ref typ, ref expr) => {
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Const);
filter!(self.span_utils, sub_span, item.span, None);
type_value: ty_to_string(&typ),
}))
}
- ast::ItemMod(ref m) => {
+ ast::ItemKind::Mod(ref m) => {
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
let cm = self.tcx.sess.codemap();
filename: filename,
}))
}
- ast::ItemEnum(..) => {
+ ast::ItemKind::Enum(..) => {
let enum_name = format!("::{}", self.tcx.map.path_to_string(item.id));
let val = self.span_utils.snippet(item.span);
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Enum);
scope: self.enclosing_scope(item.id),
}))
}
- ast::ItemImpl(_, _, _, ref trait_ref, ref typ, _) => {
+ ast::ItemKind::Impl(_, _, _, ref trait_ref, ref typ, _) => {
let mut type_data = None;
let sub_span;
// The Rust abstract syntax tree.
-pub use self::Item_::*;
pub use self::KleeneOp::*;
pub use self::MacStmtStyle::*;
pub use self::MetaItem_::*;
///
/// resolve maps each TraitRef's ref_id to its defining trait; that's all
/// that the ref_id is for. The impl_id maps to the "self type" of this impl.
-/// If this impl is an ItemImpl, the impl_id is redundant (it could be the
+/// If this impl is an ItemKind::Impl, the impl_id is redundant (it could be the
/// same as the impl's node id).
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TraitRef {
pub ident: Ident,
pub attrs: Vec<Attribute>,
pub id: NodeId,
- pub node: Item_,
+ pub node: ItemKind,
pub vis: Visibility,
pub span: Span,
}
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
-pub enum Item_ {
+pub enum ItemKind {
/// An`extern crate` item, with optional original crate name,
///
/// e.g. `extern crate foo` or `extern crate foo_bar as foo`
- ItemExternCrate(Option<Name>),
+ ExternCrate(Option<Name>),
/// A `use` or `pub use` item
- ItemUse(P<ViewPath>),
+ Use(P<ViewPath>),
/// A `static` item
- ItemStatic(P<Ty>, Mutability, P<Expr>),
+ Static(P<Ty>, Mutability, P<Expr>),
/// A `const` item
- ItemConst(P<Ty>, P<Expr>),
+ Const(P<Ty>, P<Expr>),
/// A function declaration
- ItemFn(P<FnDecl>, Unsafety, Constness, Abi, Generics, P<Block>),
+ Fn(P<FnDecl>, Unsafety, Constness, Abi, Generics, P<Block>),
/// A module
- ItemMod(Mod),
+ Mod(Mod),
/// An external module
- ItemForeignMod(ForeignMod),
+ ForeignMod(ForeignMod),
/// A type alias, e.g. `type Foo = Bar<u8>`
- ItemTy(P<Ty>, Generics),
+ Ty(P<Ty>, Generics),
/// An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}`
- ItemEnum(EnumDef, Generics),
+ Enum(EnumDef, Generics),
/// A struct definition, e.g. `struct Foo<A> {x: A}`
- ItemStruct(VariantData, Generics),
+ Struct(VariantData, Generics),
/// Represents a Trait Declaration
- ItemTrait(Unsafety,
+ Trait(Unsafety,
Generics,
TyParamBounds,
Vec<P<TraitItem>>),
// Default trait implementations
///
// `impl Trait for .. {}`
- ItemDefaultImpl(Unsafety, TraitRef),
+ DefaultImpl(Unsafety, TraitRef),
/// An implementation, eg `impl<A> Trait for Foo { .. }`
- ItemImpl(Unsafety,
+ Impl(Unsafety,
ImplPolarity,
Generics,
Option<TraitRef>, // (optional) trait this impl implements
P<Ty>, // self
Vec<P<ImplItem>>),
/// A macro invocation (which includes macro definition)
- ItemMac(Mac),
+ Mac(Mac),
}
-impl Item_ {
+impl ItemKind {
pub fn descriptive_variant(&self) -> &str {
match *self {
- ItemExternCrate(..) => "extern crate",
- ItemUse(..) => "use",
- ItemStatic(..) => "static item",
- ItemConst(..) => "constant item",
- ItemFn(..) => "function",
- ItemMod(..) => "module",
- ItemForeignMod(..) => "foreign module",
- ItemTy(..) => "type alias",
- ItemEnum(..) => "enum",
- ItemStruct(..) => "struct",
- ItemTrait(..) => "trait",
- ItemMac(..) |
- ItemImpl(..) |
- ItemDefaultImpl(..) => "item"
+ ItemKind::ExternCrate(..) => "extern crate",
+ ItemKind::Use(..) => "use",
+ ItemKind::Static(..) => "static item",
+ ItemKind::Const(..) => "constant item",
+ ItemKind::Fn(..) => "function",
+ ItemKind::Mod(..) => "module",
+ ItemKind::ForeignMod(..) => "foreign module",
+ ItemKind::Ty(..) => "type alias",
+ ItemKind::Enum(..) => "enum",
+ ItemKind::Struct(..) => "struct",
+ ItemKind::Trait(..) => "trait",
+ ItemKind::Mac(..) |
+ ItemKind::Impl(..) |
+ ItemKind::DefaultImpl(..) => "item"
}
}
}
self.operation.visit_id(item.id);
match item.node {
- ItemUse(ref view_path) => {
+ ItemKind::Use(ref view_path) => {
match view_path.node {
ViewPathSimple(_, _) |
ViewPathGlob(_) => {}
fn fold_foreign_mod(&mut self, foreign_mod: ast::ForeignMod) -> ast::ForeignMod {
fold_foreign_mod(self, foreign_mod)
}
- fn fold_item_underscore(&mut self, item: ast::Item_) -> ast::Item_ {
- fold_item_underscore(self, item)
+ fn fold_item_kind(&mut self, item: ast::ItemKind) -> ast::ItemKind {
+ fold_item_kind(self, item)
}
fn fold_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
// If an expr is valid to cfg away it will have been removed by the
}
}
-fn fold_item_underscore<F>(cx: &mut Context<F>, item: ast::Item_) -> ast::Item_ where
+fn fold_item_kind<F>(cx: &mut Context<F>, item: ast::ItemKind) -> ast::ItemKind where
F: FnMut(&[ast::Attribute]) -> bool
{
let item = match item {
- ast::ItemImpl(u, o, a, b, c, impl_items) => {
+ ast::ItemKind::Impl(u, o, a, b, c, impl_items) => {
let impl_items = impl_items.into_iter()
.filter(|ii| (cx.in_cfg)(&ii.attrs))
.collect();
- ast::ItemImpl(u, o, a, b, c, impl_items)
+ ast::ItemKind::Impl(u, o, a, b, c, impl_items)
}
- ast::ItemTrait(u, a, b, methods) => {
+ ast::ItemKind::Trait(u, a, b, methods) => {
let methods = methods.into_iter()
.filter(|ti| (cx.in_cfg)(&ti.attrs))
.collect();
- ast::ItemTrait(u, a, b, methods)
+ ast::ItemKind::Trait(u, a, b, methods)
}
- ast::ItemStruct(def, generics) => {
- ast::ItemStruct(fold_struct(cx, def), generics)
+ ast::ItemKind::Struct(def, generics) => {
+ ast::ItemKind::Struct(fold_struct(cx, def), generics)
}
- ast::ItemEnum(def, generics) => {
+ ast::ItemKind::Enum(def, generics) => {
let variants = def.variants.into_iter().filter_map(|v| {
if !(cx.in_cfg)(&v.node.attrs) {
None
}))
}
});
- ast::ItemEnum(ast::EnumDef {
+ ast::ItemKind::Enum(ast::EnumDef {
variants: variants.collect(),
}, generics)
}
item => item,
};
- fold::noop_fold_item_underscore(item, cx)
+ fold::noop_fold_item_kind(item, cx)
}
fn fold_struct<F>(cx: &mut Context<F>, vdata: ast::VariantData) -> ast::VariantData where
ident: name.clone(),
attrs: Vec::new(),
id: ast::DUMMY_NODE_ID,
- node: ast::ItemConst(
+ node: ast::ItemKind::Const(
ty,
expr,
),
// except according to those terms.
use attr;
-use ast::{Item, ItemFn};
+use ast::{Item, ItemKind};
pub enum EntryPointType {
None,
// them in sync.
pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType {
match item.node {
- ItemFn(..) => {
+ ItemKind::Fn(..) => {
if attr::contains_name(&item.attrs, "start") {
EntryPointType::Start
} else if attr::contains_name(&item.attrs, "main") {
}
}
-// A more flexible ItemModifier (ItemModifier should go away, eventually, FIXME).
+// A more flexible ItemKind::Modifier (ItemKind::Modifier should go away, eventually, FIXME).
// meta_item is the annotation, item is the item being modified, parent_item
// is the impl or trait item is declared in if item is part of such a thing.
// FIXME Decorators should follow the same pattern too.
// items
fn item(&self, span: Span,
- name: Ident, attrs: Vec<ast::Attribute> , node: ast::Item_) -> P<ast::Item>;
+ name: Ident, attrs: Vec<ast::Attribute> , node: ast::ItemKind) -> P<ast::Item>;
fn arg(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::Arg;
// FIXME unused self
}
fn item(&self, span: Span, name: Ident,
- attrs: Vec<ast::Attribute>, node: ast::Item_) -> P<ast::Item> {
+ attrs: Vec<ast::Attribute>, node: ast::ItemKind) -> P<ast::Item> {
// FIXME: Would be nice if our generated code didn't violate
// Rust coding conventions
P(ast::Item {
self.item(span,
name,
Vec::new(),
- ast::ItemFn(self.fn_decl(inputs, output),
+ ast::ItemKind::Fn(self.fn_decl(inputs, output),
ast::Unsafety::Normal,
ast::Constness::NotConst,
Abi::Rust,
fn item_enum_poly(&self, span: Span, name: Ident,
enum_definition: ast::EnumDef,
generics: Generics) -> P<ast::Item> {
- self.item(span, name, Vec::new(), ast::ItemEnum(enum_definition, generics))
+ self.item(span, name, Vec::new(), ast::ItemKind::Enum(enum_definition, generics))
}
fn item_enum(&self, span: Span, name: Ident,
fn item_struct_poly(&self, span: Span, name: Ident,
struct_def: ast::VariantData, generics: Generics) -> P<ast::Item> {
- self.item(span, name, Vec::new(), ast::ItemStruct(struct_def, generics))
+ self.item(span, name, Vec::new(), ast::ItemKind::Struct(struct_def, generics))
}
fn item_mod(&self, span: Span, inner_span: Span, name: Ident,
span,
name,
attrs,
- ast::ItemMod(ast::Mod {
+ ast::ItemKind::Mod(ast::Mod {
inner: inner_span,
items: items,
})
mutbl: ast::Mutability,
expr: P<ast::Expr>)
-> P<ast::Item> {
- self.item(span, name, Vec::new(), ast::ItemStatic(ty, mutbl, expr))
+ self.item(span, name, Vec::new(), ast::ItemKind::Static(ty, mutbl, expr))
}
fn item_const(&self,
ty: P<ast::Ty>,
expr: P<ast::Expr>)
-> P<ast::Item> {
- self.item(span, name, Vec::new(), ast::ItemConst(ty, expr))
+ self.item(span, name, Vec::new(), ast::ItemKind::Const(ty, expr))
}
fn item_ty_poly(&self, span: Span, name: Ident, ty: P<ast::Ty>,
generics: Generics) -> P<ast::Item> {
- self.item(span, name, Vec::new(), ast::ItemTy(ty, generics))
+ self.item(span, name, Vec::new(), ast::ItemKind::Ty(ty, generics))
}
fn item_ty(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> P<ast::Item> {
id: ast::DUMMY_NODE_ID,
ident: special_idents::invalid,
attrs: vec![],
- node: ast::ItemUse(vp),
+ node: ast::ItemKind::Use(vp),
vis: vis,
span: sp
})
use ast::{Block, Crate, DeclKind, PatMac};
use ast::{Local, Ident, Mac_, Name};
-use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtKind};
+use ast::{MacStmtStyle, Mrk, Stmt, StmtKind, ItemKind};
use ast::TokenTree;
use ast;
use ext::mtwt;
.into_iter().map(|i| i.expect_item()).collect()
}
-/// Expand item_underscore
-fn expand_item_underscore(item: ast::Item_, fld: &mut MacroExpander) -> ast::Item_ {
+/// Expand item_kind
+fn expand_item_kind(item: ast::ItemKind, fld: &mut MacroExpander) -> ast::ItemKind {
match item {
- ast::ItemFn(decl, unsafety, constness, abi, generics, body) => {
+ ast::ItemKind::Fn(decl, unsafety, constness, abi, generics, body) => {
let (rewritten_fn_decl, rewritten_body)
= expand_and_rename_fn_decl_and_block(decl, body, fld);
let expanded_generics = fold::noop_fold_generics(generics,fld);
- ast::ItemFn(rewritten_fn_decl, unsafety, constness, abi,
+ ast::ItemKind::Fn(rewritten_fn_decl, unsafety, constness, abi,
expanded_generics, rewritten_body)
}
- _ => noop_fold_item_underscore(item, fld)
+ _ => noop_fold_item_kind(item, fld)
}
}
pub fn expand_item_mac(it: P<ast::Item>,
fld: &mut MacroExpander) -> SmallVector<P<ast::Item>> {
let (extname, path_span, tts, span, attrs, ident) = it.and_then(|it| match it.node {
- ItemMac(codemap::Spanned { node: Mac_ { path, tts, .. }, .. }) =>
+ ItemKind::Mac(codemap::Spanned { node: Mac_ { path, tts, .. }, .. }) =>
(path.segments[0].identifier.name, path.span, tts, it.span, it.attrs, it.ident),
_ => fld.cx.span_bug(it.span, "invalid item macro invocation")
});
let mut new_items: SmallVector<Annotatable> = match a {
Annotatable::Item(it) => match it.node {
- ast::ItemMac(..) => {
+ ast::ItemKind::Mac(..) => {
expand_item_mac(it, fld).into_iter().map(|i| Annotatable::Item(i)).collect()
}
- ast::ItemMod(_) | ast::ItemForeignMod(_) => {
+ ast::ItemKind::Mod(_) | ast::ItemKind::ForeignMod(_) => {
let valid_ident =
it.ident.name != parse::token::special_idents::invalid.name;
}
}
- // Expansion may have added new ItemModifiers.
+ // Expansion may have added new ItemKind::Modifiers.
expand_item_multi_modifier(it, fld)
}
expand_item(item, self)
}
- fn fold_item_underscore(&mut self, item: ast::Item_) -> ast::Item_ {
- expand_item_underscore(item, self)
+ fn fold_item_kind(&mut self, item: ast::ItemKind) -> ast::ItemKind {
+ expand_item_kind(item, self)
}
fn fold_stmt(&mut self, stmt: P<ast::Stmt>) -> SmallVector<P<ast::Stmt>> {
fn visit_item(&mut self, i: &ast::Item) {
match i.node {
- ast::ItemExternCrate(_) => {
+ ast::ItemKind::ExternCrate(_) => {
if attr::contains_name(&i.attrs[..], "macro_reexport") {
self.gate_feature("macro_reexport", i.span,
"macros reexports are experimental \
}
}
- ast::ItemForeignMod(ref foreign_module) => {
+ ast::ItemKind::ForeignMod(ref foreign_module) => {
if attr::contains_name(&i.attrs[..], "link_args") {
self.gate_feature("link_args", i.span,
"the `link_args` attribute is not portable \
}
}
- ast::ItemFn(..) => {
+ ast::ItemKind::Fn(..) => {
if attr::contains_name(&i.attrs[..], "plugin_registrar") {
self.gate_feature("plugin_registrar", i.span,
"compiler plugins are experimental and possibly buggy");
}
}
- ast::ItemStruct(..) => {
+ ast::ItemKind::Struct(..) => {
if attr::contains_name(&i.attrs[..], "simd") {
self.gate_feature("simd", i.span,
"SIMD types are experimental and possibly buggy");
}
}
- ast::ItemDefaultImpl(..) => {
+ ast::ItemKind::DefaultImpl(..) => {
self.gate_feature("optin_builtin_traits",
i.span,
"default trait implementations are experimental \
and possibly buggy");
}
- ast::ItemImpl(_, polarity, _, _, _, _) => {
+ ast::ItemKind::Impl(_, polarity, _, _, _, _) => {
match polarity {
ast::ImplPolarity::Negative => {
self.gate_feature("optin_builtin_traits",
noop_fold_struct_field(sf, self)
}
- fn fold_item_underscore(&mut self, i: Item_) -> Item_ {
- noop_fold_item_underscore(i, self)
+ fn fold_item_kind(&mut self, i: ItemKind) -> ItemKind {
+ noop_fold_item_kind(i, self)
}
fn fold_trait_item(&mut self, i: P<TraitItem>) -> SmallVector<P<TraitItem>> {
})
}
-pub fn noop_fold_item_underscore<T: Folder>(i: Item_, folder: &mut T) -> Item_ {
+pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
match i {
- ItemExternCrate(string) => ItemExternCrate(string),
- ItemUse(view_path) => {
- ItemUse(folder.fold_view_path(view_path))
+ ItemKind::ExternCrate(string) => ItemKind::ExternCrate(string),
+ ItemKind::Use(view_path) => {
+ ItemKind::Use(folder.fold_view_path(view_path))
}
- ItemStatic(t, m, e) => {
- ItemStatic(folder.fold_ty(t), m, folder.fold_expr(e))
+ ItemKind::Static(t, m, e) => {
+ ItemKind::Static(folder.fold_ty(t), m, folder.fold_expr(e))
}
- ItemConst(t, e) => {
- ItemConst(folder.fold_ty(t), folder.fold_expr(e))
+ ItemKind::Const(t, e) => {
+ ItemKind::Const(folder.fold_ty(t), folder.fold_expr(e))
}
- ItemFn(decl, unsafety, constness, abi, generics, body) => {
- ItemFn(
+ ItemKind::Fn(decl, unsafety, constness, abi, generics, body) => {
+ ItemKind::Fn(
folder.fold_fn_decl(decl),
unsafety,
constness,
folder.fold_block(body)
)
}
- ItemMod(m) => ItemMod(folder.fold_mod(m)),
- ItemForeignMod(nm) => ItemForeignMod(folder.fold_foreign_mod(nm)),
- ItemTy(t, generics) => {
- ItemTy(folder.fold_ty(t), folder.fold_generics(generics))
+ ItemKind::Mod(m) => ItemKind::Mod(folder.fold_mod(m)),
+ ItemKind::ForeignMod(nm) => ItemKind::ForeignMod(folder.fold_foreign_mod(nm)),
+ ItemKind::Ty(t, generics) => {
+ ItemKind::Ty(folder.fold_ty(t), folder.fold_generics(generics))
}
- ItemEnum(enum_definition, generics) => {
- ItemEnum(
+ ItemKind::Enum(enum_definition, generics) => {
+ ItemKind::Enum(
ast::EnumDef {
variants: enum_definition.variants.move_map(|x| folder.fold_variant(x)),
},
folder.fold_generics(generics))
}
- ItemStruct(struct_def, generics) => {
+ ItemKind::Struct(struct_def, generics) => {
let struct_def = folder.fold_variant_data(struct_def);
- ItemStruct(struct_def, folder.fold_generics(generics))
+ ItemKind::Struct(struct_def, folder.fold_generics(generics))
}
- ItemDefaultImpl(unsafety, ref trait_ref) => {
- ItemDefaultImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone()))
+ ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
+ ItemKind::DefaultImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone()))
}
- ItemImpl(unsafety, polarity, generics, ifce, ty, impl_items) => {
+ ItemKind::Impl(unsafety, polarity, generics, ifce, ty, impl_items) => {
let new_impl_items = impl_items.move_flat_map(|item| {
folder.fold_impl_item(item)
});
Some(folder.fold_trait_ref((*trait_ref).clone()))
}
};
- ItemImpl(unsafety,
+ ItemKind::Impl(unsafety,
polarity,
folder.fold_generics(generics),
ifce,
folder.fold_ty(ty),
new_impl_items)
}
- ItemTrait(unsafety, generics, bounds, items) => {
+ ItemKind::Trait(unsafety, generics, bounds, items) => {
let bounds = folder.fold_bounds(bounds);
let items = items.move_flat_map(|item| {
folder.fold_trait_item(item)
});
- ItemTrait(unsafety,
+ ItemKind::Trait(unsafety,
folder.fold_generics(generics),
bounds,
items)
}
- ItemMac(m) => ItemMac(folder.fold_mac(m)),
+ ItemKind::Mac(m) => ItemKind::Mac(folder.fold_mac(m)),
}
}
id: ast::DUMMY_NODE_ID,
vis: ast::Public,
span: span,
- node: ast::ItemMod(module),
+ node: ast::ItemKind::Mod(module),
})).into_iter();
let (module, attrs, span) = match items.next() {
"a crate cannot expand to more than one item");
item.and_then(|ast::Item { attrs, span, node, .. }| {
match node {
- ast::ItemMod(m) => (m, attrs, span),
+ ast::ItemKind::Mod(m) => (m, attrs, span),
_ => panic!("fold converted a module to not a module"),
}
})
pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}: Item,
folder: &mut T) -> Item {
let id = folder.new_id(id);
- let node = folder.fold_item_underscore(node);
+ let node = folder.fold_item_kind(node);
let ident = match node {
// The node may have changed, recompute the "pretty" impl name.
- ItemImpl(_, _, _, ref maybe_trait, ref ty, _) => {
+ ItemKind::Impl(_, _, _, ref maybe_trait, ref ty, _) => {
ast_util::impl_pretty_name(maybe_trait, Some(&**ty))
}
_ => ident
P(ast::Item{ident:str_to_ident("a"),
attrs:Vec::new(),
id: ast::DUMMY_NODE_ID,
- node: ast::ItemFn(P(ast::FnDecl {
+ node: ast::ItemKind::Fn(P(ast::FnDecl {
inputs: vec!(ast::Arg{
ty: P(ast::Ty{id: ast::DUMMY_NODE_ID,
node: ast::TyKind::Path(None, ast::Path{
use ast::{Expr, ExprKind};
use ast::{Field, FnDecl};
use ast::{ForeignItem, ForeignItemKind, FunctionRetTy};
-use ast::{Ident, Inherited, ImplItem, Item, Item_, ItemStatic};
-use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst};
-use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, ItemDefaultImpl};
-use ast::{ItemExternCrate, ItemUse};
+use ast::{Ident, Inherited, ImplItem, Item, ItemKind};
use ast::{Lit, LitKind, UintTy};
use ast::Local;
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
}
}
-type ItemInfo = (Ident, Item_, Option<Vec<Attribute> >);
+type ItemInfo = (Ident, ItemKind, Option<Vec<Attribute> >);
/// How to parse a path. There are four different kinds of paths, all of which
/// are parsed somewhat differently.
P(spanned(lo, hi, DeclKind::Item(
self.mk_item(
lo, hi, id /*id is good here*/,
- ItemMac(spanned(lo, hi,
+ ItemKind::Mac(spanned(lo, hi,
Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT })),
Inherited, attrs)))),
ast::DUMMY_NODE_ID))
}
fn mk_item(&mut self, lo: BytePos, hi: BytePos, ident: Ident,
- node: Item_, vis: Visibility,
+ node: ItemKind, vis: Visibility,
attrs: Vec<Attribute>) -> P<Item> {
P(Item {
ident: ident,
let decl = try!(self.parse_fn_decl(false));
generics.where_clause = try!(self.parse_where_clause());
let (inner_attrs, body) = try!(self.parse_inner_attrs_and_block());
- Ok((ident, ItemFn(decl, unsafety, constness, abi, generics, body), Some(inner_attrs)))
+ Ok((ident, ItemKind::Fn(decl, unsafety, constness, abi, generics, body), Some(inner_attrs)))
}
/// true if we are looking at `const ID`, false for things like `const fn` etc
tps.where_clause = try!(self.parse_where_clause());
let meths = try!(self.parse_trait_items());
- Ok((ident, ItemTrait(unsafety, tps, bounds, meths), None))
+ Ok((ident, ItemKind::Trait(unsafety, tps, bounds, meths), None))
}
/// Parses items implementations variants
try!(self.expect(&token::OpenDelim(token::Brace)));
try!(self.expect(&token::CloseDelim(token::Brace)));
Ok((ast_util::impl_pretty_name(&opt_trait, None),
- ItemDefaultImpl(unsafety, opt_trait.unwrap()), None))
+ ItemKind::DefaultImpl(unsafety, opt_trait.unwrap()), None))
} else {
if opt_trait.is_some() {
ty = try!(self.parse_ty_sum());
}
Ok((ast_util::impl_pretty_name(&opt_trait, Some(&*ty)),
- ItemImpl(unsafety, polarity, generics, opt_trait, ty, impl_items),
+ ItemKind::Impl(unsafety, polarity, generics, opt_trait, ty, impl_items),
Some(attrs)))
}
}
name, found `{}`", token_str)))
};
- Ok((class_name, ItemStruct(vdata, generics), None))
+ Ok((class_name, ItemKind::Struct(vdata, generics), None))
}
pub fn parse_record_struct_body(&mut self,
let e = try!(self.parse_expr());
try!(self.commit_expr_expecting(&*e, token::Semi));
let item = match m {
- Some(m) => ItemStatic(ty, m, e),
- None => ItemConst(ty, e),
+ Some(m) => ItemKind::Static(ty, m, e),
+ None => ItemKind::Const(ty, e),
};
Ok((id, item, None))
}
let m = try!(self.parse_mod_items(&token::CloseDelim(token::Brace), mod_inner_lo));
self.owns_directory = old_owns_directory;
self.pop_mod_path();
- Ok((id, ItemMod(m), Some(attrs)))
+ Ok((id, ItemKind::Mod(m), Some(attrs)))
}
}
id: ast::Ident,
outer_attrs: &[ast::Attribute],
id_sp: Span)
- -> PResult<'a, (ast::Item_, Vec<ast::Attribute> )> {
+ -> PResult<'a, (ast::ItemKind, Vec<ast::Attribute> )> {
let ModulePathSuccess { path, owns_directory } = try!(self.submod_path(id,
outer_attrs,
id_sp));
path: PathBuf,
owns_directory: bool,
name: String,
- id_sp: Span) -> PResult<'a, (ast::Item_, Vec<ast::Attribute> )> {
+ id_sp: Span) -> PResult<'a, (ast::ItemKind, Vec<ast::Attribute> )> {
let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
match included_mod_stack.iter().position(|p| *p == path) {
Some(i) => {
let mod_attrs = try!(p0.parse_inner_attributes());
let m0 = try!(p0.parse_mod_items(&token::Eof, mod_inner_lo));
self.sess.included_mod_stack.borrow_mut().pop();
- Ok((ast::ItemMod(m0), mod_attrs))
+ Ok((ast::ItemKind::Mod(m0), mod_attrs))
}
/// Parse a function declaration from a foreign module
Ok(self.mk_item(lo,
last_span.hi,
ident,
- ItemExternCrate(maybe_path),
+ ItemKind::ExternCrate(maybe_path),
visibility,
attrs))
}
Ok(self.mk_item(lo,
last_span.hi,
special_idents::invalid,
- ItemForeignMod(m),
+ ItemKind::ForeignMod(m),
visibility,
attrs))
}
try!(self.expect(&token::Eq));
let ty = try!(self.parse_ty_sum());
try!(self.expect(&token::Semi));
- Ok((ident, ItemTy(ty, tps), None))
+ Ok((ident, ItemKind::Ty(ty, tps), None))
}
/// Parse the part of an "enum" decl following the '{'
try!(self.expect(&token::OpenDelim(token::Brace)));
let enum_definition = try!(self.parse_enum_def(&generics));
- Ok((id, ItemEnum(enum_definition, generics), None))
+ Ok((id, ItemKind::Enum(enum_definition, generics), None))
}
/// Parses a string as an ABI spec on an extern type or module. Consumes
if self.eat_keyword(keywords::Use) {
// USE ITEM
- let item_ = ItemUse(try!(self.parse_view_path()));
+ let item_ = ItemKind::Use(try!(self.parse_view_path()));
try!(self.expect(&token::Semi));
let last_span = self.last_span;
}
}
- let item_ = ItemMac(m);
+ let item_ = ItemKind::Mac(m);
let last_span = self.last_span;
let item = self.mk_item(lo,
last_span.hi,
try!(self.print_outer_attributes(&item.attrs));
try!(self.ann.pre(self, NodeItem(item)));
match item.node {
- ast::ItemExternCrate(ref optional_path) => {
+ ast::ItemKind::ExternCrate(ref optional_path) => {
try!(self.head(&visibility_qualified(item.vis,
"extern crate")));
if let Some(p) = *optional_path {
try!(self.end()); // end inner head-block
try!(self.end()); // end outer head-block
}
- ast::ItemUse(ref vp) => {
+ ast::ItemKind::Use(ref vp) => {
try!(self.head(&visibility_qualified(item.vis,
"use")));
try!(self.print_view_path(&**vp));
try!(self.end()); // end inner head-block
try!(self.end()); // end outer head-block
}
- ast::ItemStatic(ref ty, m, ref expr) => {
+ ast::ItemKind::Static(ref ty, m, ref expr) => {
try!(self.head(&visibility_qualified(item.vis,
"static")));
if m == ast::MutMutable {
try!(word(&mut self.s, ";"));
try!(self.end()); // end the outer cbox
}
- ast::ItemConst(ref ty, ref expr) => {
+ ast::ItemKind::Const(ref ty, ref expr) => {
try!(self.head(&visibility_qualified(item.vis,
"const")));
try!(self.print_ident(item.ident));
try!(word(&mut self.s, ";"));
try!(self.end()); // end the outer cbox
}
- ast::ItemFn(ref decl, unsafety, constness, abi, ref typarams, ref body) => {
+ ast::ItemKind::Fn(ref decl, unsafety, constness, abi, ref typarams, ref body) => {
try!(self.head(""));
try!(self.print_fn(
decl,
try!(word(&mut self.s, " "));
try!(self.print_block_with_attrs(&**body, &item.attrs));
}
- ast::ItemMod(ref _mod) => {
+ ast::ItemKind::Mod(ref _mod) => {
try!(self.head(&visibility_qualified(item.vis,
"mod")));
try!(self.print_ident(item.ident));
try!(self.print_mod(_mod, &item.attrs));
try!(self.bclose(item.span));
}
- ast::ItemForeignMod(ref nmod) => {
+ ast::ItemKind::ForeignMod(ref nmod) => {
try!(self.head("extern"));
try!(self.word_nbsp(&nmod.abi.to_string()));
try!(self.bopen());
try!(self.print_foreign_mod(nmod, &item.attrs));
try!(self.bclose(item.span));
}
- ast::ItemTy(ref ty, ref params) => {
+ ast::ItemKind::Ty(ref ty, ref params) => {
try!(self.ibox(INDENT_UNIT));
try!(self.ibox(0));
try!(self.word_nbsp(&visibility_qualified(item.vis, "type")));
try!(word(&mut self.s, ";"));
try!(self.end()); // end the outer ibox
}
- ast::ItemEnum(ref enum_definition, ref params) => {
+ ast::ItemKind::Enum(ref enum_definition, ref params) => {
try!(self.print_enum_def(
enum_definition,
params,
item.vis
));
}
- ast::ItemStruct(ref struct_def, ref generics) => {
+ ast::ItemKind::Struct(ref struct_def, ref generics) => {
try!(self.head(&visibility_qualified(item.vis,"struct")));
try!(self.print_struct(&struct_def, generics, item.ident, item.span, true));
}
- ast::ItemDefaultImpl(unsafety, ref trait_ref) => {
+ ast::ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
try!(self.head(""));
try!(self.print_visibility(item.vis));
try!(self.print_unsafety(unsafety));
try!(self.bopen());
try!(self.bclose(item.span));
}
- ast::ItemImpl(unsafety,
+ ast::ItemKind::Impl(unsafety,
polarity,
ref generics,
ref opt_trait,
}
try!(self.bclose(item.span));
}
- ast::ItemTrait(unsafety, ref generics, ref bounds, ref trait_items) => {
+ ast::ItemKind::Trait(unsafety, ref generics, ref bounds, ref trait_items) => {
try!(self.head(""));
try!(self.print_visibility(item.vis));
try!(self.print_unsafety(unsafety));
}
try!(self.bclose(item.span));
}
- ast::ItemMac(codemap::Spanned { ref node, .. }) => {
+ ast::ItemKind::Mac(codemap::Spanned { ref node, .. }) => {
try!(self.print_visibility(item.vis));
try!(self.print_path(&node.path, false, 0));
try!(word(&mut self.s, "! "));
try!(self.print_associated_type(ii.ident, None, Some(ty)));
}
ast::ImplItemKind::Macro(codemap::Spanned { ref node, .. }) => {
- // code copied from ItemMac:
+ // code copied from ItemKind::Mac:
try!(self.print_path(&node.path, false, 0));
try!(word(&mut self.s, "! "));
try!(self.cbox(INDENT_UNIT));
attrs: vec!(
attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(
InternedString::new("macro_use")))),
- node: ast::ItemExternCrate(Some(self.crate_name)),
+ node: ast::ItemKind::ExternCrate(Some(self.crate_name)),
vis: ast::Inherited,
span: DUMMY_SP
}));
mod_.items.insert(0, P(ast::Item {
id: ast::DUMMY_NODE_ID,
ident: special_idents::invalid,
- node: ast::ItemUse(vp),
+ node: ast::ItemKind::Use(vp),
attrs: vec![ast::Attribute {
span: self.span,
node: ast::Attribute_ {
let i = if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) {
match i.node {
- ast::ItemFn(_, ast::Unsafety::Unsafe, _, _, _, _) => {
+ ast::ItemKind::Fn(_, ast::Unsafety::Unsafe, _, _, _, _) => {
let diag = self.cx.span_diagnostic;
panic!(diag.span_fatal(i.span, "unsafe functions cannot be used for tests"));
}
// We don't want to recurse into anything other than mods, since
// mods or tests inside of functions will break things
let res = match i.node {
- ast::ItemMod(..) => fold::noop_fold_item(i, self),
+ ast::ItemKind::Mod(..) => fold::noop_fold_item(i, self),
_ => SmallVector::one(i),
};
if ident.name != token::special_idents::invalid.name {
ident: sym.clone(),
attrs: Vec::new(),
id: ast::DUMMY_NODE_ID,
- node: ast::ItemMod(reexport_mod),
+ node: ast::ItemKind::Mod(reexport_mod),
vis: ast::Public,
span: DUMMY_SP,
});
fn has_test_signature(i: &ast::Item) -> HasTestSignature {
match i.node {
- ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
+ ast::ItemKind::Fn(ref decl, _, _, _, ref generics, _) => {
let no_output = match decl.output {
ast::FunctionRetTy::Default(..) => true,
ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyKind::Tup(vec![]) => true,
fn has_test_signature(i: &ast::Item) -> bool {
match i.node {
- ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
+ ast::ItemKind::Fn(ref decl, _, _, _, ref generics, _) => {
let input_cnt = decl.inputs.len();
let no_output = match decl.output {
ast::FunctionRetTy::Default(..) => true,
fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
let id_test = token::str_to_ident("test");
let (vi, vis, ident) = if cx.is_test_crate {
- (ast::ItemUse(
+ (ast::ItemKind::Use(
P(nospan(ast::ViewPathSimple(id_test,
path_node(vec!(id_test)))))),
ast::Public, token::special_idents::invalid)
} else {
- (ast::ItemExternCrate(None), ast::Inherited, id_test)
+ (ast::ItemKind::ExternCrate(None), ast::Inherited, id_test)
};
P(ast::Item {
id: ast::DUMMY_NODE_ID,
// pub fn main() { ... }
let main_ret_ty = ecx.ty(sp, ast::TyKind::Tup(vec![]));
let main_body = ecx.block_all(sp, vec![call_test_main], None);
- let main = ast::ItemFn(ecx.fn_decl(vec![], main_ret_ty),
+ let main = ast::ItemKind::Fn(ecx.fn_decl(vec![], main_ret_ty),
ast::Unsafety::Normal,
ast::Constness::NotConst,
::abi::Abi::Rust, ast::Generics::default(), main_body);
inner: DUMMY_SP,
items: vec![import, mainfn, tests],
};
- let item_ = ast::ItemMod(testmod);
+ let item_ = ast::ItemKind::Mod(testmod);
let mod_ident = token::gensym_ident("__test");
let item = P(ast::Item {
id: ast::DUMMY_NODE_ID,
ident: token::special_idents::invalid,
attrs: vec![],
- node: ast::ItemUse(P(use_path)),
+ node: ast::ItemKind::Use(P(use_path)),
vis: ast::Inherited,
span: DUMMY_SP
})
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
visitor.visit_ident(item.span, item.ident);
match item.node {
- ItemExternCrate(opt_name) => {
+ ItemKind::ExternCrate(opt_name) => {
walk_opt_name(visitor, item.span, opt_name)
}
- ItemUse(ref vp) => {
+ ItemKind::Use(ref vp) => {
match vp.node {
ViewPathSimple(ident, ref path) => {
visitor.visit_ident(vp.span, ident);
}
}
}
- ItemStatic(ref typ, _, ref expr) |
- ItemConst(ref typ, ref expr) => {
+ ItemKind::Static(ref typ, _, ref expr) |
+ ItemKind::Const(ref typ, ref expr) => {
visitor.visit_ty(typ);
visitor.visit_expr(expr);
}
- ItemFn(ref declaration, unsafety, constness, abi, ref generics, ref body) => {
+ ItemKind::Fn(ref declaration, unsafety, constness, abi, ref generics, ref body) => {
visitor.visit_fn(FnKind::ItemFn(item.ident, generics, unsafety,
constness, abi, item.vis),
declaration,
item.span,
item.id)
}
- ItemMod(ref module) => {
+ ItemKind::Mod(ref module) => {
visitor.visit_mod(module, item.span, item.id)
}
- ItemForeignMod(ref foreign_module) => {
+ ItemKind::ForeignMod(ref foreign_module) => {
walk_list!(visitor, visit_foreign_item, &foreign_module.items);
}
- ItemTy(ref typ, ref type_parameters) => {
+ ItemKind::Ty(ref typ, ref type_parameters) => {
visitor.visit_ty(typ);
visitor.visit_generics(type_parameters)
}
- ItemEnum(ref enum_definition, ref type_parameters) => {
+ ItemKind::Enum(ref enum_definition, ref type_parameters) => {
visitor.visit_generics(type_parameters);
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
}
- ItemDefaultImpl(_, ref trait_ref) => {
+ ItemKind::DefaultImpl(_, ref trait_ref) => {
visitor.visit_trait_ref(trait_ref)
}
- ItemImpl(_, _,
+ ItemKind::Impl(_, _,
ref type_parameters,
ref opt_trait_reference,
ref typ,
visitor.visit_ty(typ);
walk_list!(visitor, visit_impl_item, impl_items);
}
- ItemStruct(ref struct_definition, ref generics) => {
+ ItemKind::Struct(ref struct_definition, ref generics) => {
visitor.visit_generics(generics);
visitor.visit_variant_data(struct_definition, item.ident,
generics, item.id, item.span);
}
- ItemTrait(_, ref generics, ref bounds, ref methods) => {
+ ItemKind::Trait(_, ref generics, ref bounds, ref methods) => {
visitor.visit_generics(generics);
walk_list!(visitor, visit_ty_param_bound, bounds);
walk_list!(visitor, visit_trait_item, methods);
}
- ItemMac(ref mac) => visitor.visit_mac(mac),
+ ItemKind::Mac(ref mac) => visitor.visit_mac(mac),
}
walk_list!(visitor, visit_attribute, &item.attrs);
}
match *item {
Annotatable::Item(ref item) => {
let newitem = match item.node {
- ast::ItemStruct(ref struct_def, ref generics) => {
+ ast::ItemKind::Struct(ref struct_def, ref generics) => {
self.expand_struct_def(cx,
&struct_def,
item.ident,
generics)
}
- ast::ItemEnum(ref enum_def, ref generics) => {
+ ast::ItemKind::Enum(ref enum_def, ref generics) => {
self.expand_enum_def(cx,
enum_def,
&item.attrs,
self.span,
ident,
a,
- ast::ItemImpl(unsafety,
- ast::ImplPolarity::Positive,
- trait_generics,
- opt_trait_ref,
- self_type,
- methods.into_iter().chain(associated_types).collect()))
+ ast::ItemKind::Impl(unsafety,
+ ast::ImplPolarity::Positive,
+ trait_generics,
+ opt_trait_ref,
+ self_type,
+ methods.into_iter().chain(associated_types).collect()))
}
fn expand_struct_def(&self,
ast::MutImmutable);
let slice = ecx.expr_vec_slice(sp, pieces);
// static instead of const to speed up codegen by not requiring this to be inlined
- let st = ast::ItemStatic(ty, ast::MutImmutable, slice);
+ let st = ast::ItemKind::Static(ty, ast::MutImmutable, slice);
let name = ecx.ident_of(name);
let item = ecx.item(sp, name, vec![], st);
extern crate rustc;
extern crate rustc_plugin;
-use syntax::ast::{self, TokenTree, Item, MetaItem, ImplItem, TraitItem};
+use syntax::ast::{self, TokenTree, Item, MetaItem, ImplItem, TraitItem, ItemKind};
use syntax::codemap::Span;
use syntax::ext::base::*;
use syntax::parse::{self, token};
Annotatable::ImplItem(it) => {
quote_item!(cx, impl X { fn foo(&self) -> i32 { 42 } }).unwrap().and_then(|i| {
match i.node {
- ast::ItemImpl(_, _, _, _, _, mut items) => {
+ ItemKind::Impl(_, _, _, _, _, mut items) => {
Annotatable::ImplItem(items.pop().expect("impl method not found"))
}
_ => unreachable!("impl parsed to something other than impl")
Annotatable::TraitItem(it) => {
quote_item!(cx, trait X { fn foo(&self) -> i32 { 0 } }).unwrap().and_then(|i| {
match i.node {
- ast::ItemTrait(_, _, _, mut items) => {
+ ItemKind::Trait(_, _, _, mut items) => {
Annotatable::TraitItem(items.pop().expect("trait method not found"))
}
_ => unreachable!("trait parsed to something other than trait")