[breaking-change] don't glob export ast::TraitItemKind variants
This commit is contained in:
parent
73fa9b2da2
commit
dfe35da6b8
10 changed files with 38 additions and 40 deletions
|
@ -616,7 +616,7 @@ impl fold::Folder for ReplaceBodyWithLoop {
|
||||||
|
|
||||||
fn fold_trait_item(&mut self, i: P<ast::TraitItem>) -> SmallVector<P<ast::TraitItem>> {
|
fn fold_trait_item(&mut self, i: P<ast::TraitItem>) -> SmallVector<P<ast::TraitItem>> {
|
||||||
match i.node {
|
match i.node {
|
||||||
ast::ConstTraitItem(..) => {
|
ast::TraitItemKind::Const(..) => {
|
||||||
self.within_static_or_const = true;
|
self.within_static_or_const = true;
|
||||||
let ret = fold::noop_fold_trait_item(i, self);
|
let ret = fold::noop_fold_trait_item(i, self);
|
||||||
self.within_static_or_const = false;
|
self.within_static_or_const = false;
|
||||||
|
|
|
@ -728,15 +728,15 @@ pub fn lower_trait_item(lctx: &LoweringContext, i: &TraitItem) -> hir::TraitItem
|
||||||
name: i.ident.name,
|
name: i.ident.name,
|
||||||
attrs: lower_attrs(lctx, &i.attrs),
|
attrs: lower_attrs(lctx, &i.attrs),
|
||||||
node: match i.node {
|
node: match i.node {
|
||||||
ConstTraitItem(ref ty, ref default) => {
|
TraitItemKind::Const(ref ty, ref default) => {
|
||||||
hir::ConstTraitItem(lower_ty(lctx, ty),
|
hir::ConstTraitItem(lower_ty(lctx, ty),
|
||||||
default.as_ref().map(|x| lower_expr(lctx, x)))
|
default.as_ref().map(|x| lower_expr(lctx, x)))
|
||||||
}
|
}
|
||||||
MethodTraitItem(ref sig, ref body) => {
|
TraitItemKind::Method(ref sig, ref body) => {
|
||||||
hir::MethodTraitItem(lower_method_sig(lctx, sig),
|
hir::MethodTraitItem(lower_method_sig(lctx, sig),
|
||||||
body.as_ref().map(|x| lower_block(lctx, x)))
|
body.as_ref().map(|x| lower_block(lctx, x)))
|
||||||
}
|
}
|
||||||
TypeTraitItem(ref bounds, ref default) => {
|
TraitItemKind::Type(ref bounds, ref default) => {
|
||||||
hir::TypeTraitItem(lower_bounds(lctx, bounds),
|
hir::TypeTraitItem(lower_bounds(lctx, bounds),
|
||||||
default.as_ref().map(|x| lower_ty(lctx, x)))
|
default.as_ref().map(|x| lower_ty(lctx, x)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1020,22 +1020,22 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
||||||
fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
|
fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
|
||||||
self.process_macro_use(trait_item.span, trait_item.id);
|
self.process_macro_use(trait_item.span, trait_item.id);
|
||||||
match trait_item.node {
|
match trait_item.node {
|
||||||
ast::ConstTraitItem(ref ty, Some(ref expr)) => {
|
ast::TraitItemKind::Const(ref ty, Some(ref expr)) => {
|
||||||
self.process_const(trait_item.id,
|
self.process_const(trait_item.id,
|
||||||
trait_item.ident.name,
|
trait_item.ident.name,
|
||||||
trait_item.span,
|
trait_item.span,
|
||||||
&*ty,
|
&*ty,
|
||||||
&*expr);
|
&*expr);
|
||||||
}
|
}
|
||||||
ast::MethodTraitItem(ref sig, ref body) => {
|
ast::TraitItemKind::Method(ref sig, ref body) => {
|
||||||
self.process_method(sig,
|
self.process_method(sig,
|
||||||
body.as_ref().map(|x| &**x),
|
body.as_ref().map(|x| &**x),
|
||||||
trait_item.id,
|
trait_item.id,
|
||||||
trait_item.ident.name,
|
trait_item.ident.name,
|
||||||
trait_item.span);
|
trait_item.span);
|
||||||
}
|
}
|
||||||
ast::ConstTraitItem(_, None) |
|
ast::TraitItemKind::Const(_, None) |
|
||||||
ast::TypeTraitItem(..) => {}
|
ast::TraitItemKind::Type(..) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ pub use self::Pat_::*;
|
||||||
pub use self::PathListItem_::*;
|
pub use self::PathListItem_::*;
|
||||||
pub use self::StrStyle::*;
|
pub use self::StrStyle::*;
|
||||||
pub use self::StructFieldKind::*;
|
pub use self::StructFieldKind::*;
|
||||||
pub use self::TraitItem_::*;
|
|
||||||
pub use self::TyParamBound::*;
|
pub use self::TyParamBound::*;
|
||||||
pub use self::UnsafeSource::*;
|
pub use self::UnsafeSource::*;
|
||||||
pub use self::ViewPath_::*;
|
pub use self::ViewPath_::*;
|
||||||
|
@ -1324,15 +1323,15 @@ pub struct TraitItem {
|
||||||
pub id: NodeId,
|
pub id: NodeId,
|
||||||
pub ident: Ident,
|
pub ident: Ident,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: Vec<Attribute>,
|
||||||
pub node: TraitItem_,
|
pub node: TraitItemKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub enum TraitItem_ {
|
pub enum TraitItemKind {
|
||||||
ConstTraitItem(P<Ty>, Option<P<Expr>>),
|
Const(P<Ty>, Option<P<Expr>>),
|
||||||
MethodTraitItem(MethodSig, Option<P<Block>>),
|
Method(MethodSig, Option<P<Block>>),
|
||||||
TypeTraitItem(TyParamBounds, Option<P<Ty>>),
|
Type(TyParamBounds, Option<P<Ty>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
|
|
|
@ -919,14 +919,14 @@ fn expand_annotatable(a: Annotatable,
|
||||||
},
|
},
|
||||||
|
|
||||||
Annotatable::TraitItem(it) => match it.node {
|
Annotatable::TraitItem(it) => match it.node {
|
||||||
ast::MethodTraitItem(_, Some(_)) => SmallVector::one(it.map(|ti| ast::TraitItem {
|
ast::TraitItemKind::Method(_, Some(_)) => SmallVector::one(it.map(|ti| ast::TraitItem {
|
||||||
id: ti.id,
|
id: ti.id,
|
||||||
ident: ti.ident,
|
ident: ti.ident,
|
||||||
attrs: ti.attrs,
|
attrs: ti.attrs,
|
||||||
node: match ti.node {
|
node: match ti.node {
|
||||||
ast::MethodTraitItem(sig, Some(body)) => {
|
ast::TraitItemKind::Method(sig, Some(body)) => {
|
||||||
let (sig, body) = expand_and_rename_method(sig, body, fld);
|
let (sig, body) = expand_and_rename_method(sig, body, fld);
|
||||||
ast::MethodTraitItem(sig, Some(body))
|
ast::TraitItemKind::Method(sig, Some(body))
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
},
|
},
|
||||||
|
|
|
@ -1071,17 +1071,17 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||||
|
|
||||||
fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) {
|
fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) {
|
||||||
match ti.node {
|
match ti.node {
|
||||||
ast::ConstTraitItem(..) => {
|
ast::TraitItemKind::Const(..) => {
|
||||||
self.gate_feature("associated_consts",
|
self.gate_feature("associated_consts",
|
||||||
ti.span,
|
ti.span,
|
||||||
"associated constants are experimental")
|
"associated constants are experimental")
|
||||||
}
|
}
|
||||||
ast::MethodTraitItem(ref sig, _) => {
|
ast::TraitItemKind::Method(ref sig, _) => {
|
||||||
if sig.constness == ast::Constness::Const {
|
if sig.constness == ast::Constness::Const {
|
||||||
self.gate_feature("const_fn", ti.span, "const fn is unstable");
|
self.gate_feature("const_fn", ti.span, "const fn is unstable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::TypeTraitItem(_, Some(_)) => {
|
ast::TraitItemKind::Type(_, Some(_)) => {
|
||||||
self.gate_feature("associated_type_defaults", ti.span,
|
self.gate_feature("associated_type_defaults", ti.span,
|
||||||
"associated type defaults are unstable");
|
"associated type defaults are unstable");
|
||||||
}
|
}
|
||||||
|
|
|
@ -969,16 +969,16 @@ pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>, folder: &mut T)
|
||||||
ident: folder.fold_ident(ident),
|
ident: folder.fold_ident(ident),
|
||||||
attrs: fold_attrs(attrs, folder),
|
attrs: fold_attrs(attrs, folder),
|
||||||
node: match node {
|
node: match node {
|
||||||
ConstTraitItem(ty, default) => {
|
TraitItemKind::Const(ty, default) => {
|
||||||
ConstTraitItem(folder.fold_ty(ty),
|
TraitItemKind::Const(folder.fold_ty(ty),
|
||||||
default.map(|x| folder.fold_expr(x)))
|
default.map(|x| folder.fold_expr(x)))
|
||||||
}
|
}
|
||||||
MethodTraitItem(sig, body) => {
|
TraitItemKind::Method(sig, body) => {
|
||||||
MethodTraitItem(noop_fold_method_sig(sig, folder),
|
TraitItemKind::Method(noop_fold_method_sig(sig, folder),
|
||||||
body.map(|x| folder.fold_block(x)))
|
body.map(|x| folder.fold_block(x)))
|
||||||
}
|
}
|
||||||
TypeTraitItem(bounds, default) => {
|
TraitItemKind::Type(bounds, default) => {
|
||||||
TypeTraitItem(folder.fold_bounds(bounds),
|
TraitItemKind::Type(folder.fold_bounds(bounds),
|
||||||
default.map(|x| folder.fold_ty(x)))
|
default.map(|x| folder.fold_ty(x)))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,11 +13,11 @@ pub use self::PathParsingMode::*;
|
||||||
use abi::{self, Abi};
|
use abi::{self, Abi};
|
||||||
use ast::BareFnTy;
|
use ast::BareFnTy;
|
||||||
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
|
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
|
||||||
use ast::{Public, Unsafety};
|
use ast::Unsafety;
|
||||||
use ast::{Mod, Arg, Arm, Attribute, BindingMode};
|
use ast::{Mod, Arg, Arm, Attribute, BindingMode, TraitItemKind};
|
||||||
use ast::Block;
|
use ast::Block;
|
||||||
use ast::{BlockCheckMode, CaptureBy};
|
use ast::{BlockCheckMode, CaptureBy};
|
||||||
use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
|
use ast::{Constness, Crate, CrateConfig};
|
||||||
use ast::{Decl, DeclKind};
|
use ast::{Decl, DeclKind};
|
||||||
use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
|
use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
|
||||||
use ast::{Expr, ExprKind};
|
use ast::{Expr, ExprKind};
|
||||||
|
@ -39,7 +39,6 @@ use ast::StrStyle;
|
||||||
use ast::SelfKind;
|
use ast::SelfKind;
|
||||||
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
|
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
|
||||||
use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds};
|
use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds};
|
||||||
use ast::TypeTraitItem;
|
|
||||||
use ast::UnnamedField;
|
use ast::UnnamedField;
|
||||||
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
|
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
|
||||||
use ast::{Visibility, WhereClause};
|
use ast::{Visibility, WhereClause};
|
||||||
|
@ -1188,7 +1187,7 @@ impl<'a> Parser<'a> {
|
||||||
let (name, node) = if p.eat_keyword(keywords::Type) {
|
let (name, node) = if p.eat_keyword(keywords::Type) {
|
||||||
let TyParam {ident, bounds, default, ..} = try!(p.parse_ty_param());
|
let TyParam {ident, bounds, default, ..} = try!(p.parse_ty_param());
|
||||||
try!(p.expect(&token::Semi));
|
try!(p.expect(&token::Semi));
|
||||||
(ident, TypeTraitItem(bounds, default))
|
(ident, TraitItemKind::Type(bounds, default))
|
||||||
} else if p.is_const_item() {
|
} else if p.is_const_item() {
|
||||||
try!(p.expect_keyword(keywords::Const));
|
try!(p.expect_keyword(keywords::Const));
|
||||||
let ident = try!(p.parse_ident());
|
let ident = try!(p.parse_ident());
|
||||||
|
@ -1203,7 +1202,7 @@ impl<'a> Parser<'a> {
|
||||||
try!(p.expect(&token::Semi));
|
try!(p.expect(&token::Semi));
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
(ident, ConstTraitItem(ty, default))
|
(ident, TraitItemKind::Const(ty, default))
|
||||||
} else {
|
} else {
|
||||||
let (constness, unsafety, abi) = try!(p.parse_fn_front_matter());
|
let (constness, unsafety, abi) = try!(p.parse_fn_front_matter());
|
||||||
|
|
||||||
|
@ -1247,7 +1246,7 @@ impl<'a> Parser<'a> {
|
||||||
token_str)[..]))
|
token_str)[..]))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(ident, ast::MethodTraitItem(sig, body))
|
(ident, ast::TraitItemKind::Method(sig, body))
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(P(TraitItem {
|
Ok(P(TraitItem {
|
||||||
|
|
|
@ -1552,12 +1552,12 @@ impl<'a> State<'a> {
|
||||||
try!(self.maybe_print_comment(ti.span.lo));
|
try!(self.maybe_print_comment(ti.span.lo));
|
||||||
try!(self.print_outer_attributes(&ti.attrs));
|
try!(self.print_outer_attributes(&ti.attrs));
|
||||||
match ti.node {
|
match ti.node {
|
||||||
ast::ConstTraitItem(ref ty, ref default) => {
|
ast::TraitItemKind::Const(ref ty, ref default) => {
|
||||||
try!(self.print_associated_const(ti.ident, &ty,
|
try!(self.print_associated_const(ti.ident, &ty,
|
||||||
default.as_ref().map(|expr| &**expr),
|
default.as_ref().map(|expr| &**expr),
|
||||||
ast::Inherited));
|
ast::Inherited));
|
||||||
}
|
}
|
||||||
ast::MethodTraitItem(ref sig, ref body) => {
|
ast::TraitItemKind::Method(ref sig, ref body) => {
|
||||||
if body.is_some() {
|
if body.is_some() {
|
||||||
try!(self.head(""));
|
try!(self.head(""));
|
||||||
}
|
}
|
||||||
|
@ -1569,7 +1569,7 @@ impl<'a> State<'a> {
|
||||||
try!(word(&mut self.s, ";"));
|
try!(word(&mut self.s, ";"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::TypeTraitItem(ref bounds, ref default) => {
|
ast::TraitItemKind::Type(ref bounds, ref default) => {
|
||||||
try!(self.print_associated_type(ti.ident, Some(bounds),
|
try!(self.print_associated_type(ti.ident, Some(bounds),
|
||||||
default.as_ref().map(|ty| &**ty)));
|
default.as_ref().map(|ty| &**ty)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -565,20 +565,20 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||||
visitor.visit_ident(trait_item.span, trait_item.ident);
|
visitor.visit_ident(trait_item.span, trait_item.ident);
|
||||||
walk_list!(visitor, visit_attribute, &trait_item.attrs);
|
walk_list!(visitor, visit_attribute, &trait_item.attrs);
|
||||||
match trait_item.node {
|
match trait_item.node {
|
||||||
ConstTraitItem(ref ty, ref default) => {
|
TraitItemKind::Const(ref ty, ref default) => {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
walk_list!(visitor, visit_expr, default);
|
walk_list!(visitor, visit_expr, default);
|
||||||
}
|
}
|
||||||
MethodTraitItem(ref sig, None) => {
|
TraitItemKind::Method(ref sig, None) => {
|
||||||
visitor.visit_explicit_self(&sig.explicit_self);
|
visitor.visit_explicit_self(&sig.explicit_self);
|
||||||
visitor.visit_generics(&sig.generics);
|
visitor.visit_generics(&sig.generics);
|
||||||
walk_fn_decl(visitor, &sig.decl);
|
walk_fn_decl(visitor, &sig.decl);
|
||||||
}
|
}
|
||||||
MethodTraitItem(ref sig, Some(ref body)) => {
|
TraitItemKind::Method(ref sig, Some(ref body)) => {
|
||||||
visitor.visit_fn(FnKind::Method(trait_item.ident, sig, None), &sig.decl,
|
visitor.visit_fn(FnKind::Method(trait_item.ident, sig, None), &sig.decl,
|
||||||
body, trait_item.span, trait_item.id);
|
body, trait_item.span, trait_item.id);
|
||||||
}
|
}
|
||||||
TypeTraitItem(ref bounds, ref default) => {
|
TraitItemKind::Type(ref bounds, ref default) => {
|
||||||
walk_list!(visitor, visit_ty_param_bound, bounds);
|
walk_list!(visitor, visit_ty_param_bound, bounds);
|
||||||
walk_list!(visitor, visit_ty, default);
|
walk_list!(visitor, visit_ty, default);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue