Skip to content

Commit dfe35da

Browse files
committed
[breaking-change] don't glob export ast::TraitItemKind variants
1 parent 73fa9b2 commit dfe35da

File tree

10 files changed

+38
-40
lines changed

10 files changed

+38
-40
lines changed

src/librustc_driver/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ impl fold::Folder for ReplaceBodyWithLoop {
616616

617617
fn fold_trait_item(&mut self, i: P<ast::TraitItem>) -> SmallVector<P<ast::TraitItem>> {
618618
match i.node {
619-
ast::ConstTraitItem(..) => {
619+
ast::TraitItemKind::Const(..) => {
620620
self.within_static_or_const = true;
621621
let ret = fold::noop_fold_trait_item(i, self);
622622
self.within_static_or_const = false;

src/librustc_front/lowering.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,15 @@ pub fn lower_trait_item(lctx: &LoweringContext, i: &TraitItem) -> hir::TraitItem
728728
name: i.ident.name,
729729
attrs: lower_attrs(lctx, &i.attrs),
730730
node: match i.node {
731-
ConstTraitItem(ref ty, ref default) => {
731+
TraitItemKind::Const(ref ty, ref default) => {
732732
hir::ConstTraitItem(lower_ty(lctx, ty),
733733
default.as_ref().map(|x| lower_expr(lctx, x)))
734734
}
735-
MethodTraitItem(ref sig, ref body) => {
735+
TraitItemKind::Method(ref sig, ref body) => {
736736
hir::MethodTraitItem(lower_method_sig(lctx, sig),
737737
body.as_ref().map(|x| lower_block(lctx, x)))
738738
}
739-
TypeTraitItem(ref bounds, ref default) => {
739+
TraitItemKind::Type(ref bounds, ref default) => {
740740
hir::TypeTraitItem(lower_bounds(lctx, bounds),
741741
default.as_ref().map(|x| lower_ty(lctx, x)))
742742
}

src/librustc_trans/save/dump_csv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,22 +1020,22 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
10201020
fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
10211021
self.process_macro_use(trait_item.span, trait_item.id);
10221022
match trait_item.node {
1023-
ast::ConstTraitItem(ref ty, Some(ref expr)) => {
1023+
ast::TraitItemKind::Const(ref ty, Some(ref expr)) => {
10241024
self.process_const(trait_item.id,
10251025
trait_item.ident.name,
10261026
trait_item.span,
10271027
&*ty,
10281028
&*expr);
10291029
}
1030-
ast::MethodTraitItem(ref sig, ref body) => {
1030+
ast::TraitItemKind::Method(ref sig, ref body) => {
10311031
self.process_method(sig,
10321032
body.as_ref().map(|x| &**x),
10331033
trait_item.id,
10341034
trait_item.ident.name,
10351035
trait_item.span);
10361036
}
1037-
ast::ConstTraitItem(_, None) |
1038-
ast::TypeTraitItem(..) => {}
1037+
ast::TraitItemKind::Const(_, None) |
1038+
ast::TraitItemKind::Type(..) => {}
10391039
}
10401040
}
10411041

src/libsyntax/ast.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub use self::Pat_::*;
1414
pub use self::PathListItem_::*;
1515
pub use self::StrStyle::*;
1616
pub use self::StructFieldKind::*;
17-
pub use self::TraitItem_::*;
1817
pub use self::TyParamBound::*;
1918
pub use self::UnsafeSource::*;
2019
pub use self::ViewPath_::*;
@@ -1324,15 +1323,15 @@ pub struct TraitItem {
13241323
pub id: NodeId,
13251324
pub ident: Ident,
13261325
pub attrs: Vec<Attribute>,
1327-
pub node: TraitItem_,
1326+
pub node: TraitItemKind,
13281327
pub span: Span,
13291328
}
13301329

13311330
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1332-
pub enum TraitItem_ {
1333-
ConstTraitItem(P<Ty>, Option<P<Expr>>),
1334-
MethodTraitItem(MethodSig, Option<P<Block>>),
1335-
TypeTraitItem(TyParamBounds, Option<P<Ty>>),
1331+
pub enum TraitItemKind {
1332+
Const(P<Ty>, Option<P<Expr>>),
1333+
Method(MethodSig, Option<P<Block>>),
1334+
Type(TyParamBounds, Option<P<Ty>>),
13361335
}
13371336

13381337
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]

src/libsyntax/ext/expand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,14 +919,14 @@ fn expand_annotatable(a: Annotatable,
919919
},
920920

921921
Annotatable::TraitItem(it) => match it.node {
922-
ast::MethodTraitItem(_, Some(_)) => SmallVector::one(it.map(|ti| ast::TraitItem {
922+
ast::TraitItemKind::Method(_, Some(_)) => SmallVector::one(it.map(|ti| ast::TraitItem {
923923
id: ti.id,
924924
ident: ti.ident,
925925
attrs: ti.attrs,
926926
node: match ti.node {
927-
ast::MethodTraitItem(sig, Some(body)) => {
927+
ast::TraitItemKind::Method(sig, Some(body)) => {
928928
let (sig, body) = expand_and_rename_method(sig, body, fld);
929-
ast::MethodTraitItem(sig, Some(body))
929+
ast::TraitItemKind::Method(sig, Some(body))
930930
}
931931
_ => unreachable!()
932932
},

src/libsyntax/feature_gate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,17 +1071,17 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
10711071

10721072
fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) {
10731073
match ti.node {
1074-
ast::ConstTraitItem(..) => {
1074+
ast::TraitItemKind::Const(..) => {
10751075
self.gate_feature("associated_consts",
10761076
ti.span,
10771077
"associated constants are experimental")
10781078
}
1079-
ast::MethodTraitItem(ref sig, _) => {
1079+
ast::TraitItemKind::Method(ref sig, _) => {
10801080
if sig.constness == ast::Constness::Const {
10811081
self.gate_feature("const_fn", ti.span, "const fn is unstable");
10821082
}
10831083
}
1084-
ast::TypeTraitItem(_, Some(_)) => {
1084+
ast::TraitItemKind::Type(_, Some(_)) => {
10851085
self.gate_feature("associated_type_defaults", ti.span,
10861086
"associated type defaults are unstable");
10871087
}

src/libsyntax/fold.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -969,16 +969,16 @@ pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>, folder: &mut T)
969969
ident: folder.fold_ident(ident),
970970
attrs: fold_attrs(attrs, folder),
971971
node: match node {
972-
ConstTraitItem(ty, default) => {
973-
ConstTraitItem(folder.fold_ty(ty),
972+
TraitItemKind::Const(ty, default) => {
973+
TraitItemKind::Const(folder.fold_ty(ty),
974974
default.map(|x| folder.fold_expr(x)))
975975
}
976-
MethodTraitItem(sig, body) => {
977-
MethodTraitItem(noop_fold_method_sig(sig, folder),
976+
TraitItemKind::Method(sig, body) => {
977+
TraitItemKind::Method(noop_fold_method_sig(sig, folder),
978978
body.map(|x| folder.fold_block(x)))
979979
}
980-
TypeTraitItem(bounds, default) => {
981-
TypeTraitItem(folder.fold_bounds(bounds),
980+
TraitItemKind::Type(bounds, default) => {
981+
TraitItemKind::Type(folder.fold_bounds(bounds),
982982
default.map(|x| folder.fold_ty(x)))
983983
}
984984
},

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ pub use self::PathParsingMode::*;
1313
use abi::{self, Abi};
1414
use ast::BareFnTy;
1515
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
16-
use ast::{Public, Unsafety};
17-
use ast::{Mod, Arg, Arm, Attribute, BindingMode};
16+
use ast::Unsafety;
17+
use ast::{Mod, Arg, Arm, Attribute, BindingMode, TraitItemKind};
1818
use ast::Block;
1919
use ast::{BlockCheckMode, CaptureBy};
20-
use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
20+
use ast::{Constness, Crate, CrateConfig};
2121
use ast::{Decl, DeclKind};
2222
use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
2323
use ast::{Expr, ExprKind};
@@ -39,7 +39,6 @@ use ast::StrStyle;
3939
use ast::SelfKind;
4040
use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef};
4141
use ast::{Ty, TyKind, TypeBinding, TyParam, TyParamBounds};
42-
use ast::TypeTraitItem;
4342
use ast::UnnamedField;
4443
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
4544
use ast::{Visibility, WhereClause};
@@ -1188,7 +1187,7 @@ impl<'a> Parser<'a> {
11881187
let (name, node) = if p.eat_keyword(keywords::Type) {
11891188
let TyParam {ident, bounds, default, ..} = try!(p.parse_ty_param());
11901189
try!(p.expect(&token::Semi));
1191-
(ident, TypeTraitItem(bounds, default))
1190+
(ident, TraitItemKind::Type(bounds, default))
11921191
} else if p.is_const_item() {
11931192
try!(p.expect_keyword(keywords::Const));
11941193
let ident = try!(p.parse_ident());
@@ -1203,7 +1202,7 @@ impl<'a> Parser<'a> {
12031202
try!(p.expect(&token::Semi));
12041203
None
12051204
};
1206-
(ident, ConstTraitItem(ty, default))
1205+
(ident, TraitItemKind::Const(ty, default))
12071206
} else {
12081207
let (constness, unsafety, abi) = try!(p.parse_fn_front_matter());
12091208

@@ -1247,7 +1246,7 @@ impl<'a> Parser<'a> {
12471246
token_str)[..]))
12481247
}
12491248
};
1250-
(ident, ast::MethodTraitItem(sig, body))
1249+
(ident, ast::TraitItemKind::Method(sig, body))
12511250
};
12521251

12531252
Ok(P(TraitItem {

src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,12 +1552,12 @@ impl<'a> State<'a> {
15521552
try!(self.maybe_print_comment(ti.span.lo));
15531553
try!(self.print_outer_attributes(&ti.attrs));
15541554
match ti.node {
1555-
ast::ConstTraitItem(ref ty, ref default) => {
1555+
ast::TraitItemKind::Const(ref ty, ref default) => {
15561556
try!(self.print_associated_const(ti.ident, &ty,
15571557
default.as_ref().map(|expr| &**expr),
15581558
ast::Inherited));
15591559
}
1560-
ast::MethodTraitItem(ref sig, ref body) => {
1560+
ast::TraitItemKind::Method(ref sig, ref body) => {
15611561
if body.is_some() {
15621562
try!(self.head(""));
15631563
}
@@ -1569,7 +1569,7 @@ impl<'a> State<'a> {
15691569
try!(word(&mut self.s, ";"));
15701570
}
15711571
}
1572-
ast::TypeTraitItem(ref bounds, ref default) => {
1572+
ast::TraitItemKind::Type(ref bounds, ref default) => {
15731573
try!(self.print_associated_type(ti.ident, Some(bounds),
15741574
default.as_ref().map(|ty| &**ty)));
15751575
}

src/libsyntax/visit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,20 +565,20 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
565565
visitor.visit_ident(trait_item.span, trait_item.ident);
566566
walk_list!(visitor, visit_attribute, &trait_item.attrs);
567567
match trait_item.node {
568-
ConstTraitItem(ref ty, ref default) => {
568+
TraitItemKind::Const(ref ty, ref default) => {
569569
visitor.visit_ty(ty);
570570
walk_list!(visitor, visit_expr, default);
571571
}
572-
MethodTraitItem(ref sig, None) => {
572+
TraitItemKind::Method(ref sig, None) => {
573573
visitor.visit_explicit_self(&sig.explicit_self);
574574
visitor.visit_generics(&sig.generics);
575575
walk_fn_decl(visitor, &sig.decl);
576576
}
577-
MethodTraitItem(ref sig, Some(ref body)) => {
577+
TraitItemKind::Method(ref sig, Some(ref body)) => {
578578
visitor.visit_fn(FnKind::Method(trait_item.ident, sig, None), &sig.decl,
579579
body, trait_item.span, trait_item.id);
580580
}
581-
TypeTraitItem(ref bounds, ref default) => {
581+
TraitItemKind::Type(ref bounds, ref default) => {
582582
walk_list!(visitor, visit_ty_param_bound, bounds);
583583
walk_list!(visitor, visit_ty, default);
584584
}

0 commit comments

Comments
 (0)