Skip to content

Commit 019614f

Browse files
committed
[breaking-change] don't glob export ast::Item_ variants
1 parent 0d6ddd1 commit 019614f

File tree

27 files changed

+230
-233
lines changed

27 files changed

+230
-233
lines changed

src/librustc/front/check_attr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ enum Target {
2626
impl Target {
2727
fn from_item(item: &ast::Item) -> Target {
2828
match item.node {
29-
ast::ItemFn(..) => Target::Fn,
30-
ast::ItemStruct(..) => Target::Struct,
31-
ast::ItemEnum(..) => Target::Enum,
29+
ast::ItemKind::Fn(..) => Target::Fn,
30+
ast::ItemKind::Struct(..) => Target::Struct,
31+
ast::ItemKind::Enum(..) => Target::Enum,
3232
_ => Target::Other,
3333
}
3434
}

src/librustc_driver/pretty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,16 +600,16 @@ impl ReplaceBodyWithLoop {
600600
}
601601

602602
impl fold::Folder for ReplaceBodyWithLoop {
603-
fn fold_item_underscore(&mut self, i: ast::Item_) -> ast::Item_ {
603+
fn fold_item_kind(&mut self, i: ast::ItemKind) -> ast::ItemKind {
604604
match i {
605-
ast::ItemStatic(..) | ast::ItemConst(..) => {
605+
ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => {
606606
self.within_static_or_const = true;
607-
let ret = fold::noop_fold_item_underscore(i, self);
607+
let ret = fold::noop_fold_item_kind(i, self);
608608
self.within_static_or_const = false;
609609
return ret;
610610
}
611611
_ => {
612-
fold::noop_fold_item_underscore(i, self)
612+
fold::noop_fold_item_kind(i, self)
613613
}
614614
}
615615
}

src/librustc_front/lowering.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -654,34 +654,34 @@ pub fn lower_block(lctx: &LoweringContext, b: &Block) -> P<hir::Block> {
654654
})
655655
}
656656

657-
pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
657+
pub fn lower_item_kind(lctx: &LoweringContext, i: &ItemKind) -> hir::Item_ {
658658
match *i {
659-
ItemExternCrate(string) => hir::ItemExternCrate(string),
660-
ItemUse(ref view_path) => {
659+
ItemKind::ExternCrate(string) => hir::ItemExternCrate(string),
660+
ItemKind::Use(ref view_path) => {
661661
hir::ItemUse(lower_view_path(lctx, view_path))
662662
}
663-
ItemStatic(ref t, m, ref e) => {
663+
ItemKind::Static(ref t, m, ref e) => {
664664
hir::ItemStatic(lower_ty(lctx, t),
665665
lower_mutability(lctx, m),
666666
lower_expr(lctx, e))
667667
}
668-
ItemConst(ref t, ref e) => {
668+
ItemKind::Const(ref t, ref e) => {
669669
hir::ItemConst(lower_ty(lctx, t), lower_expr(lctx, e))
670670
}
671-
ItemFn(ref decl, unsafety, constness, abi, ref generics, ref body) => {
671+
ItemKind::Fn(ref decl, unsafety, constness, abi, ref generics, ref body) => {
672672
hir::ItemFn(lower_fn_decl(lctx, decl),
673673
lower_unsafety(lctx, unsafety),
674674
lower_constness(lctx, constness),
675675
abi,
676676
lower_generics(lctx, generics),
677677
lower_block(lctx, body))
678678
}
679-
ItemMod(ref m) => hir::ItemMod(lower_mod(lctx, m)),
680-
ItemForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)),
681-
ItemTy(ref t, ref generics) => {
679+
ItemKind::Mod(ref m) => hir::ItemMod(lower_mod(lctx, m)),
680+
ItemKind::ForeignMod(ref nm) => hir::ItemForeignMod(lower_foreign_mod(lctx, nm)),
681+
ItemKind::Ty(ref t, ref generics) => {
682682
hir::ItemTy(lower_ty(lctx, t), lower_generics(lctx, generics))
683683
}
684-
ItemEnum(ref enum_definition, ref generics) => {
684+
ItemKind::Enum(ref enum_definition, ref generics) => {
685685
hir::ItemEnum(hir::EnumDef {
686686
variants: enum_definition.variants
687687
.iter()
@@ -690,15 +690,15 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
690690
},
691691
lower_generics(lctx, generics))
692692
}
693-
ItemStruct(ref struct_def, ref generics) => {
693+
ItemKind::Struct(ref struct_def, ref generics) => {
694694
let struct_def = lower_variant_data(lctx, struct_def);
695695
hir::ItemStruct(struct_def, lower_generics(lctx, generics))
696696
}
697-
ItemDefaultImpl(unsafety, ref trait_ref) => {
697+
ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
698698
hir::ItemDefaultImpl(lower_unsafety(lctx, unsafety),
699699
lower_trait_ref(lctx, trait_ref))
700700
}
701-
ItemImpl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => {
701+
ItemKind::Impl(unsafety, polarity, ref generics, ref ifce, ref ty, ref impl_items) => {
702702
let new_impl_items = impl_items.iter()
703703
.map(|item| lower_impl_item(lctx, item))
704704
.collect();
@@ -710,15 +710,15 @@ pub fn lower_item_underscore(lctx: &LoweringContext, i: &Item_) -> hir::Item_ {
710710
lower_ty(lctx, ty),
711711
new_impl_items)
712712
}
713-
ItemTrait(unsafety, ref generics, ref bounds, ref items) => {
713+
ItemKind::Trait(unsafety, ref generics, ref bounds, ref items) => {
714714
let bounds = lower_bounds(lctx, bounds);
715715
let items = items.iter().map(|item| lower_trait_item(lctx, item)).collect();
716716
hir::ItemTrait(lower_unsafety(lctx, unsafety),
717717
lower_generics(lctx, generics),
718718
bounds,
719719
items)
720720
}
721-
ItemMac(_) => panic!("Shouldn't still be around"),
721+
ItemKind::Mac(_) => panic!("Shouldn't still be around"),
722722
}
723723
}
724724

@@ -820,7 +820,7 @@ pub fn lower_item_id(_lctx: &LoweringContext, i: &Item) -> hir::ItemId {
820820
}
821821

822822
pub fn lower_item(lctx: &LoweringContext, i: &Item) -> hir::Item {
823-
let node = lower_item_underscore(lctx, &i.node);
823+
let node = lower_item_kind(lctx, &i.node);
824824

825825
hir::Item {
826826
id: i.id,

src/librustc_metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'a> CrateReader<'a> {
157157

158158
fn extract_crate_info(&self, i: &ast::Item) -> Option<CrateInfo> {
159159
match i.node {
160-
ast::ItemExternCrate(ref path_opt) => {
160+
ast::ItemKind::ExternCrate(ref path_opt) => {
161161
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
162162
i.ident, path_opt);
163163
let name = match *path_opt {

src/librustc_metadata/macro_import.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn read_macro_defs(sess: &Session, cstore: &CStore, krate: &ast::Crate)
5656
// crate root, because `$crate` won't work properly. Identify these by
5757
// spans, because the crate map isn't set up yet.
5858
for item in &krate.module.items {
59-
if let ast::ItemExternCrate(_) = item.node {
59+
if let ast::ItemKind::ExternCrate(_) = item.node {
6060
loader.span_whitelist.insert(item.span);
6161
}
6262
}
@@ -73,7 +73,7 @@ impl<'a, 'v> Visitor<'v> for MacroLoader<'a> {
7373
fn visit_item(&mut self, item: &ast::Item) {
7474
// We're only interested in `extern crate`.
7575
match item.node {
76-
ast::ItemExternCrate(_) => {}
76+
ast::ItemKind::ExternCrate(_) => {}
7777
_ => {
7878
visit::walk_item(self, item);
7979
return;

src/librustc_passes/const_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ impl<'a, 'v> Visitor<'v> for CheckConstFn<'a> {
7878
fn visit_item(&mut self, i: &'v ast::Item) {
7979
visit::walk_item(self, i);
8080
match i.node {
81-
ast::ItemConst(_, ref e) => {
81+
ast::ItemKind::Const(_, ref e) => {
8282
CheckBlock{ sess: self.sess, kind: "constant"}.visit_expr(e)
8383
},
84-
ast::ItemStatic(_, _, ref e) => {
84+
ast::ItemKind::Static(_, _, ref e) => {
8585
CheckBlock{ sess: self.sess, kind: "static"}.visit_expr(e)
8686
},
8787
_ => {},

src/librustc_trans/save/dump_csv.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,10 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
864864

865865
impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
866866
fn visit_item(&mut self, item: &ast::Item) {
867+
use syntax::ast::ItemKind::*;
867868
self.process_macro_use(item.span, item.id);
868869
match item.node {
869-
ast::ItemUse(ref use_item) => {
870+
Use(ref use_item) => {
870871
match use_item.node {
871872
ast::ViewPathSimple(ident, ref path) => {
872873
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> {
950951
}
951952
}
952953
}
953-
ast::ItemExternCrate(ref s) => {
954+
ExternCrate(ref s) => {
954955
let location = match *s {
955956
Some(s) => s.to_string(),
956957
None => item.ident.to_string(),
@@ -968,28 +969,28 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
968969
&location,
969970
self.cur_scope);
970971
}
971-
ast::ItemFn(ref decl, _, _, _, ref ty_params, ref body) =>
972+
Fn(ref decl, _, _, _, ref ty_params, ref body) =>
972973
self.process_fn(item, &**decl, ty_params, &**body),
973-
ast::ItemStatic(ref typ, _, ref expr) =>
974+
Static(ref typ, _, ref expr) =>
974975
self.process_static_or_const_item(item, typ, expr),
975-
ast::ItemConst(ref typ, ref expr) =>
976+
Const(ref typ, ref expr) =>
976977
self.process_static_or_const_item(item, &typ, &expr),
977-
ast::ItemStruct(ref def, ref ty_params) => self.process_struct(item, def, ty_params),
978-
ast::ItemEnum(ref def, ref ty_params) => self.process_enum(item, def, ty_params),
979-
ast::ItemImpl(_, _,
978+
Struct(ref def, ref ty_params) => self.process_struct(item, def, ty_params),
979+
Enum(ref def, ref ty_params) => self.process_enum(item, def, ty_params),
980+
Impl(_, _,
980981
ref ty_params,
981982
ref trait_ref,
982983
ref typ,
983984
ref impl_items) => {
984985
self.process_impl(item, ty_params, trait_ref, &typ, impl_items)
985986
}
986-
ast::ItemTrait(_, ref generics, ref trait_refs, ref methods) =>
987+
Trait(_, ref generics, ref trait_refs, ref methods) =>
987988
self.process_trait(item, generics, trait_refs, methods),
988-
ast::ItemMod(ref m) => {
989+
Mod(ref m) => {
989990
self.process_mod(item);
990991
self.nest(item.id, |v| visit::walk_mod(v, m));
991992
}
992-
ast::ItemTy(ref ty, ref ty_params) => {
993+
Ty(ref ty, ref ty_params) => {
993994
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
994995
let value = ty_to_string(&**ty);
995996
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> {
998999
self.visit_ty(&**ty);
9991000
self.process_generic_params(ty_params, item.span, &qualname, item.id);
10001001
}
1001-
ast::ItemMac(_) => (),
1002+
Mac(_) => (),
10021003
_ => visit::walk_item(self, item),
10031004
}
10041005
}

src/librustc_trans/save/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
229229

230230
pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
231231
match item.node {
232-
ast::ItemFn(..) => {
232+
ast::ItemKind::Fn(..) => {
233233
let name = self.tcx.map.path_to_string(item.id);
234234
let qualname = format!("::{}", name);
235235
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> {
243243
scope: self.enclosing_scope(item.id),
244244
}))
245245
}
246-
ast::ItemStatic(ref typ, mt, ref expr) => {
246+
ast::ItemKind::Static(ref typ, mt, ref expr) => {
247247
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
248248

249249
// If the variable is immutable, save the initialising expression.
@@ -264,7 +264,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
264264
type_value: ty_to_string(&typ),
265265
}))
266266
}
267-
ast::ItemConst(ref typ, ref expr) => {
267+
ast::ItemKind::Const(ref typ, ref expr) => {
268268
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
269269
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Const);
270270
filter!(self.span_utils, sub_span, item.span, None);
@@ -278,7 +278,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
278278
type_value: ty_to_string(&typ),
279279
}))
280280
}
281-
ast::ItemMod(ref m) => {
281+
ast::ItemKind::Mod(ref m) => {
282282
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
283283

284284
let cm = self.tcx.sess.codemap();
@@ -295,7 +295,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
295295
filename: filename,
296296
}))
297297
}
298-
ast::ItemEnum(..) => {
298+
ast::ItemKind::Enum(..) => {
299299
let enum_name = format!("::{}", self.tcx.map.path_to_string(item.id));
300300
let val = self.span_utils.snippet(item.span);
301301
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> {
308308
scope: self.enclosing_scope(item.id),
309309
}))
310310
}
311-
ast::ItemImpl(_, _, _, ref trait_ref, ref typ, _) => {
311+
ast::ItemKind::Impl(_, _, _, ref trait_ref, ref typ, _) => {
312312
let mut type_data = None;
313313
let sub_span;
314314

0 commit comments

Comments
 (0)