ForeignItemKind
This commit is contained in:
parent
f12eca47e0
commit
7e5d224472
@ -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);
|
||||
|
@ -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),
|
||||
|
@ -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) => {
|
||||
|
@ -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<Attribute>,
|
||||
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<FnDecl>, HirVec<Ident>, Generics),
|
||||
Fn(P<FnDecl>, HirVec<Ident>, Generics),
|
||||
/// A foreign static item (`static ext: u8`), with optional mutability
|
||||
/// (the boolean is true when mutable)
|
||||
ForeignItemStatic(P<Ty>, bool),
|
||||
Static(P<Ty>, 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",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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(";")?;
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)),
|
||||
|
@ -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!()
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
},
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -4018,7 +4018,7 @@ impl Clean<Vec<Item>> for hir::ForeignMod {
|
||||
impl Clean<Item> 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<Item> 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
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user