Skip to content

Commit 7e5d224

Browse files
csmoeoli-obk
authored andcommitted
ForeignItemKind
1 parent f12eca4 commit 7e5d224

File tree

18 files changed

+60
-61
lines changed

18 files changed

+60
-61
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,15 +710,15 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
710710
visitor.visit_name(foreign_item.span, foreign_item.name);
711711

712712
match foreign_item.node {
713-
ForeignItemFn(ref function_declaration, ref param_names, ref generics) => {
713+
ForeignItemKind::Fn(ref function_declaration, ref param_names, ref generics) => {
714714
visitor.visit_generics(generics);
715715
visitor.visit_fn_decl(function_declaration);
716716
for &param_name in param_names {
717717
visitor.visit_ident(param_name);
718718
}
719719
}
720-
ForeignItemStatic(ref typ, _) => visitor.visit_ty(typ),
721-
ForeignItemType => (),
720+
ForeignItemKind::Static(ref typ, _) => visitor.visit_ty(typ),
721+
ForeignItemKind::Type => (),
722722
}
723723

724724
walk_list!(visitor, visit_attribute, &foreign_item.attrs);

src/librustc/hir/lowering.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3230,12 +3230,12 @@ impl<'a> LoweringContext<'a> {
32303230
},
32313231
);
32323232

3233-
hir::ForeignItemFn(fn_dec, fn_args, generics)
3233+
hir::ForeignItemKind::Fn(fn_dec, fn_args, generics)
32343234
}
32353235
ForeignItemKind::Static(ref t, m) => {
3236-
hir::ForeignItemStatic(self.lower_ty(t, ImplTraitContext::Disallowed), m)
3236+
hir::ForeignItemKind::Static(self.lower_ty(t, ImplTraitContext::Disallowed), m)
32373237
}
3238-
ForeignItemKind::Ty => hir::ForeignItemType,
3238+
ForeignItemKind::Ty => hir::ForeignItemKind::Type,
32393239
ForeignItemKind::Macro(_) => panic!("shouldn't exist here"),
32403240
},
32413241
vis: self.lower_visibility(&i.vis, None),

