diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 8c97d5e74af..401beeb6d20 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -710,15 +710,15 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v visitor.visit_name(foreign_item.span, foreign_item.name); match foreign_item.node { - ForeignItemFn(ref function_declaration, ref param_names, ref generics) => { + ForeignItemKind::Fn(ref function_declaration, ref param_names, ref generics) => { visitor.visit_generics(generics); visitor.visit_fn_decl(function_declaration); for ¶m_name in param_names { visitor.visit_ident(param_name); } } - ForeignItemStatic(ref typ, _) => visitor.visit_ty(typ), - ForeignItemType => (), + ForeignItemKind::Static(ref typ, _) => visitor.visit_ty(typ), + ForeignItemKind::Type => (), } walk_list!(visitor, visit_attribute, &foreign_item.attrs); diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 060f0e036b6..d1cc061fdfd 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -3230,12 +3230,12 @@ impl<'a> LoweringContext<'a> { }, ); - hir::ForeignItemFn(fn_dec, fn_args, generics) + hir::ForeignItemKind::Fn(fn_dec, fn_args, generics) } ForeignItemKind::Static(ref t, m) => { - hir::ForeignItemStatic(self.lower_ty(t, ImplTraitContext::Disallowed), m) + hir::ForeignItemKind::Static(self.lower_ty(t, ImplTraitContext::Disallowed), m) } - ForeignItemKind::Ty => hir::ForeignItemType, + ForeignItemKind::Ty => hir::ForeignItemKind::Type, ForeignItemKind::Macro(_) => panic!("shouldn't exist here"), }, vis: self.lower_visibility(&i.vis, None), diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 3397c7b8432..d9ee77dbe24 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -451,9 +451,9 @@ impl<'hir> Map<'hir> { NodeForeignItem(item) => { let def_id = self.local_def_id(item.id); match item.node { - ForeignItemFn(..) => Some(Def::Fn(def_id)), - ForeignItemStatic(_, m) => Some(Def::Static(def_id, m)), - ForeignItemType => Some(Def::TyForeign(def_id)), + ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)), + ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)), + ForeignItemKind::Type => Some(Def::TyForeign(def_id)), } } NodeTraitItem(item) => { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index edacada9be4..ac7a9b4257a 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -13,7 +13,6 @@ pub use self::BlockCheckMode::*; pub use self::CaptureClause::*; pub use self::FunctionRetTy::*; -pub use self::ForeignItem_::*; pub use self::Item_::*; pub use self::Mutability::*; pub use self::PrimTy::*; @@ -2192,7 +2191,7 @@ pub enum AssociatedItemKind { pub struct ForeignItem { pub name: Name, pub attrs: HirVec, - pub node: ForeignItem_, + pub node: ForeignItemKind, pub id: NodeId, pub span: Span, pub vis: Visibility, @@ -2200,22 +2199,22 @@ pub struct ForeignItem { /// An item within an `extern` block #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub enum ForeignItem_ { +pub enum ForeignItemKind { /// A foreign function - ForeignItemFn(P, HirVec, Generics), + Fn(P, HirVec, Generics), /// A foreign static item (`static ext: u8`), with optional mutability /// (the boolean is true when mutable) - ForeignItemStatic(P, bool), + Static(P, bool), /// A foreign type - ForeignItemType, + Type, } -impl ForeignItem_ { +impl ForeignItemKind { pub fn descriptive_variant(&self) -> &str { match *self { - ForeignItemFn(..) => "foreign function", - ForeignItemStatic(..) => "foreign static item", - ForeignItemType => "foreign type", + ForeignItemKind::Fn(..) => "foreign function", + ForeignItemKind::Static(..) => "foreign static item", + ForeignItemKind::Type => "foreign type", } } } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 5c1378fd941..9d211535063 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -447,7 +447,7 @@ impl<'a> State<'a> { self.maybe_print_comment(item.span.lo())?; self.print_outer_attributes(&item.attrs)?; match item.node { - hir::ForeignItemFn(ref decl, ref arg_names, ref generics) => { + hir::ForeignItemKind::Fn(ref decl, ref arg_names, ref generics) => { self.head("")?; self.print_fn(decl, hir::FnHeader { @@ -465,7 +465,7 @@ impl<'a> State<'a> { self.s.word(";")?; self.end() // end the outer fn box } - hir::ForeignItemStatic(ref t, m) => { + hir::ForeignItemKind::Static(ref t, m) => { self.head(&visibility_qualified(&item.vis, "static"))?; if m { self.word_space("mut")?; @@ -477,7 +477,7 @@ impl<'a> State<'a> { self.end()?; // end the head-ibox self.end() // end the outer cbox } - hir::ForeignItemType => { + hir::ForeignItemKind::Type => { self.head(&visibility_qualified(&item.vis, "type"))?; self.print_name(item.name)?; self.s.word(";")?; diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index d8f7e09f6b4..d00f96834ab 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -909,10 +909,10 @@ impl_stable_hash_for!(struct hir::ForeignItem { vis }); -impl_stable_hash_for!(enum hir::ForeignItem_ { - ForeignItemFn(fn_decl, arg_names, generics), - ForeignItemStatic(ty, is_mutbl), - ForeignItemType +impl_stable_hash_for!(enum hir::ForeignItemKind { + Fn(fn_decl, arg_names, generics), + Static(ty, is_mutbl), + Type }); impl_stable_hash_for!(enum hir::StmtKind { diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index cec5197acc8..40dd51cf5b9 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -550,15 +550,15 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) { match item.node { - hir::ForeignItemFn(ref decl, _, ref generics) => { + hir::ForeignItemKind::Fn(ref decl, _, ref generics) => { self.visit_early_late(None, decl, generics, |this| { intravisit::walk_foreign_item(this, item); }) } - hir::ForeignItemStatic(..) => { + hir::ForeignItemKind::Static(..) => { intravisit::walk_foreign_item(self, item); } - hir::ForeignItemType => { + hir::ForeignItemKind::Type => { intravisit::walk_foreign_item(self, item); } } diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index f118d22c54d..d12cce5ac4d 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -608,7 +608,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { node: hir::ItemStatic(_, mutbl, _), .. }) => Some(mutbl), Node::NodeForeignItem(&hir::ForeignItem { - node: hir::ForeignItemStatic(_, is_mutbl), .. + node: hir::ForeignItemKind::Static(_, is_mutbl), .. }) => Some(if is_mutbl { hir::Mutability::MutMutable diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 199c40bb704..81e51e59d92 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -143,7 +143,7 @@ pub fn get_static(cx: &CodegenCx, def_id: DefId) -> ValueRef { } hir_map::NodeForeignItem(&hir::ForeignItem { - ref attrs, span, node: hir::ForeignItemStatic(..), .. + ref attrs, span, node: hir::ForeignItemKind::Static(..), .. }) => { let g = if let Some(linkage) = cx.tcx.codegen_fn_attrs(def_id).linkage { // If this is a static with a linkage specified, then we need to handle diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 1b198533582..30cf9288c80 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -786,13 +786,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes { if nmod.abi != Abi::RustIntrinsic && nmod.abi != Abi::PlatformIntrinsic { for ni in &nmod.items { match ni.node { - hir::ForeignItemFn(ref decl, _, _) => { + hir::ForeignItemKind::Fn(ref decl, _, _) => { vis.check_foreign_fn(ni.id, decl); } - hir::ForeignItemStatic(ref ty, _) => { + hir::ForeignItemKind::Static(ref ty, _) => { vis.check_foreign_static(ni.id, ty.span); } - hir::ForeignItemType => () + hir::ForeignItemKind::Type => () } } } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 7721fa00f1a..25bd2d09704 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -1561,7 +1561,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { debug!("IsolatedEncoder::encode_info_for_foreign_item({:?})", def_id); let kind = match nitem.node { - hir::ForeignItemFn(_, ref names, _) => { + hir::ForeignItemKind::Fn(_, ref names, _) => { let data = FnData { constness: hir::Constness::NotConst, arg_names: self.encode_fn_arg_names(names), @@ -1569,9 +1569,9 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { }; EntryKind::ForeignFn(self.lazy(&data)) } - hir::ForeignItemStatic(_, true) => EntryKind::ForeignMutStatic, - hir::ForeignItemStatic(_, false) => EntryKind::ForeignImmStatic, - hir::ForeignItemType => EntryKind::ForeignType, + hir::ForeignItemKind::Static(_, true) => EntryKind::ForeignMutStatic, + hir::ForeignItemKind::Static(_, false) => EntryKind::ForeignImmStatic, + hir::ForeignItemKind::Type => EntryKind::ForeignType, }; Entry { @@ -1586,7 +1586,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { ty: Some(self.encode_item_type(def_id)), inherent_impls: LazySeq::empty(), variances: match nitem.node { - hir::ForeignItemFn(..) => self.encode_variances_of(def_id), + hir::ForeignItemKind::Fn(..) => self.encode_variances_of(def_id), _ => LazySeq::empty(), }, generics: Some(self.encode_generics(def_id)), diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index c93023edcea..e26bf1b4f77 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -35,7 +35,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let def_id = tcx.hir.local_def_id(it.id); match it.node { - hir::ForeignItemFn(..) => {} + hir::ForeignItemKind::Fn(..) => {} _ => { struct_span_err!(tcx.sess, it.span, E0622, "intrinsic must be a function") @@ -48,7 +48,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let i_n_tps = tcx.generics_of(def_id).own_counts().types; if i_n_tps != n_tps { let span = match it.node { - hir::ForeignItemFn(_, _, ref generics) => generics.span, + hir::ForeignItemKind::Fn(_, _, ref generics) => generics.span, _ => bug!() }; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6cbe1f42acc..4aa11526acd 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1340,7 +1340,7 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item err.emit(); } - if let hir::ForeignItemFn(ref fn_decl, _, _) = item.node { + if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node { require_c_abi_if_variadic(tcx, fn_decl, m.abi, item.span); } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index a8cf0915446..e9f3cae080c 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -287,7 +287,7 @@ fn type_param_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(item) => { match item.node { - ForeignItemFn(_, _, ref generics) => generics, + ForeignItemKind::Fn(_, _, ref generics) => generics, _ => return result } } @@ -375,7 +375,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); - if let hir::ForeignItemFn(..) = item.node { + if let hir::ForeignItemKind::Fn(..) = item.node { tcx.fn_sig(def_id); } } @@ -774,7 +774,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, _ => None, }, hir_map::NodeForeignItem(item) => match item.node { - hir::ForeignItemFn(ref fn_decl, _, ref generics) => + hir::ForeignItemKind::Fn(ref fn_decl, _, ref generics) => has_late_bound_regions(tcx, generics, fn_decl), _ => None, }, @@ -869,9 +869,9 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(item) => { match item.node { - ForeignItemStatic(..) => &no_generics, - ForeignItemFn(_, _, ref generics) => generics, - ForeignItemType => &no_generics, + ForeignItemKind::Static(..) => &no_generics, + ForeignItemKind::Fn(_, _, ref generics) => generics, + ForeignItemKind::Type => &no_generics, } } @@ -1080,12 +1080,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, NodeForeignItem(foreign_item) => { match foreign_item.node { - ForeignItemFn(..) => { + ForeignItemKind::Fn(..) => { let substs = Substs::identity_for_item(tcx, def_id); tcx.mk_fn_def(def_id, substs) } - ForeignItemStatic(ref t, _) => icx.to_ty(t), - ForeignItemType => tcx.mk_foreign(def_id), + ForeignItemKind::Static(ref t, _) => icx.to_ty(t), + ForeignItemKind::Type => tcx.mk_foreign(def_id), } } @@ -1169,7 +1169,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl) } - NodeForeignItem(&hir::ForeignItem { node: ForeignItemFn(ref fn_decl, _, _), .. }) => { + NodeForeignItem(&hir::ForeignItem { node: ForeignItemKind::Fn(ref fn_decl, _, _), .. }) => { let abi = tcx.hir.get_foreign_abi(node_id); compute_sig_of_foreign_fn_decl(tcx, def_id, fn_decl, abi) } @@ -1412,9 +1412,9 @@ fn explicit_predicates_of<'a, 'tcx>( NodeForeignItem(item) => { match item.node { - ForeignItemStatic(..) => &no_generics, - ForeignItemFn(_, _, ref generics) => generics, - ForeignItemType => &no_generics, + ForeignItemKind::Static(..) => &no_generics, + ForeignItemKind::Fn(_, _, ref generics) => generics, + ForeignItemKind::Type => &no_generics, } } diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index ad7a3051f64..b346dffdb46 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> { hir::ItemForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { - if let hir::ForeignItemFn(..) = foreign_item.node { + if let hir::ForeignItemKind::Fn(..) = foreign_item.node { self.visit_node_helper(foreign_item.id); } } diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index adea9788b3c..29c7ee757ca 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -83,7 +83,7 @@ fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) }, hir::map::NodeForeignItem(item) => match item.node { - hir::ForeignItemFn(..) => {} + hir::ForeignItemKind::Fn(..) => {} _ => unsupported() }, diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index b9ab00130b3..1de7bf57422 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -167,7 +167,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> { hir::ItemForeignMod(ref foreign_mod) => { for foreign_item in &foreign_mod.items { - if let hir::ForeignItemFn(..) = foreign_item.node { + if let hir::ForeignItemKind::Fn(..) = foreign_item.node { self.add_inferreds_for_item(foreign_item.id); } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a8980cbd5c8..021dc6d3418 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -4018,7 +4018,7 @@ impl Clean> for hir::ForeignMod { impl Clean for hir::ForeignItem { fn clean(&self, cx: &DocContext) -> Item { let inner = match self.node { - hir::ForeignItemFn(ref decl, ref names, ref generics) => { + hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => { let (generics, decl) = enter_impl_trait(cx, || { (generics.clean(cx), (&**decl, &names[..]).clean(cx)) }); @@ -4033,14 +4033,14 @@ impl Clean for hir::ForeignItem { }, }) } - hir::ForeignItemStatic(ref ty, mutbl) => { + hir::ForeignItemKind::Static(ref ty, mutbl) => { ForeignStaticItem(Static { type_: ty.clean(cx), mutability: if mutbl {Mutable} else {Immutable}, expr: "".to_string(), }) } - hir::ForeignItemType => { + hir::ForeignItemKind::Type => { ForeignTypeItem } };