1
Fork 0

rename ast::ImplItem_::*ImplItem to ast::ImplItemKind::*

This commit is contained in:
Oliver Schneider 2015-11-13 14:15:04 +01:00
parent e36872da5b
commit d09220de13
12 changed files with 47 additions and 48 deletions

View file

@ -236,7 +236,7 @@ impl<'a> FnLikeNode<'a> {
},
map::NodeImplItem(ii) => {
match ii.node {
ast::ImplItem_::Method(ref sig, ref body) => {
ast::ImplItemKind::Method(ref sig, ref body) => {
method(ii.id, ii.name, sig, Some(ii.vis), body, ii.span)
}
_ => {

View file

@ -623,7 +623,7 @@ impl fold::Folder for ReplaceBodyWithLoop {
fn fold_impl_item(&mut self, i: P<ast::ImplItem>) -> SmallVector<P<ast::ImplItem>> {
match i.node {
ast::ConstImplItem(..) => {
ast::ImplItemKind::Const(..) => {
self.within_static_or_const = true;
let ret = fold::noop_fold_impl_item(i, self);
self.within_static_or_const = false;

View file

@ -675,14 +675,14 @@ pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem
attrs: i.attrs.clone(),
vis: lower_visibility(_lctx, i.vis),
node: match i.node {
ConstImplItem(ref ty, ref expr) => {
ImplItemKind::Const(ref ty, ref expr) => {
hir::ImplItemKind::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr))
}
MethodImplItem(ref sig, ref body) => {
ImplItemKind::Method(ref sig, ref body) => {
hir::ImplItemKind::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body))
}
TypeImplItem(ref ty) => hir::ImplItemKind::Type(lower_ty(_lctx, ty)),
MacImplItem(..) => panic!("Shouldn't exist any more"),
ImplItemKind::Type(ref ty) => hir::ImplItemKind::Type(lower_ty(_lctx, ty)),
ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"),
},
span: i.span,
})

View file

@ -992,22 +992,22 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
match impl_item.node {
ast::ConstImplItem(ref ty, ref expr) => {
ast::ImplItemKind::Const(ref ty, ref expr) => {
self.process_const(impl_item.id,
impl_item.ident.name,
impl_item.span,
&ty,
&expr);
}
ast::MethodImplItem(ref sig, ref body) => {
ast::ImplItemKind::Method(ref sig, ref body) => {
self.process_method(sig,
Some(body),
impl_item.id,
impl_item.ident.name,
impl_item.span);
}
ast::TypeImplItem(_) |
ast::MacImplItem(_) => {}
ast::ImplItemKind::Type(_) |
ast::ImplItemKind::Macro(_) => {}
}
}

View file

@ -20,7 +20,6 @@ pub use self::Expr_::*;
pub use self::FloatTy::*;
pub use self::FunctionRetTy::*;
pub use self::ForeignItem_::*;
pub use self::ImplItem_::*;
pub use self::IntTy::*;
pub use self::Item_::*;
pub use self::KleeneOp::*;
@ -1230,16 +1229,16 @@ pub struct ImplItem {
pub ident: Ident,
pub vis: Visibility,
pub attrs: Vec<Attribute>,
pub node: ImplItem_,
pub node: ImplItemKind,
pub span: Span,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum ImplItem_ {
ConstImplItem(P<Ty>, P<Expr>),
MethodImplItem(MethodSig, P<Block>),
TypeImplItem(P<Ty>),
MacImplItem(Mac),
pub enum ImplItemKind {
Const(P<Ty>, P<Expr>),
Method(MethodSig, P<Block>),
Type(P<Ty>),
Macro(Mac),
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]

View file

@ -480,7 +480,7 @@ impl<'a> TraitDef<'a> {
ident: ident,
vis: ast::Inherited,
attrs: Vec::new(),
node: ast::TypeImplItem(type_def.to_ty(cx,
node: ast::ImplItemKind::Type(type_def.to_ty(cx,
self.span,
type_ident,
generics
@ -895,7 +895,7 @@ impl<'a> MethodDef<'a> {
span: trait_.span,
vis: ast::Inherited,
ident: method_ident,
node: ast::MethodImplItem(ast::MethodSig {
node: ast::ImplItemKind::Method(ast::MethodSig {
generics: fn_generics,
abi: abi,
explicit_self: explicit_self,

View file

@ -1030,23 +1030,23 @@ fn expand_item_multi_modifier(mut it: Annotatable,
fn expand_impl_item(ii: P<ast::ImplItem>, fld: &mut MacroExpander)
-> SmallVector<P<ast::ImplItem>> {
match ii.node {
ast::MethodImplItem(..) => SmallVector::one(ii.map(|ii| ast::ImplItem {
ast::ImplItemKind::Method(..) => SmallVector::one(ii.map(|ii| ast::ImplItem {
id: ii.id,
ident: ii.ident,
attrs: ii.attrs,
vis: ii.vis,
node: match ii.node {
ast::MethodImplItem(sig, body) => {
ast::ImplItemKind::Method(sig, body) => {
let (sig, body) = expand_and_rename_method(sig, body, fld);
ast::MethodImplItem(sig, body)
ast::ImplItemKind::Method(sig, body)
}
_ => unreachable!()
},
span: fld.new_span(ii.span)
})),
ast::MacImplItem(_) => {
ast::ImplItemKind::Macro(_) => {
let (span, mac) = ii.and_then(|ii| match ii.node {
ast::MacImplItem(mac) => (ii.span, mac),
ast::ImplItemKind::Macro(mac) => (ii.span, mac),
_ => unreachable!()
});
let maybe_new_items =

View file

@ -998,12 +998,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
fn visit_impl_item(&mut self, ii: &'v ast::ImplItem) {
match ii.node {
ast::ConstImplItem(..) => {
ast::ImplItemKind::Const(..) => {
self.gate_feature("associated_consts",
ii.span,
"associated constants are experimental")
}
ast::MethodImplItem(ref sig, _) => {
ast::ImplItemKind::Method(ref sig, _) => {
if sig.constness == ast::Constness::Const {
self.gate_feature("const_fn", ii.span, "const fn is unstable");
}

View file

@ -1001,15 +1001,15 @@ pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T)
attrs: fold_attrs(attrs, folder),
vis: vis,
node: match node {
ConstImplItem(ty, expr) => {
ConstImplItem(folder.fold_ty(ty), folder.fold_expr(expr))
ast::ImplItemKind::Const(ty, expr) => {
ast::ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr))
}
MethodImplItem(sig, body) => {
MethodImplItem(noop_fold_method_sig(sig, folder),
ast::ImplItemKind::Method(sig, body) => {
ast::ImplItemKind::Method(noop_fold_method_sig(sig, folder),
folder.fold_block(body))
}
TypeImplItem(ty) => TypeImplItem(folder.fold_ty(ty)),
MacImplItem(mac) => MacImplItem(folder.fold_mac(mac))
ast::ImplItemKind::Type(ty) => ast::ImplItemKind::Type(folder.fold_ty(ty)),
ast::ImplItemKind::Macro(mac) => ast::ImplItemKind::Macro(folder.fold_mac(mac))
},
span: folder.new_span(span)
}))

View file

@ -17,7 +17,7 @@ use ast::{Public, Unsafety};
use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue};
use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block};
use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause};
use ast::{Constness, ConstImplItem, ConstTraitItem, Crate, CrateConfig};
use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
use ast::{Decl, DeclItem, DeclLocal, DefaultBlock, DefaultReturn};
use ast::{UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
@ -39,7 +39,7 @@ use ast::{LitStr, LitInt, Local};
use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces};
use ast::{MutImmutable, MutMutable, Mac_};
use ast::{MutTy, BiMul, Mutability};
use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, UnNot};
use ast::{NamedField, UnNeg, NoReturn, UnNot};
use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange};
use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild};
use ast::{PolyTraitRef, QSelf};
@ -52,7 +52,7 @@ use ast::{Ty, Ty_, TypeBinding, TyMac};
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr};
use ast::{TyRptr, TyTup, TyU32, TyVec};
use ast::{TypeImplItem, TypeTraitItem};
use ast::TypeTraitItem;
use ast::{UnnamedField, UnsafeBlock};
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
use ast::{Visibility, WhereClause};
@ -4425,7 +4425,7 @@ impl<'a> Parser<'a> {
try!(self.expect(&token::Eq));
let typ = try!(self.parse_ty_sum());
try!(self.expect(&token::Semi));
(name, TypeImplItem(typ))
(name, ast::ImplItemKind::Type(typ))
} else if self.is_const_item() {
try!(self.expect_keyword(keywords::Const));
let name = try!(self.parse_ident());
@ -4434,7 +4434,7 @@ impl<'a> Parser<'a> {
try!(self.expect(&token::Eq));
let expr = try!(self.parse_expr());
try!(self.commit_expr_expecting(&expr, token::Semi));
(name, ConstImplItem(typ, expr))
(name, ast::ImplItemKind::Const(typ, expr))
} else {
let (name, inner_attrs, node) = try!(self.parse_impl_method(vis));
attrs.extend(inner_attrs);
@ -4464,7 +4464,7 @@ impl<'a> Parser<'a> {
/// Parse a method or a macro invocation in a trait impl.
fn parse_impl_method(&mut self, vis: Visibility)
-> PResult<(Ident, Vec<ast::Attribute>, ast::ImplItem_)> {
-> PResult<(Ident, Vec<ast::Attribute>, ast::ImplItemKind)> {
// code copied from parse_macro_use_or_failure... abstraction!
if !self.token.is_any_keyword()
&& self.look_ahead(1, |t| *t == token::Not)
@ -4490,7 +4490,7 @@ impl<'a> Parser<'a> {
if delim != token::Brace {
try!(self.expect(&token::Semi))
}
Ok((token::special_idents::invalid, vec![], ast::MacImplItem(m)))
Ok((token::special_idents::invalid, vec![], ast::ImplItemKind::Macro(m)))
} else {
let (constness, unsafety, abi) = try!(self.parse_fn_front_matter());
let ident = try!(self.parse_ident());
@ -4500,7 +4500,7 @@ impl<'a> Parser<'a> {
}));
generics.where_clause = try!(self.parse_where_clause());
let (inner_attrs, body) = try!(self.parse_inner_attrs_and_block());
Ok((ident, inner_attrs, MethodImplItem(ast::MethodSig {
Ok((ident, inner_attrs, ast::ImplItemKind::Method(ast::MethodSig {
generics: generics,
abi: abi,
explicit_self: explicit_self,

View file

@ -1576,19 +1576,19 @@ impl<'a> State<'a> {
try!(self.maybe_print_comment(ii.span.lo));
try!(self.print_outer_attributes(&ii.attrs));
match ii.node {
ast::ConstImplItem(ref ty, ref expr) => {
ast::ImplItemKind::Const(ref ty, ref expr) => {
try!(self.print_associated_const(ii.ident, &ty, Some(&expr), ii.vis));
}
ast::MethodImplItem(ref sig, ref body) => {
ast::ImplItemKind::Method(ref sig, ref body) => {
try!(self.head(""));
try!(self.print_method_sig(ii.ident, sig, ii.vis));
try!(self.nbsp());
try!(self.print_block_with_attrs(body, &ii.attrs));
}
ast::TypeImplItem(ref ty) => {
ast::ImplItemKind::Type(ref ty) => {
try!(self.print_associated_type(ii.ident, None, Some(ty)));
}
ast::MacImplItem(codemap::Spanned { ref node, .. }) => {
ast::ImplItemKind::Macro(codemap::Spanned { ref node, .. }) => {
// code copied from ItemMac:
try!(self.print_path(&node.path, false, 0));
try!(word(&mut self.s, "! "));

View file

@ -588,18 +588,18 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
visitor.visit_ident(impl_item.span, impl_item.ident);
walk_list!(visitor, visit_attribute, &impl_item.attrs);
match impl_item.node {
ConstImplItem(ref ty, ref expr) => {
ImplItemKind::Const(ref ty, ref expr) => {
visitor.visit_ty(ty);
visitor.visit_expr(expr);
}
MethodImplItem(ref sig, ref body) => {
ImplItemKind::Method(ref sig, ref body) => {
visitor.visit_fn(FnKind::Method(impl_item.ident, sig, Some(impl_item.vis)), &sig.decl,
body, impl_item.span, impl_item.id);
}
TypeImplItem(ref ty) => {
ImplItemKind::Type(ref ty) => {
visitor.visit_ty(ty);
}
MacImplItem(ref mac) => {
ImplItemKind::Macro(ref mac) => {
visitor.visit_mac(mac);
}
}