src/librustc/hir/map/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ impl<'hir> Map<'hir> {
451451
NodeForeignItem(item) => {
452452
let def_id = self.local_def_id(item.id);
453453
match item.node {
454-
ForeignItemFn(..) => Some(Def::Fn(def_id)),
455-
ForeignItemStatic(_, m) => Some(Def::Static(def_id, m)),
456-
ForeignItemType => Some(Def::TyForeign(def_id)),
454+
ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)),
455+
ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)),
456+
ForeignItemKind::Type => Some(Def::TyForeign(def_id)),
457457
}
458458
}
459459
NodeTraitItem(item) => {

src/librustc/hir/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
pub use self::BlockCheckMode::*;
1414
pub use self::CaptureClause::*;
1515
pub use self::FunctionRetTy::*;
16-
pub use self::ForeignItem_::*;
1716
pub use self::Item_::*;
1817
pub use self::Mutability::*;
1918
pub use self::PrimTy::*;
@@ -2192,30 +2191,30 @@ pub enum AssociatedItemKind {
21922191
pub struct ForeignItem {
21932192
pub name: Name,
21942193
pub attrs: HirVec<Attribute>,
2195-
pub node: ForeignItem_,
2194+
pub node: ForeignItemKind,
21962195
pub id: NodeId,
21972196
pub span: Span,
21982197
pub vis: Visibility,
21992198
}
22002199

22012200
/// An item within an `extern` block
22022201
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
2203-
pub enum ForeignItem_ {
2202+
pub enum ForeignItemKind {
22042203
/// A foreign function
2205-
ForeignItemFn(P<FnDecl>, HirVec<Ident>, Generics),
2204+
Fn(P<FnDecl>, HirVec<Ident>, Generics),
22062205
/// A foreign static item (`static ext: u8`), with optional mutability
22072206
/// (the boolean is true when mutable)
2208-
ForeignItemStatic(P<Ty>, bool),
2207+
Static(P<Ty>, bool),
22092208
/// A foreign type
2210-
ForeignItemType,
2209+
Type,
22112210
}
22122211

2213-
impl ForeignItem_ {
2212+
impl ForeignItemKind {
22142213
pub fn descriptive_variant(&self) -> &str {
22152214
match *self {
2216-
ForeignItemFn(..) => "foreign function",
2217-
ForeignItemStatic(..) => "foreign static item",
2218-
ForeignItemType => "foreign type",
2215+
ForeignItemKind::Fn(..) => "foreign function",
2216+
ForeignItemKind::Static(..) => "foreign static item",
2217+
ForeignItemKind::Type => "foreign type",
22192218
}
22202219
}
22212220
}

src/librustc/hir/print.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'a> State<'a> {
447447
self.maybe_print_comment(item.span.lo())?;
448448
self.print_outer_attributes(&item.attrs)?;
449449
match item.node {
450-
hir::ForeignItemFn(ref decl, ref arg_names, ref generics) => {
450+
hir::ForeignItemKind::Fn(ref decl, ref arg_names, ref generics) => {
451451
self.head("")?;
452452
self.print_fn(decl,
453453
hir::FnHeader {
@@ -465,7 +465,7 @@ impl<'a> State<'a> {
465465
self.s.word(";")?;
466466
self.end() // end the outer fn box
467467
}
468-
hir::ForeignItemStatic(ref t, m) => {
468+
hir::ForeignItemKind::Static(ref t, m) => {
469469
self.head(&visibility_qualified(&item.vis, "static"))?;
470470
if m {
471471
self.word_space("mut")?;
@@ -477,7 +477,7 @@ impl<'a> State<'a> {
477477
self.end()?; // end the head-ibox
478478
self.end() // end the outer cbox
479479
}
480-
hir::ForeignItemType => {
480+
hir::ForeignItemKind::Type => {
481481
self.head(&visibility_qualified(&item.vis, "type"))?;
482482
self.print_name(item.name)?;
483483
self.s.word(";")?;

src/librustc/ich/impls_hir.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,10 @@ impl_stable_hash_for!(struct hir::ForeignItem {
909909
vis
910910
});
911911

912-
impl_stable_hash_for!(enum hir::ForeignItem_ {
913-
ForeignItemFn(fn_decl, arg_names, generics),
914-
ForeignItemStatic(ty, is_mutbl),
915-
ForeignItemType
912+
impl_stable_hash_for!(enum hir::ForeignItemKind {
913+
Fn(fn_decl, arg_names, generics),
914+
Static(ty, is_mutbl),
915+
Type
916916
});
917917

918918
impl_stable_hash_for!(enum hir::StmtKind {

src/librustc/middle/resolve_lifetime.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,15 +550,15 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
550550

551551
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
552552
match item.node {
553-
hir::ForeignItemFn(ref decl, _, ref generics) => {
553+
hir::ForeignItemKind::Fn(ref decl, _, ref generics) => {
554554
self.visit_early_late(None, decl, generics, |this| {
555555
intravisit::walk_foreign_item(this, item);
556556
})
557557
}
558-
hir::ForeignItemStatic(..) => {
558+
hir::ForeignItemKind::Static(..) => {
559559
intravisit::walk_foreign_item(self, item);
560560
}
561-
hir::ForeignItemType => {
561+
hir::ForeignItemKind::Type => {
562562
intravisit::walk_foreign_item(self, item);
563563
}
564564
}

src/librustc/ty/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
608608
node: hir::ItemStatic(_, mutbl, _), ..
609609
}) => Some(mutbl),
610610
Node::NodeForeignItem(&hir::ForeignItem {
611-
node: hir::ForeignItemStatic(_, is_mutbl), ..
611+
node: hir::ForeignItemKind::Static(_, is_mutbl), ..
612612
}) =>
613613
Some(if is_mutbl {
614614
hir::Mutability::MutMutable

src/librustc_codegen_llvm/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn get_static(cx: &CodegenCx, def_id: DefId) -> ValueRef {
143143
}
144144

145145
hir_map::NodeForeignItem(&hir::ForeignItem {
146-
ref attrs, span, node: hir::ForeignItemStatic(..), ..
146+
ref attrs, span, node: hir::ForeignItemKind::Static(..), ..
147147
}) => {
148148
let g = if let Some(linkage) = cx.tcx.codegen_fn_attrs(def_id).linkage {
149149
// If this is a static with a linkage specified, then we need to handle

src/librustc_lint/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
786786
if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic {
787787
for ni in &nmod.items {
788788
match ni.node {
789-
hir::ForeignItemFn(ref decl, _, _) => {
789+
hir::ForeignItemKind::Fn(ref decl, _, _) => {
790790
vis.check_foreign_fn(ni.id, decl);
791791
}
792-
hir::ForeignItemStatic(ref ty, _) => {
792+
hir::ForeignItemKind::Static(ref ty, _) => {
793793
vis.check_foreign_static(ni.id, ty.span);
794794
}
795-
hir::ForeignItemType => ()
795+
hir::ForeignItemKind::Type => ()
796796
}
797797
}
798798
}

src/librustc_metadata/encoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,17 +1561,17 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
15611561
debug!("IsolatedEncoder::encode_info_for_foreign_item({:?})", def_id);
15621562

15631563
let kind = match nitem.node {
1564-
hir::ForeignItemFn(_, ref names, _) => {
1564+
hir::ForeignItemKind::Fn(_, ref names, _) => {
15651565
let data = FnData {
15661566
constness: hir::Constness::NotConst,
15671567
arg_names: self.encode_fn_arg_names(names),
15681568
sig: self.lazy(&tcx.fn_sig(def_id)),
15691569
};
15701570
EntryKind::ForeignFn(self.lazy(&data))
15711571
}
1572-
hir::ForeignItemStatic(_, true) => EntryKind::ForeignMutStatic,
1573-
hir::ForeignItemStatic(_, false) => EntryKind::ForeignImmStatic,
1574-
hir::ForeignItemType => EntryKind::ForeignType,
1572+
hir::ForeignItemKind::Static(_, true) => EntryKind::ForeignMutStatic,
1573+
hir::ForeignItemKind::Static(_, false) => EntryKind::ForeignImmStatic,
1574+
hir::ForeignItemKind::Type => EntryKind::ForeignType,
15751575
};
15761576

15771577
Entry {
@@ -1586,7 +1586,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
15861586
ty: Some(self.encode_item_type(def_id)),
15871587
inherent_impls: LazySeq::empty(),
15881588
variances: match nitem.node {
1589-
hir::ForeignItemFn(..) => self.encode_variances_of(def_id),
1589+
hir::ForeignItemKind::Fn(..) => self.encode_variances_of(def_id),
15901590
_ => LazySeq::empty(),
15911591
},
15921592
generics: Some(self.encode_generics(def_id)),

src/librustc_typeck/check/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
3535
let def_id = tcx.hir.local_def_id(it.id);
3636

3737
match it.node {
38-
hir::ForeignItemFn(..) => {}
38+
hir::ForeignItemKind::Fn(..) => {}
3939
_ => {
4040
struct_span_err!(tcx.sess, it.span, E0622,
4141
"intrinsic must be a function")
@@ -48,7 +48,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
4848
let i_n_tps = tcx.generics_of(def_id).own_counts().types;
4949
if i_n_tps != n_tps {
5050
let span = match it.node {
51-
hir::ForeignItemFn(_, _, ref generics) => generics.span,
51+
hir::ForeignItemKind::Fn(_, _, ref generics) => generics.span,
5252
_ => bug!()
5353
};
5454

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
13401340
err.emit();
13411341
}
13421342

1343-
if let hir::ForeignItemFn(ref fn_decl, _, _) = item.node {
1343+
if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node {
13441344
require_c_abi_if_variadic(tcx, fn_decl, m.abi, item.span);
13451345
}
13461346
}

src/librustc_typeck/collect.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
287287

288288
NodeForeignItem(item) => {
289289
match item.node {
290-
ForeignItemFn(_, _, ref generics) => generics,
290+
ForeignItemKind::Fn(_, _, ref generics) => generics,
291291
_ => return result
292292
}
293293
}
@@ -375,7 +375,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
375375
tcx.generics_of(def_id);
376376
tcx.type_of(def_id);
377377
tcx.predicates_of(def_id);
378-
if let hir::ForeignItemFn(..) = item.node {
378+
if let hir::ForeignItemKind::Fn(..) = item.node {
379379
tcx.fn_sig(def_id);
380380
}
381381
}
@@ -774,7 +774,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
774774
_ => None,
775775
},
776776
hir_map::NodeForeignItem(item) => match item.node {
777-
hir::ForeignItemFn(ref fn_decl, _, ref generics) =>
777+
hir::ForeignItemKind::Fn(ref fn_decl, _, ref generics) =>
778778
has_late_bound_regions(tcx, generics, fn_decl),
779779
_ => None,
780780
},
@@ -869,9 +869,9 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
869869

870870
NodeForeignItem(item) => {
871871
match item.node {
872-
ForeignItemStatic(..) => &no_generics,
873-
ForeignItemFn(_, _, ref generics) => generics,
874-
ForeignItemType => &no_generics,
872+
ForeignItemKind::Static(..) => &no_generics,
873+
ForeignItemKind::Fn(_, _, ref generics) => generics,
874+
ForeignItemKind::Type => &no_generics,
875875
}
876876
}
877877

@@ -1080,12 +1080,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10801080

10811081
NodeForeignItem(foreign_item) => {
10821082
match foreign_item.node {
1083-
ForeignItemFn(..) => {
1083+
ForeignItemKind::Fn(..) => {
10841084
let substs = Substs::identity_for_item(tcx, def_id);
10851085
tcx.mk_fn_def(def_id, substs)
10861086
}
1087-
ForeignItemStatic(ref t, _) => icx.to_ty(t),
1088-
ForeignItemType => tcx.mk_foreign(def_id),
1087+
ForeignItemKind::Static(ref t, _) => icx.to_ty(t),
1088+
ForeignItemKind::Type => tcx.mk_foreign(def_id),
10891089
}
10901090
}
10911091

@@ -1169,7 +1169,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11691169
AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl)
11701170
}
11711171

1172-
NodeForeignItem(&hir::ForeignItem { node: ForeignItemFn(ref fn_decl, _, _), .. }) => {
1172+
NodeForeignItem(&hir::ForeignItem { node: ForeignItemKind::Fn(ref fn_decl, _, _), .. }) => {
11731173
let abi = tcx.hir.get_foreign_abi(node_id);
11741174
compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi)
11751175
}
@@ -1412,9 +1412,9 @@ fn explicit_predicates_of<'a, 'tcx>(
14121412

14131413
NodeForeignItem(item) => {
14141414
match item.node {
1415-
ForeignItemStatic(..) => &no_generics,
1416-
ForeignItemFn(_, _, ref generics) => generics,
1417-
ForeignItemType => &no_generics,
1415+
ForeignItemKind::Static(..) => &no_generics,
1416+
ForeignItemKind::Fn(_, _, ref generics) => generics,
1417+
ForeignItemKind::Type => &no_generics,
14181418
}
14191419
}
14201420

src/librustc_typeck/variance/constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
105105

106106
hir::ItemForeignMod(ref foreign_mod) => {
107107
for foreign_item in &foreign_mod.items {
108-
if let hir::ForeignItemFn(..) = foreign_item.node {
108+
if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
109109
self.visit_node_helper(foreign_item.id);
110110
}
111111
}

src/librustc_typeck/variance/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId)
8383
},
8484

8585
hir::map::NodeForeignItem(item) => match item.node {
86-
hir::ForeignItemFn(..) => {}
86+
hir::ForeignItemKind::Fn(..) => {}
8787

8888
_ => unsupported()
8989
},

src/librustc_typeck/variance/terms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
167167

168168
hir::ItemForeignMod(ref foreign_mod) => {
169169
for foreign_item in &foreign_mod.items {
170-
if let hir::ForeignItemFn(..) = foreign_item.node {
170+
if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
171171
self.add_inferreds_for_item(foreign_item.id);
172172
}
173173
}

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,7 @@ impl Clean<Vec<Item>> for hir::ForeignMod {
40184018
impl Clean<Item> for hir::ForeignItem {
40194019
fn clean(&self, cx: &DocContext) -> Item {
40204020
let inner = match self.node {
4021-
hir::ForeignItemFn(ref decl, ref names, ref generics) => {
4021+
hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => {
40224022
let (generics, decl) = enter_impl_trait(cx, || {
40234023
(generics.clean(cx), (&**decl, &names[..]).clean(cx))
40244024
});
@@ -4033,14 +4033,14 @@ impl Clean<Item> for hir::ForeignItem {
40334033
},
40344034
})
40354035
}
4036-
hir::ForeignItemStatic(ref ty, mutbl) => {
4036+
hir::ForeignItemKind::Static(ref ty, mutbl) => {
40374037
ForeignStaticItem(Static {
40384038
type_: ty.clean(cx),
40394039
mutability: if mutbl {Mutable} else {Immutable},
40404040
expr: "".to_string(),
40414041
})
40424042
}
4043-
hir::ForeignItemType => {
4043+
hir::ForeignItemKind::Type => {
40444044
ForeignTypeItem
40454045
}
40464046
};

0 commit comments

Comments
 (0)