[breaking-change] don't glob export ast::Item_ variants
This commit is contained in:
parent
0d6ddd1903
commit
019614f03d
27 changed files with 230 additions and 233 deletions
|
@ -26,9 +26,9 @@ enum Target {
|
|||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -600,16 +600,16 @@ impl ReplaceBodyWithLoop {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -654,21 +654,21 @@ pub fn lower_block(lctx: &LoweringContext, b: &Block) -> P<hir::Block> {
|
|||
})
|
||||
}
|
||||
|
||||
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),
|
||||
|
@ -676,12 +676,12 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
|
|||
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()
|
||||
|
@ -690,15 +690,15 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
|
|||
},
|
||||
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();
|
||||
|
@ -710,7 +710,7 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
|
|||
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),
|
||||
|
@ -718,7 +718,7 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
|
|||
bounds,
|
||||
items)
|
||||
}
|
||||
ItemMac(_) => panic!("Shouldn't still be around"),
|
||||
ItemKind::Mac(_) => panic!("Shouldn't still be around"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -820,7 +820,7 @@ pub fn lower_item_id(_lctx: &LoweringContext, i: &Item) -> hir::ItemId {
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -157,7 +157,7 @@ impl<'a> CrateReader<'a> {
|
|||
|
||||
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 {
|
||||
|
|
|
@ -56,7 +56,7 @@ pub fn read_macro_defs(sess: &Session, cstore: &CStore, krate: &ast::Crate)
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ impl<'a, 'v> Visitor<'v> for MacroLoader<'a> {
|
|||
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;
|
||||
|
|
|
@ -78,10 +78,10 @@ impl<'a, 'v> Visitor<'v> for CheckConstFn<'a> {
|
|||
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)
|
||||
},
|
||||
_ => {},
|
||||
|
|
|
@ -864,9 +864,10 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
|||
|
||||
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);
|
||||
|
@ -950,7 +951,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::ItemExternCrate(ref s) => {
|
||||
ExternCrate(ref s) => {
|
||||
let location = match *s {
|
||||
Some(s) => s.to_string(),
|
||||
None => item.ident.to_string(),
|
||||
|
@ -968,28 +969,28 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
&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);
|
||||
|
@ -998,7 +999,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
self.visit_ty(&**ty);
|
||||
self.process_generic_params(ty_params, item.span, &qualname, item.id);
|
||||
}
|
||||
ast::ItemMac(_) => (),
|
||||
Mac(_) => (),
|
||||
_ => visit::walk_item(self, item),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
|
||||
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);
|
||||
|
@ -243,7 +243,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
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.
|
||||
|
@ -264,7 +264,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
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);
|
||||
|
@ -278,7 +278,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
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();
|
||||
|
@ -295,7 +295,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
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);
|
||||
|
@ -308,7 +308,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
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;
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
// The Rust abstract syntax tree.
|
||||
|
||||
pub use self::Item_::*;
|
||||
pub use self::KleeneOp::*;
|
||||
pub use self::MacStmtStyle::*;
|
||||
pub use self::MetaItem_::*;
|
||||
|
@ -1828,7 +1827,7 @@ pub struct Attribute_ {
|
|||
///
|
||||
/// 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 {
|
||||
|
@ -1956,7 +1955,7 @@ pub struct Item {
|
|||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub id: NodeId,
|
||||
pub node: Item_,
|
||||
pub node: ItemKind,
|
||||
pub vis: Visibility,
|
||||
pub span: Span,
|
||||
}
|
||||
|
@ -1968,32 +1967,32 @@ impl Item {
|
|||
}
|
||||
|
||||
#[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>>),
|
||||
|
@ -2001,35 +2000,35 @@ pub enum Item_ {
|
|||
// 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
|
|||
|
||||
self.operation.visit_id(item.id);
|
||||
match item.node {
|
||||
ItemUse(ref view_path) => {
|
||||
ItemKind::Use(ref view_path) => {
|
||||
match view_path.node {
|
||||
ViewPathSimple(_, _) |
|
||||
ViewPathGlob(_) => {}
|
||||
|
|
|
@ -52,8 +52,8 @@ impl<'a, F> fold::Folder for Context<'a, F> where F: FnMut(&[ast::Attribute]) ->
|
|||
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
|
||||
|
@ -129,26 +129,26 @@ fn fold_item<F>(cx: &mut Context<F>, item: P<ast::Item>) -> SmallVector<P<ast::I
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -167,14 +167,14 @@ fn fold_item_underscore<F>(cx: &mut Context<F>, item: ast::Item_) -> ast::Item_
|
|||
}))
|
||||
}
|
||||
});
|
||||
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
|
||||
|
|
|
@ -226,7 +226,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
|||
ident: name.clone(),
|
||||
attrs: Vec::new(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
node: ast::ItemConst(
|
||||
node: ast::ItemKind::Const(
|
||||
ty,
|
||||
expr,
|
||||
),
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
use attr;
|
||||
use ast::{Item, ItemFn};
|
||||
use ast::{Item, ItemKind};
|
||||
|
||||
pub enum EntryPointType {
|
||||
None,
|
||||
|
@ -23,7 +23,7 @@ pub enum EntryPointType {
|
|||
// 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") {
|
||||
|
|
|
@ -120,7 +120,7 @@ impl<F> MultiItemDecorator for F
|
|||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -213,7 +213,7 @@ pub trait AstBuilder {
|
|||
|
||||
// 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
|
||||
|
@ -951,7 +951,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -974,7 +974,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
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,
|
||||
|
@ -1026,7 +1026,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
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,
|
||||
|
@ -1047,7 +1047,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
|
||||
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,
|
||||
|
@ -1057,7 +1057,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
span,
|
||||
name,
|
||||
attrs,
|
||||
ast::ItemMod(ast::Mod {
|
||||
ast::ItemKind::Mod(ast::Mod {
|
||||
inner: inner_span,
|
||||
items: items,
|
||||
})
|
||||
|
@ -1071,7 +1071,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
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,
|
||||
|
@ -1080,12 +1080,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
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> {
|
||||
|
@ -1125,7 +1125,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
id: ast::DUMMY_NODE_ID,
|
||||
ident: special_idents::invalid,
|
||||
attrs: vec![],
|
||||
node: ast::ItemUse(vp),
|
||||
node: ast::ItemKind::Use(vp),
|
||||
vis: vis,
|
||||
span: sp
|
||||
})
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
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;
|
||||
|
@ -315,17 +315,17 @@ pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander)
|
|||
.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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
|
|||
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")
|
||||
});
|
||||
|
@ -890,10 +890,10 @@ fn expand_annotatable(a: Annotatable,
|
|||
|
||||
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;
|
||||
|
||||
|
@ -1048,7 +1048,7 @@ fn expand_item_multi_modifier(mut it: Annotatable,
|
|||
}
|
||||
}
|
||||
|
||||
// Expansion may have added new ItemModifiers.
|
||||
// Expansion may have added new ItemKind::Modifiers.
|
||||
expand_item_multi_modifier(it, fld)
|
||||
}
|
||||
|
||||
|
@ -1194,8 +1194,8 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> {
|
|||
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>> {
|
||||
|
|
|
@ -855,7 +855,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
|
||||
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 \
|
||||
|
@ -863,7 +863,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
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 \
|
||||
|
@ -888,7 +888,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -907,7 +907,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -928,14 +928,14 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
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",
|
||||
|
|
|
@ -71,8 +71,8 @@ pub trait Folder : Sized {
|
|||
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>> {
|
||||
|
@ -890,20 +890,20 @@ pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> {
|
|||
})
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -912,26 +912,26 @@ pub fn noop_fold_item_underscore<T: Folder>(i: Item_, folder: &mut T) -> Item_ {
|
|||
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)
|
||||
});
|
||||
|
@ -941,24 +941,24 @@ pub fn noop_fold_item_underscore<T: Folder>(i: Item_, folder: &mut T) -> 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)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1025,7 +1025,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, mut exported_mac
|
|||
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() {
|
||||
|
@ -1034,7 +1034,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, mut exported_mac
|
|||
"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"),
|
||||
}
|
||||
})
|
||||
|
@ -1067,10 +1067,10 @@ pub fn noop_fold_item<T: Folder>(i: P<Item>, folder: &mut T) -> SmallVector<P<It
|
|||
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
|
||||
|
|
|
@ -913,7 +913,7 @@ mod tests {
|
|||
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{
|
||||
|
|
|
@ -23,10 +23,7 @@ use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
|
|||
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};
|
||||
|
@ -80,7 +77,7 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -3750,7 +3747,7 @@ impl<'a> Parser<'a> {
|
|||
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))
|
||||
|
@ -4590,7 +4587,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
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,
|
||||
|
@ -4612,7 +4609,7 @@ impl<'a> Parser<'a> {
|
|||
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
|
||||
|
@ -4772,7 +4769,7 @@ impl<'a> Parser<'a> {
|
|||
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
|
||||
|
@ -4835,7 +4832,7 @@ impl<'a> Parser<'a> {
|
|||
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());
|
||||
|
@ -4851,7 +4848,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
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)))
|
||||
}
|
||||
}
|
||||
|
@ -4936,7 +4933,7 @@ impl<'a> Parser<'a> {
|
|||
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,
|
||||
|
@ -5066,8 +5063,8 @@ impl<'a> Parser<'a> {
|
|||
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))
|
||||
}
|
||||
|
@ -5091,7 +5088,7 @@ impl<'a> Parser<'a> {
|
|||
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)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5197,7 +5194,7 @@ impl<'a> Parser<'a> {
|
|||
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));
|
||||
|
@ -5212,7 +5209,7 @@ impl<'a> Parser<'a> {
|
|||
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) => {
|
||||
|
@ -5240,7 +5237,7 @@ impl<'a> Parser<'a> {
|
|||
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
|
||||
|
@ -5315,7 +5312,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(self.mk_item(lo,
|
||||
last_span.hi,
|
||||
ident,
|
||||
ItemExternCrate(maybe_path),
|
||||
ItemKind::ExternCrate(maybe_path),
|
||||
visibility,
|
||||
attrs))
|
||||
}
|
||||
|
@ -5356,7 +5353,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(self.mk_item(lo,
|
||||
last_span.hi,
|
||||
special_idents::invalid,
|
||||
ItemForeignMod(m),
|
||||
ItemKind::ForeignMod(m),
|
||||
visibility,
|
||||
attrs))
|
||||
}
|
||||
|
@ -5369,7 +5366,7 @@ impl<'a> Parser<'a> {
|
|||
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 '{'
|
||||
|
@ -5430,7 +5427,7 @@ impl<'a> Parser<'a> {
|
|||
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
|
||||
|
@ -5488,7 +5485,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
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;
|
||||
|
@ -5804,7 +5801,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
let item_ = ItemMac(m);
|
||||
let item_ = ItemKind::Mac(m);
|
||||
let last_span = self.last_span;
|
||||
let item = self.mk_item(lo,
|
||||
last_span.hi,
|
||||
|
|
|
@ -1117,7 +1117,7 @@ impl<'a> State<'a> {
|
|||
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 {
|
||||
|
@ -1136,7 +1136,7 @@ impl<'a> State<'a> {
|
|||
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));
|
||||
|
@ -1144,7 +1144,7 @@ impl<'a> State<'a> {
|
|||
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 {
|
||||
|
@ -1161,7 +1161,7 @@ impl<'a> State<'a> {
|
|||
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));
|
||||
|
@ -1175,7 +1175,7 @@ impl<'a> State<'a> {
|
|||
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,
|
||||
|
@ -1190,7 +1190,7 @@ impl<'a> State<'a> {
|
|||
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));
|
||||
|
@ -1199,14 +1199,14 @@ impl<'a> State<'a> {
|
|||
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")));
|
||||
|
@ -1221,7 +1221,7 @@ impl<'a> State<'a> {
|
|||
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,
|
||||
|
@ -1230,12 +1230,12 @@ impl<'a> State<'a> {
|
|||
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));
|
||||
|
@ -1247,7 +1247,7 @@ impl<'a> State<'a> {
|
|||
try!(self.bopen());
|
||||
try!(self.bclose(item.span));
|
||||
}
|
||||
ast::ItemImpl(unsafety,
|
||||
ast::ItemKind::Impl(unsafety,
|
||||
polarity,
|
||||
ref generics,
|
||||
ref opt_trait,
|
||||
|
@ -1290,7 +1290,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
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));
|
||||
|
@ -1316,7 +1316,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
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, "! "));
|
||||
|
@ -1596,7 +1596,7 @@ impl<'a> State<'a> {
|
|||
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));
|
||||
|
|
|
@ -89,7 +89,7 @@ impl fold::Folder for CrateInjector {
|
|||
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
|
||||
}));
|
||||
|
@ -149,7 +149,7 @@ impl fold::Folder for PreludeInjector {
|
|||
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_ {
|
||||
|
|
|
@ -125,7 +125,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
|
|||
|
||||
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"));
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
|
|||
// 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 {
|
||||
|
@ -262,7 +262,7 @@ fn mk_reexport_mod(cx: &mut TestCtxt, tests: Vec<ast::Ident>,
|
|||
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,
|
||||
});
|
||||
|
@ -355,7 +355,7 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
|
|||
|
||||
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,
|
||||
|
@ -391,7 +391,7 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
|
|||
|
||||
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,
|
||||
|
@ -453,12 +453,12 @@ mod __test {
|
|||
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,
|
||||
|
@ -496,7 +496,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> {
|
|||
// 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);
|
||||
|
@ -527,7 +527,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<P<ast::Item>>) {
|
|||
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 {
|
||||
|
@ -550,7 +550,7 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<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
|
||||
})
|
||||
|
|
|
@ -230,10 +230,10 @@ pub fn walk_trait_ref<'v,V>(visitor: &mut V,
|
|||
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);
|
||||
|
@ -253,12 +253,12 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
|||
}
|
||||
}
|
||||
}
|
||||
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,
|
||||
|
@ -266,24 +266,24 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
|||
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,
|
||||
|
@ -293,17 +293,17 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -391,13 +391,13 @@ impl<'a> TraitDef<'a> {
|
|||
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,
|
||||
|
@ -637,12 +637,12 @@ impl<'a> TraitDef<'a> {
|
|||
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,
|
||||
|
|
|
@ -453,7 +453,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
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);
|
||||
|
|
|
@ -16,7 +16,7 @@ extern crate syntax;
|
|||
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};
|
||||
|
@ -73,7 +73,7 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt,
|
|||
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")
|
||||
|
@ -83,7 +83,7 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt,
|
|||
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")
|
||||
|
|
Loading…
Add table
Reference in a new issue