Rename ImplItem.node
to ImplItem.kind
This commit is contained in:
parent
8bd0382134
commit
ce6aabbaa1
48 changed files with 107 additions and 108 deletions
|
@ -905,7 +905,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
|
||||||
ref defaultness,
|
ref defaultness,
|
||||||
ref attrs,
|
ref attrs,
|
||||||
ref generics,
|
ref generics,
|
||||||
ref node,
|
ref kind,
|
||||||
span: _,
|
span: _,
|
||||||
} = *impl_item;
|
} = *impl_item;
|
||||||
|
|
||||||
|
@ -914,7 +914,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
|
||||||
visitor.visit_defaultness(defaultness);
|
visitor.visit_defaultness(defaultness);
|
||||||
walk_list!(visitor, visit_attribute, attrs);
|
walk_list!(visitor, visit_attribute, attrs);
|
||||||
visitor.visit_generics(generics);
|
visitor.visit_generics(generics);
|
||||||
match *node {
|
match *kind {
|
||||||
ImplItemKind::Const(ref ty, body) => {
|
ImplItemKind::Const(ref ty, body) => {
|
||||||
visitor.visit_id(impl_item.hir_id);
|
visitor.visit_id(impl_item.hir_id);
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
|
|
|
@ -902,7 +902,7 @@ impl LoweringContext<'_> {
|
||||||
fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
|
fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
|
||||||
let impl_item_def_id = self.resolver.definitions().local_def_id(i.id);
|
let impl_item_def_id = self.resolver.definitions().local_def_id(i.id);
|
||||||
|
|
||||||
let (generics, node) = match i.node {
|
let (generics, kind) = match i.kind {
|
||||||
ImplItemKind::Const(ref ty, ref expr) => (
|
ImplItemKind::Const(ref ty, ref expr) => (
|
||||||
self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
|
self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
|
||||||
hir::ImplItemKind::Const(
|
hir::ImplItemKind::Const(
|
||||||
|
@ -946,7 +946,7 @@ impl LoweringContext<'_> {
|
||||||
generics,
|
generics,
|
||||||
vis: self.lower_visibility(&i.vis, None),
|
vis: self.lower_visibility(&i.vis, None),
|
||||||
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
|
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
|
||||||
node,
|
kind,
|
||||||
span: i.span,
|
span: i.span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,7 +960,7 @@ impl LoweringContext<'_> {
|
||||||
span: i.span,
|
span: i.span,
|
||||||
vis: self.lower_visibility(&i.vis, Some(i.id)),
|
vis: self.lower_visibility(&i.vis, Some(i.id)),
|
||||||
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
|
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
|
||||||
kind: match i.node {
|
kind: match i.kind {
|
||||||
ImplItemKind::Const(..) => hir::AssocItemKind::Const,
|
ImplItemKind::Const(..) => hir::AssocItemKind::Const,
|
||||||
ImplItemKind::TyAlias(..) => hir::AssocItemKind::Type,
|
ImplItemKind::TyAlias(..) => hir::AssocItemKind::Type,
|
||||||
ImplItemKind::OpaqueTy(..) => hir::AssocItemKind::OpaqueTy,
|
ImplItemKind::OpaqueTy(..) => hir::AssocItemKind::OpaqueTy,
|
||||||
|
|
|
@ -43,7 +43,10 @@ impl MaybeFnLike for ast::Item {
|
||||||
|
|
||||||
impl MaybeFnLike for ast::ImplItem {
|
impl MaybeFnLike for ast::ImplItem {
|
||||||
fn is_fn_like(&self) -> bool {
|
fn is_fn_like(&self) -> bool {
|
||||||
match self.node { ast::ImplItemKind::Method(..) => true, _ => false, }
|
match self.kind {
|
||||||
|
ast::ImplItemKind::Method(..) => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +237,7 @@ impl<'a> FnLikeNode<'a> {
|
||||||
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
_ => bug!("trait method FnLikeNode that is not fn-like"),
|
||||||
},
|
},
|
||||||
map::Node::ImplItem(ii) => {
|
map::Node::ImplItem(ii) => {
|
||||||
match ii.node {
|
match ii.kind {
|
||||||
ast::ImplItemKind::Method(ref sig, body) => {
|
ast::ImplItemKind::Method(ref sig, body) => {
|
||||||
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
|
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,7 +228,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
||||||
let def_data = match ii.node {
|
let def_data = match ii.kind {
|
||||||
ImplItemKind::Method(MethodSig {
|
ImplItemKind::Method(MethodSig {
|
||||||
ref header,
|
ref header,
|
||||||
ref decl,
|
ref decl,
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl<'hir> Entry<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::ImplItem(ref item) => {
|
Node::ImplItem(ref item) => {
|
||||||
match item.node {
|
match item.kind {
|
||||||
ImplItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
|
ImplItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::ImplItem(item) => {
|
Node::ImplItem(item) => {
|
||||||
match item.node {
|
match item.kind {
|
||||||
ImplItemKind::Const(_, body) |
|
ImplItemKind::Const(_, body) |
|
||||||
ImplItemKind::Method(_, body) => Some(body),
|
ImplItemKind::Method(_, body) => Some(body),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -327,7 +327,7 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node::ImplItem(item) => {
|
Node::ImplItem(item) => {
|
||||||
match item.node {
|
match item.kind {
|
||||||
ImplItemKind::Const(..) => DefKind::AssocConst,
|
ImplItemKind::Const(..) => DefKind::AssocConst,
|
||||||
ImplItemKind::Method(..) => DefKind::Method,
|
ImplItemKind::Method(..) => DefKind::Method,
|
||||||
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
|
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
|
||||||
|
@ -455,14 +455,14 @@ impl<'hir> Map<'hir> {
|
||||||
match self.get(id) {
|
match self.get(id) {
|
||||||
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
|
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
|
||||||
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
|
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
|
||||||
Node::ImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) |
|
Node::ImplItem(&ImplItem { kind: ImplItemKind::Const(..), .. }) |
|
||||||
Node::AnonConst(_) => {
|
Node::AnonConst(_) => {
|
||||||
BodyOwnerKind::Const
|
BodyOwnerKind::Const
|
||||||
}
|
}
|
||||||
Node::Ctor(..) |
|
Node::Ctor(..) |
|
||||||
Node::Item(&Item { node: ItemKind::Fn(..), .. }) |
|
Node::Item(&Item { node: ItemKind::Fn(..), .. }) |
|
||||||
Node::TraitItem(&TraitItem { node: TraitItemKind::Method(..), .. }) |
|
Node::TraitItem(&TraitItem { node: TraitItemKind::Method(..), .. }) |
|
||||||
Node::ImplItem(&ImplItem { node: ImplItemKind::Method(..), .. }) => {
|
Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => {
|
||||||
BodyOwnerKind::Fn
|
BodyOwnerKind::Fn
|
||||||
}
|
}
|
||||||
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
|
Node::Item(&Item { node: ItemKind::Static(_, m, _), .. }) => {
|
||||||
|
@ -657,7 +657,7 @@ impl<'hir> Map<'hir> {
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| Node::ImplItem(&ImplItem {
|
| Node::ImplItem(&ImplItem {
|
||||||
node: ImplItemKind::Const(..),
|
kind: ImplItemKind::Const(..),
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| Node::AnonConst(_)
|
| Node::AnonConst(_)
|
||||||
|
@ -832,7 +832,7 @@ impl<'hir> Map<'hir> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Node::ImplItem(ii) => {
|
Node::ImplItem(ii) => {
|
||||||
match ii.node {
|
match ii.kind {
|
||||||
ImplItemKind::Method(..) => true,
|
ImplItemKind::Method(..) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
@ -1310,7 +1310,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
||||||
format!("foreign item {}{}", path_str(), id_str)
|
format!("foreign item {}{}", path_str(), id_str)
|
||||||
}
|
}
|
||||||
Some(Node::ImplItem(ii)) => {
|
Some(Node::ImplItem(ii)) => {
|
||||||
match ii.node {
|
match ii.kind {
|
||||||
ImplItemKind::Const(..) => {
|
ImplItemKind::Const(..) => {
|
||||||
format!("assoc const {} in {}{}", ii.ident, path_str(), id_str)
|
format!("assoc const {} in {}{}", ii.ident, path_str(), id_str)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1873,7 +1873,7 @@ pub struct ImplItem {
|
||||||
pub defaultness: Defaultness,
|
pub defaultness: Defaultness,
|
||||||
pub attrs: HirVec<Attribute>,
|
pub attrs: HirVec<Attribute>,
|
||||||
pub generics: Generics,
|
pub generics: Generics,
|
||||||
pub node: ImplItemKind,
|
pub kind: ImplItemKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -896,7 +896,7 @@ impl<'a> State<'a> {
|
||||||
self.print_outer_attributes(&ii.attrs);
|
self.print_outer_attributes(&ii.attrs);
|
||||||
self.print_defaultness(ii.defaultness);
|
self.print_defaultness(ii.defaultness);
|
||||||
|
|
||||||
match ii.node {
|
match ii.kind {
|
||||||
hir::ImplItemKind::Const(ref ty, expr) => {
|
hir::ImplItemKind::Const(ref ty, expr) => {
|
||||||
self.print_associated_const(ii.ident, &ty, Some(expr), &ii.vis);
|
self.print_associated_const(ii.ident, &ty, Some(expr), &ii.vis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
|
||||||
defaultness,
|
defaultness,
|
||||||
ref attrs,
|
ref attrs,
|
||||||
ref generics,
|
ref generics,
|
||||||
ref node,
|
ref kind,
|
||||||
span
|
span
|
||||||
} = *self;
|
} = *self;
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem {
|
||||||
defaultness.hash_stable(hcx, hasher);
|
defaultness.hash_stable(hcx, hasher);
|
||||||
attrs.hash_stable(hcx, hasher);
|
attrs.hash_stable(hcx, hasher);
|
||||||
generics.hash_stable(hcx, hasher);
|
generics.hash_stable(hcx, hasher);
|
||||||
node.hash_stable(hcx, hasher);
|
kind.hash_stable(hcx, hasher);
|
||||||
span.hash_stable(hcx, hasher);
|
span.hash_stable(hcx, hasher);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn impl_item_scope_tag(item: &hir::ImplItem) -> &'static str {
|
fn impl_item_scope_tag(item: &hir::ImplItem) -> &'static str {
|
||||||
match item.node {
|
match item.kind {
|
||||||
hir::ImplItemKind::Method(..) => "method body",
|
hir::ImplItemKind::Method(..) => "method body",
|
||||||
hir::ImplItemKind::Const(..)
|
hir::ImplItemKind::Const(..)
|
||||||
| hir::ImplItemKind::OpaqueTy(..)
|
| hir::ImplItemKind::OpaqueTy(..)
|
||||||
|
|
|
@ -39,7 +39,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| Node::ImplItem(&hir::ImplItem {
|
| Node::ImplItem(&hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(ref m, ..),
|
kind: hir::ImplItemKind::Method(ref m, ..),
|
||||||
..
|
..
|
||||||
}) => &m.decl,
|
}) => &m.decl,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
||||||
(def_scope_default(), hir::OpaqueTyOrigin::TypeAlias)
|
(def_scope_default(), hir::OpaqueTyOrigin::TypeAlias)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(Node::ImplItem(item)) => match item.node {
|
Some(Node::ImplItem(item)) => match item.kind {
|
||||||
hir::ImplItemKind::OpaqueTy(_) => (
|
hir::ImplItemKind::OpaqueTy(_) => (
|
||||||
may_define_opaque_type(
|
may_define_opaque_type(
|
||||||
tcx,
|
tcx,
|
||||||
|
|
|
@ -626,7 +626,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(_, body_id) => {
|
hir::ImplItemKind::Const(_, body_id) => {
|
||||||
if !self.symbol_is_live(impl_item.hir_id) {
|
if !self.symbol_is_live(impl_item.hir_id) {
|
||||||
self.warn_dead_code(impl_item.hir_id,
|
self.warn_dead_code(impl_item.hir_id,
|
||||||
|
|
|
@ -55,7 +55,7 @@ fn method_might_be_inlined(
|
||||||
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.node {
|
if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.kind {
|
||||||
if method_sig.header.is_const() {
|
if method_sig.header.is_const() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Node::ImplItem(impl_item)) => {
|
Some(Node::ImplItem(impl_item)) => {
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(..) => true,
|
hir::ImplItemKind::Const(..) => true,
|
||||||
hir::ImplItemKind::Method(..) => {
|
hir::ImplItemKind::Method(..) => {
|
||||||
let attrs = self.tcx.codegen_fn_attrs(def_id);
|
let attrs = self.tcx.codegen_fn_attrs(def_id);
|
||||||
|
@ -299,7 +299,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node::ImplItem(impl_item) => {
|
Node::ImplItem(impl_item) => {
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(_, body) => {
|
hir::ImplItemKind::Const(_, body) => {
|
||||||
self.visit_nested_body(body);
|
self.visit_nested_body(body);
|
||||||
}
|
}
|
||||||
|
|
|
@ -830,7 +830,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||||
use self::hir::ImplItemKind::*;
|
use self::hir::ImplItemKind::*;
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
Method(ref sig, _) => {
|
Method(ref sig, _) => {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
self.visit_early_late(
|
self.visit_early_late(
|
||||||
|
@ -1530,7 +1530,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Node::ImplItem(impl_item) => {
|
Node::ImplItem(impl_item) => {
|
||||||
if let hir::ImplItemKind::Method(sig, _) = &impl_item.node {
|
if let hir::ImplItemKind::Method(sig, _) = &impl_item.kind {
|
||||||
find_arg_use_span(&sig.decl.inputs);
|
find_arg_use_span(&sig.decl.inputs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1875,7 +1875,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| Node::ImplItem(&hir::ImplItem {
|
| Node::ImplItem(&hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(..),
|
kind: hir::ImplItemKind::Method(..),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
let scope = self.tcx.hir().local_def_id(fn_id);
|
let scope = self.tcx.hir().local_def_id(fn_id);
|
||||||
|
@ -2190,7 +2190,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(_, body),
|
kind: hir::ImplItemKind::Method(_, body),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
|
if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
}) |
|
}) |
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
span,
|
span,
|
||||||
node: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
kind: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||||
..
|
..
|
||||||
}) |
|
}) |
|
||||||
Node::TraitItem(&hir::TraitItem {
|
Node::TraitItem(&hir::TraitItem {
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn reachable_non_generics_provider(
|
||||||
node: hir::ItemKind::Fn(..), ..
|
node: hir::ItemKind::Fn(..), ..
|
||||||
}) |
|
}) |
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(..),
|
kind: hir::ImplItemKind::Method(..),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
let def_id = tcx.hir().local_def_id(hir_id);
|
let def_id = tcx.hir().local_def_id(hir_id);
|
||||||
|
|
|
@ -404,7 +404,7 @@ impl DirtyCleanVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
HirNode::ImplItem(item) => {
|
HirNode::ImplItem(item) => {
|
||||||
match item.node {
|
match item.kind {
|
||||||
ImplItemKind::Method(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
|
ImplItemKind::Method(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL),
|
||||||
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
|
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
|
||||||
ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
|
ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
|
||||||
|
|
|
@ -806,7 +806,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
|
fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
|
||||||
let is_const = match i.node {
|
let is_const = match i.kind {
|
||||||
ast::ImplItemKind::Const(..) => true,
|
ast::ImplItemKind::Const(..) => true,
|
||||||
ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
|
ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
|
||||||
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
|
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
|
||||||
|
|
|
@ -459,7 +459,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let desc = match impl_item.node {
|
let desc = match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(..) => "an associated constant",
|
hir::ImplItemKind::Const(..) => "an associated constant",
|
||||||
hir::ImplItemKind::Method(..) => "a method",
|
hir::ImplItemKind::Method(..) => "a method",
|
||||||
hir::ImplItemKind::TyAlias(_) => "an associated type",
|
hir::ImplItemKind::TyAlias(_) => "an associated type",
|
||||||
|
|
|
@ -405,7 +405,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem) {
|
fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem) {
|
||||||
if let hir::ImplItemKind::Const(..) = ii.node {
|
if let hir::ImplItemKind::Const(..) = ii.kind {
|
||||||
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident);
|
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -970,7 +970,7 @@ impl EncodeContext<'tcx> {
|
||||||
|
|
||||||
let kind = match impl_item.kind {
|
let kind = match impl_item.kind {
|
||||||
ty::AssocKind::Const => {
|
ty::AssocKind::Const => {
|
||||||
if let hir::ImplItemKind::Const(_, body_id) = ast_item.node {
|
if let hir::ImplItemKind::Const(_, body_id) = ast_item.kind {
|
||||||
let mir = self.tcx.at(ast_item.span).mir_const_qualif(def_id).0;
|
let mir = self.tcx.at(ast_item.span).mir_const_qualif(def_id).0;
|
||||||
|
|
||||||
EntryKind::AssocConst(container,
|
EntryKind::AssocConst(container,
|
||||||
|
@ -981,7 +981,7 @@ impl EncodeContext<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::AssocKind::Method => {
|
ty::AssocKind::Method => {
|
||||||
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
|
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.kind {
|
||||||
FnData {
|
FnData {
|
||||||
asyncness: sig.header.asyncness,
|
asyncness: sig.header.asyncness,
|
||||||
constness: sig.header.constness,
|
constness: sig.header.constness,
|
||||||
|
@ -1001,21 +1001,20 @@ impl EncodeContext<'tcx> {
|
||||||
ty::AssocKind::Type => EntryKind::AssocType(container)
|
ty::AssocKind::Type => EntryKind::AssocType(container)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mir =
|
let mir = match ast_item.kind {
|
||||||
match ast_item.node {
|
hir::ImplItemKind::Const(..) => true,
|
||||||
hir::ImplItemKind::Const(..) => true,
|
hir::ImplItemKind::Method(ref sig, _) => {
|
||||||
hir::ImplItemKind::Method(ref sig, _) => {
|
let generics = self.tcx.generics_of(def_id);
|
||||||
let generics = self.tcx.generics_of(def_id);
|
let needs_inline = (generics.requires_monomorphization(self.tcx) ||
|
||||||
let needs_inline = (generics.requires_monomorphization(self.tcx) ||
|
tcx.codegen_fn_attrs(def_id).requests_inline()) &&
|
||||||
tcx.codegen_fn_attrs(def_id).requests_inline()) &&
|
!self.metadata_output_only();
|
||||||
!self.metadata_output_only();
|
let is_const_fn = sig.header.constness == hir::Constness::Const;
|
||||||
let is_const_fn = sig.header.constness == hir::Constness::Const;
|
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
|
||||||
let always_encode_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir;
|
needs_inline || is_const_fn || always_encode_mir
|
||||||
needs_inline || is_const_fn || always_encode_mir
|
},
|
||||||
},
|
hir::ImplItemKind::OpaqueTy(..) |
|
||||||
hir::ImplItemKind::OpaqueTy(..) |
|
hir::ImplItemKind::TyAlias(..) => false,
|
||||||
hir::ImplItemKind::TyAlias(..) => false,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
Entry {
|
Entry {
|
||||||
kind,
|
kind,
|
||||||
|
|
|
@ -772,7 +772,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
hir::Node::ImplItem(hir::ImplItem {
|
hir::Node::ImplItem(hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(method_sig, _),
|
kind: hir::ImplItemKind::Method(method_sig, _),
|
||||||
..
|
..
|
||||||
}) => (method_sig.decl.output.span(), ""),
|
}) => (method_sig.decl.output.span(), ""),
|
||||||
_ => (body.span, ""),
|
_ => (body.span, ""),
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||||
| Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
| Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. })
|
||||||
| Node::ImplItem(
|
| Node::ImplItem(
|
||||||
hir::ImplItem {
|
hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
|
kind: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id),
|
||||||
..
|
..
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -48,7 +48,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||||
}
|
}
|
||||||
Node::Item(hir::Item { node: hir::ItemKind::Static(ty, _, body_id), .. })
|
Node::Item(hir::Item { node: hir::ItemKind::Static(ty, _, body_id), .. })
|
||||||
| Node::Item(hir::Item { node: hir::ItemKind::Const(ty, body_id), .. })
|
| Node::Item(hir::Item { node: hir::ItemKind::Const(ty, body_id), .. })
|
||||||
| Node::ImplItem(hir::ImplItem { node: hir::ImplItemKind::Const(ty, body_id), .. })
|
| Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, body_id), .. })
|
||||||
| Node::TraitItem(
|
| Node::TraitItem(
|
||||||
hir::TraitItem { node: hir::TraitItemKind::Const(ty, Some(body_id)), .. }
|
hir::TraitItem { node: hir::TraitItemKind::Const(ty, Some(body_id)), .. }
|
||||||
) => {
|
) => {
|
||||||
|
|
|
@ -1058,7 +1058,7 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
|
fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
|
||||||
match ii.node {
|
match ii.kind {
|
||||||
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
|
hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
|
||||||
let def_id = self.tcx.hir().local_def_id(ii.hir_id);
|
let def_id = self.tcx.hir().local_def_id(ii.hir_id);
|
||||||
self.push_if_root(def_id);
|
self.push_if_root(def_id);
|
||||||
|
|
|
@ -551,7 +551,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
}
|
}
|
||||||
for impl_item in impl_items {
|
for impl_item in impl_items {
|
||||||
self.invalid_visibility(&impl_item.vis, None);
|
self.invalid_visibility(&impl_item.vis, None);
|
||||||
if let ImplItemKind::Method(ref sig, _) = impl_item.node {
|
if let ImplItemKind::Method(ref sig, _) = impl_item.kind {
|
||||||
self.check_trait_fn_not_const(sig.header.constness);
|
self.check_trait_fn_not_const(sig.header.constness);
|
||||||
self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node);
|
self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node);
|
||||||
}
|
}
|
||||||
|
@ -832,11 +832,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
fn visit_impl_item(&mut self, ii: &'a ImplItem) {
|
||||||
match ii.node {
|
if let ImplItemKind::Method(ref sig, _) = ii.kind {
|
||||||
ImplItemKind::Method(ref sig, _) => {
|
self.check_fn_decl(&sig.decl);
|
||||||
self.check_fn_decl(&sig.decl);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
visit::walk_impl_item(self, ii);
|
visit::walk_impl_item(self, ii);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1489,7 +1489,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||||
impl_item_refs.iter()
|
impl_item_refs.iter()
|
||||||
.any(|impl_item_ref| {
|
.any(|impl_item_ref| {
|
||||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(..) |
|
hir::ImplItemKind::Const(..) |
|
||||||
hir::ImplItemKind::Method(..) => {
|
hir::ImplItemKind::Method(..) => {
|
||||||
self.access_levels.is_reachable(
|
self.access_levels.is_reachable(
|
||||||
|
@ -1515,7 +1515,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||||
// don't erroneously report errors for private
|
// don't erroneously report errors for private
|
||||||
// types in private items.
|
// types in private items.
|
||||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(..) |
|
hir::ImplItemKind::Const(..) |
|
||||||
hir::ImplItemKind::Method(..)
|
hir::ImplItemKind::Method(..)
|
||||||
if self.item_is_public(&impl_item.hir_id, &impl_item.vis) =>
|
if self.item_is_public(&impl_item.hir_id, &impl_item.vis) =>
|
||||||
|
@ -1548,7 +1548,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||||
// Those in 3. are warned with this call.
|
// Those in 3. are warned with this call.
|
||||||
for impl_item_ref in impl_item_refs {
|
for impl_item_ref in impl_item_refs {
|
||||||
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
|
||||||
if let hir::ImplItemKind::TyAlias(ref ty) = impl_item.node {
|
if let hir::ImplItemKind::TyAlias(ref ty) = impl_item.kind {
|
||||||
self.visit_ty(ty);
|
self.visit_ty(ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1132,7 +1132,7 @@ macro_rules! method {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
||||||
method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item, node);
|
method!(visit_impl_item: ast::ImplItem, ast::ImplItemKind::Macro, walk_impl_item, kind);
|
||||||
method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr, kind);
|
method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr, kind);
|
||||||
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, kind);
|
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat, kind);
|
||||||
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty, node);
|
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty, node);
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
||||||
AssocItemRibKind);
|
AssocItemRibKind);
|
||||||
this.with_generic_param_rib(generic_params, |this| {
|
this.with_generic_param_rib(generic_params, |this| {
|
||||||
use crate::ResolutionError::*;
|
use crate::ResolutionError::*;
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
ImplItemKind::Const(..) => {
|
ImplItemKind::Const(..) => {
|
||||||
debug!(
|
debug!(
|
||||||
"resolve_implementation ImplItemKind::Const",
|
"resolve_implementation ImplItemKind::Const",
|
||||||
|
|
|
@ -1078,7 +1078,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
||||||
|
|
||||||
fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
|
fn process_impl_item(&mut self, impl_item: &'l ast::ImplItem, impl_id: DefId) {
|
||||||
self.process_macro_use(impl_item.span);
|
self.process_macro_use(impl_item.span);
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
ast::ImplItemKind::Const(ref ty, ref expr) => {
|
ast::ImplItemKind::Const(ref ty, ref expr) => {
|
||||||
self.process_assoc_const(
|
self.process_assoc_const(
|
||||||
impl_item.id,
|
impl_item.id,
|
||||||
|
|
|
@ -200,7 +200,7 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {
|
||||||
_ => NodeKind::Other,
|
_ => NodeKind::Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::ImplItem(item) => match item.node {
|
Node::ImplItem(item) => match item.kind {
|
||||||
ImplItemKind::Method(..) => NodeKind::Fn,
|
ImplItemKind::Method(..) => NodeKind::Fn,
|
||||||
_ => NodeKind::Other,
|
_ => NodeKind::Other,
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,7 +425,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
||||||
let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap();
|
let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap();
|
||||||
let (impl_m_output, impl_m_iter) = match tcx.hir()
|
let (impl_m_output, impl_m_iter) = match tcx.hir()
|
||||||
.expect_impl_item(impl_m_hir_id)
|
.expect_impl_item(impl_m_hir_id)
|
||||||
.node {
|
.kind {
|
||||||
ImplItemKind::Method(ref impl_m_sig, _) => {
|
ImplItemKind::Method(ref impl_m_sig, _) => {
|
||||||
(&impl_m_sig.decl.output, impl_m_sig.decl.inputs.iter())
|
(&impl_m_sig.decl.output, impl_m_sig.decl.inputs.iter())
|
||||||
}
|
}
|
||||||
|
@ -740,7 +740,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||||
trait_item_span
|
trait_item_span
|
||||||
};
|
};
|
||||||
let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap();
|
let impl_m_hir_id = tcx.hir().as_local_hir_id(impl_m.def_id).unwrap();
|
||||||
let impl_span = match tcx.hir().expect_impl_item(impl_m_hir_id).node {
|
let impl_span = match tcx.hir().expect_impl_item(impl_m_hir_id).kind {
|
||||||
ImplItemKind::Method(ref impl_m_sig, _) => {
|
ImplItemKind::Method(ref impl_m_sig, _) => {
|
||||||
let pos = if impl_number_args > 0 {
|
let pos = if impl_number_args > 0 {
|
||||||
impl_number_args - 1
|
impl_number_args - 1
|
||||||
|
@ -883,7 +883,7 @@ fn compare_synthetic_generics<'tcx>(
|
||||||
(|| {
|
(|| {
|
||||||
let impl_m = tcx.hir().as_local_hir_id(impl_m.def_id)?;
|
let impl_m = tcx.hir().as_local_hir_id(impl_m.def_id)?;
|
||||||
let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m });
|
let impl_m = tcx.hir().impl_item(hir::ImplItemId { hir_id: impl_m });
|
||||||
let input_tys = match impl_m.node {
|
let input_tys = match impl_m.kind {
|
||||||
hir::ImplItemKind::Method(ref sig, _) => &sig.decl.inputs,
|
hir::ImplItemKind::Method(ref sig, _) => &sig.decl.inputs,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
@ -1014,7 +1014,7 @@ pub fn compare_const_impl<'tcx>(
|
||||||
trait_ty);
|
trait_ty);
|
||||||
|
|
||||||
// Locate the Span containing just the type of the offending impl
|
// Locate the Span containing just the type of the offending impl
|
||||||
match tcx.hir().expect_impl_item(impl_c_hir_id).node {
|
match tcx.hir().expect_impl_item(impl_c_hir_id).kind {
|
||||||
ImplItemKind::Const(ref ty, _) => cause.span = ty.span,
|
ImplItemKind::Const(ref ty, _) => cause.span = ty.span,
|
||||||
_ => bug!("{:?} is not a impl const", impl_c),
|
_ => bug!("{:?} is not a impl const", impl_c),
|
||||||
}
|
}
|
||||||
|
|
|
@ -813,7 +813,7 @@ fn primary_body_of(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Node::ImplItem(item) => {
|
Node::ImplItem(item) => {
|
||||||
match item.node {
|
match item.kind {
|
||||||
hir::ImplItemKind::Const(ref ty, body) =>
|
hir::ImplItemKind::Const(ref ty, body) =>
|
||||||
Some((body, Some(ty), None, None)),
|
Some((body, Some(ty), None, None)),
|
||||||
hir::ImplItemKind::Method(ref sig, body) =>
|
hir::ImplItemKind::Method(ref sig, body) =>
|
||||||
|
@ -1681,7 +1681,7 @@ fn check_specialization_validity<'tcx>(
|
||||||
) {
|
) {
|
||||||
let ancestors = trait_def.ancestors(tcx, impl_id);
|
let ancestors = trait_def.ancestors(tcx, impl_id);
|
||||||
|
|
||||||
let kind = match impl_item.node {
|
let kind = match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(..) => ty::AssocKind::Const,
|
hir::ImplItemKind::Const(..) => ty::AssocKind::Const,
|
||||||
hir::ImplItemKind::Method(..) => ty::AssocKind::Method,
|
hir::ImplItemKind::Method(..) => ty::AssocKind::Method,
|
||||||
hir::ImplItemKind::OpaqueTy(..) => ty::AssocKind::OpaqueTy,
|
hir::ImplItemKind::OpaqueTy(..) => ty::AssocKind::OpaqueTy,
|
||||||
|
@ -1725,7 +1725,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||||
let ty_impl_item = tcx.associated_item(
|
let ty_impl_item = tcx.associated_item(
|
||||||
tcx.hir().local_def_id(impl_item.hir_id));
|
tcx.hir().local_def_id(impl_item.hir_id));
|
||||||
let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id)
|
let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id)
|
||||||
.find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) &&
|
.find(|ac| Namespace::from(&impl_item.kind) == Namespace::from(ac.kind) &&
|
||||||
tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id))
|
tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id))
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
// Not compatible, but needed for the error message
|
// Not compatible, but needed for the error message
|
||||||
|
@ -1735,7 +1735,7 @@ fn check_impl_items_against_trait<'tcx>(
|
||||||
|
|
||||||
// Check that impl definition matches trait definition
|
// Check that impl definition matches trait definition
|
||||||
if let Some(ty_trait_item) = ty_trait_item {
|
if let Some(ty_trait_item) = ty_trait_item {
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
hir::ImplItemKind::Const(..) => {
|
hir::ImplItemKind::Const(..) => {
|
||||||
// Find associated const definition.
|
// Find associated const definition.
|
||||||
if ty_trait_item.kind == ty::AssocKind::Const {
|
if ty_trait_item.kind == ty::AssocKind::Const {
|
||||||
|
@ -4072,7 +4072,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
node: hir::ItemKind::Fn(_, _, _, body_id), ..
|
node: hir::ItemKind::Fn(_, _, _, body_id), ..
|
||||||
}) |
|
}) |
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(_, body_id), ..
|
kind: hir::ImplItemKind::Method(_, body_id), ..
|
||||||
}) => {
|
}) => {
|
||||||
let body = self.tcx.hir().body(body_id);
|
let body = self.tcx.hir().body(body_id);
|
||||||
if let ExprKind::Block(block, _) = &body.value.kind {
|
if let ExprKind::Block(block, _) = &body.value.kind {
|
||||||
|
@ -4107,7 +4107,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}, ..), ..
|
}, ..), ..
|
||||||
}) => Some((decl, ident, true)),
|
}) => Some((decl, ident, true)),
|
||||||
Node::ImplItem(&hir::ImplItem {
|
Node::ImplItem(&hir::ImplItem {
|
||||||
ident, node: hir::ImplItemKind::Method(hir::MethodSig {
|
ident, kind: hir::ImplItemKind::Method(hir::MethodSig {
|
||||||
ref decl, ..
|
ref decl, ..
|
||||||
}, ..), ..
|
}, ..), ..
|
||||||
}) => Some((decl, ident, false)),
|
}) => Some((decl, ident, false)),
|
||||||
|
@ -4196,7 +4196,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
..
|
..
|
||||||
})) |
|
})) |
|
||||||
Some(Node::ImplItem(hir::ImplItem {
|
Some(Node::ImplItem(hir::ImplItem {
|
||||||
node: hir::ImplItemKind::Method(_, body_id),
|
kind: hir::ImplItemKind::Method(_, body_id),
|
||||||
..
|
..
|
||||||
})) |
|
})) |
|
||||||
Some(Node::TraitItem(hir::TraitItem {
|
Some(Node::TraitItem(hir::TraitItem {
|
||||||
|
|
|
@ -178,7 +178,7 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: DefId) {
|
||||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||||
let impl_item = tcx.hir().expect_impl_item(hir_id);
|
let impl_item = tcx.hir().expect_impl_item(hir_id);
|
||||||
|
|
||||||
let method_sig = match impl_item.node {
|
let method_sig = match impl_item.kind {
|
||||||
hir::ImplItemKind::Method(ref sig, _) => Some(sig),
|
hir::ImplItemKind::Method(ref sig, _) => Some(sig),
|
||||||
_ => None
|
_ => None
|
||||||
};
|
};
|
||||||
|
|
|
@ -507,7 +507,7 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
|
||||||
tcx.generics_of(def_id);
|
tcx.generics_of(def_id);
|
||||||
tcx.type_of(def_id);
|
tcx.type_of(def_id);
|
||||||
tcx.predicates_of(def_id);
|
tcx.predicates_of(def_id);
|
||||||
if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).node {
|
if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).kind {
|
||||||
tcx.fn_sig(def_id);
|
tcx.fn_sig(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,7 +866,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
Node::ImplItem(item) => match item.node {
|
Node::ImplItem(item) => match item.kind {
|
||||||
hir::ImplItemKind::Method(ref sig, _) => {
|
hir::ImplItemKind::Method(ref sig, _) => {
|
||||||
has_late_bound_regions(tcx, &item.generics, &sig.decl)
|
has_late_bound_regions(tcx, &item.generics, &sig.decl)
|
||||||
}
|
}
|
||||||
|
@ -1230,7 +1230,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Node::ImplItem(item) => match item.node {
|
Node::ImplItem(item) => match item.kind {
|
||||||
ImplItemKind::Method(..) => {
|
ImplItemKind::Method(..) => {
|
||||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||||
tcx.mk_fn_def(def_id, substs)
|
tcx.mk_fn_def(def_id, substs)
|
||||||
|
@ -1790,7 +1790,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| ImplItem(hir::ImplItem {
|
| ImplItem(hir::ImplItem {
|
||||||
node: ImplItemKind::Method(MethodSig { header, decl }, _),
|
kind: ImplItemKind::Method(MethodSig { header, decl }, _),
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
| Item(hir::Item {
|
| Item(hir::Item {
|
||||||
|
@ -2055,7 +2055,7 @@ fn explicit_predicates_of(
|
||||||
let ast_generics = match node {
|
let ast_generics = match node {
|
||||||
Node::TraitItem(item) => &item.generics,
|
Node::TraitItem(item) => &item.generics,
|
||||||
|
|
||||||
Node::ImplItem(item) => match item.node {
|
Node::ImplItem(item) => match item.kind {
|
||||||
ImplItemKind::OpaqueTy(ref bounds) => {
|
ImplItemKind::OpaqueTy(ref bounds) => {
|
||||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||||
let opaque_ty = tcx.mk_opaque(def_id, substs);
|
let opaque_ty = tcx.mk_opaque(def_id, substs);
|
||||||
|
|
|
@ -197,7 +197,7 @@ fn enforce_impl_items_are_distinct(tcx: TyCtxt<'_>, impl_item_refs: &[hir::ImplI
|
||||||
let mut seen_value_items = FxHashMap::default();
|
let mut seen_value_items = FxHashMap::default();
|
||||||
for impl_item_ref in impl_item_refs {
|
for impl_item_ref in impl_item_refs {
|
||||||
let impl_item = tcx.hir().impl_item(impl_item_ref.id);
|
let impl_item = tcx.hir().impl_item(impl_item_ref.id);
|
||||||
let seen_items = match impl_item.node {
|
let seen_items = match impl_item.kind {
|
||||||
hir::ImplItemKind::TyAlias(_) => &mut seen_type_items,
|
hir::ImplItemKind::TyAlias(_) => &mut seen_type_items,
|
||||||
_ => &mut seen_value_items,
|
_ => &mut seen_value_items,
|
||||||
};
|
};
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
|
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
|
||||||
if let hir::ImplItemKind::Method(..) = impl_item.node {
|
if let hir::ImplItemKind::Method(..) = impl_item.kind {
|
||||||
self.visit_node_helper(impl_item.hir_id);
|
self.visit_node_helper(impl_item.hir_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] {
|
||||||
_ => unsupported()
|
_ => unsupported()
|
||||||
},
|
},
|
||||||
|
|
||||||
Node::ImplItem(item) => match item.node {
|
Node::ImplItem(item) => match item.kind {
|
||||||
hir::ImplItemKind::Method(..) => {}
|
hir::ImplItemKind::Method(..) => {}
|
||||||
|
|
||||||
_ => unsupported()
|
_ => unsupported()
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
|
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
|
||||||
if let hir::ImplItemKind::Method(..) = impl_item.node {
|
if let hir::ImplItemKind::Method(..) = impl_item.kind {
|
||||||
self.add_inferreds_for_item(impl_item.hir_id);
|
self.add_inferreds_for_item(impl_item.hir_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2321,7 +2321,7 @@ impl Clean<Item> for hir::TraitItem {
|
||||||
|
|
||||||
impl Clean<Item> for hir::ImplItem {
|
impl Clean<Item> for hir::ImplItem {
|
||||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||||
let inner = match self.node {
|
let inner = match self.kind {
|
||||||
hir::ImplItemKind::Const(ref ty, expr) => {
|
hir::ImplItemKind::Const(ref ty, expr) => {
|
||||||
AssocConstItem(ty.clean(cx),
|
AssocConstItem(ty.clean(cx),
|
||||||
Some(print_const_expr(cx, expr)))
|
Some(print_const_expr(cx, expr)))
|
||||||
|
|
|
@ -1497,7 +1497,7 @@ pub struct ImplItem {
|
||||||
pub defaultness: Defaultness,
|
pub defaultness: Defaultness,
|
||||||
pub attrs: Vec<Attribute>,
|
pub attrs: Vec<Attribute>,
|
||||||
pub generics: Generics,
|
pub generics: Generics,
|
||||||
pub node: ImplItemKind,
|
pub kind: ImplItemKind,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
/// See `Item::tokens` for what this is.
|
/// See `Item::tokens` for what this is.
|
||||||
pub tokens: Option<TokenStream>,
|
pub tokens: Option<TokenStream>,
|
||||||
|
|
|
@ -1337,7 +1337,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
||||||
AstFragmentKind::ImplItems, after_derive).make_impl_items();
|
AstFragmentKind::ImplItems, after_derive).make_impl_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
match item.node {
|
match item.kind {
|
||||||
ast::ImplItemKind::Macro(mac) => {
|
ast::ImplItemKind::Macro(mac) => {
|
||||||
let ast::ImplItem { attrs, span, .. } = item;
|
let ast::ImplItem { attrs, span, .. } = item;
|
||||||
self.check_attributes(&attrs);
|
self.check_attributes(&attrs);
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
|
||||||
}]),
|
}]),
|
||||||
AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![ast::ImplItem {
|
AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![ast::ImplItem {
|
||||||
id, span, ident, vis, attrs, generics,
|
id, span, ident, vis, attrs, generics,
|
||||||
node: ast::ImplItemKind::Macro(mac_placeholder()),
|
kind: ast::ImplItemKind::Macro(mac_placeholder()),
|
||||||
defaultness: ast::Defaultness::Final,
|
defaultness: ast::Defaultness::Final,
|
||||||
tokens: None,
|
tokens: None,
|
||||||
}]),
|
}]),
|
||||||
|
@ -268,7 +268,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flat_map_impl_item(&mut self, item: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
|
fn flat_map_impl_item(&mut self, item: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
|
||||||
match item.node {
|
match item.kind {
|
||||||
ast::ImplItemKind::Macro(_) => self.remove(item.id).make_impl_items(),
|
ast::ImplItemKind::Macro(_) => self.remove(item.id).make_impl_items(),
|
||||||
_ => noop_flat_map_impl_item(item, self),
|
_ => noop_flat_map_impl_item(item, self),
|
||||||
}
|
}
|
||||||
|
|
|
@ -600,7 +600,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||||
"specialization is unstable");
|
"specialization is unstable");
|
||||||
}
|
}
|
||||||
|
|
||||||
match ii.node {
|
match ii.kind {
|
||||||
ast::ImplItemKind::Method(..) => {}
|
ast::ImplItemKind::Method(..) => {}
|
||||||
ast::ImplItemKind::OpaqueTy(..) => {
|
ast::ImplItemKind::OpaqueTy(..) => {
|
||||||
gate_feature_post!(
|
gate_feature_post!(
|
||||||
|
|
|
@ -951,14 +951,14 @@ pub fn noop_flat_map_trait_item<T: MutVisitor>(mut item: TraitItem, vis: &mut T)
|
||||||
pub fn noop_flat_map_impl_item<T: MutVisitor>(mut item: ImplItem, visitor: &mut T)
|
pub fn noop_flat_map_impl_item<T: MutVisitor>(mut item: ImplItem, visitor: &mut T)
|
||||||
-> SmallVec<[ImplItem; 1]>
|
-> SmallVec<[ImplItem; 1]>
|
||||||
{
|
{
|
||||||
let ImplItem { id, ident, vis, defaultness: _, attrs, generics, node, span, tokens: _ } =
|
let ImplItem { id, ident, vis, defaultness: _, attrs, generics, kind, span, tokens: _ } =
|
||||||
&mut item;
|
&mut item;
|
||||||
visitor.visit_id(id);
|
visitor.visit_id(id);
|
||||||
visitor.visit_ident(ident);
|
visitor.visit_ident(ident);
|
||||||
visitor.visit_vis(vis);
|
visitor.visit_vis(vis);
|
||||||
visit_attrs(attrs, visitor);
|
visit_attrs(attrs, visitor);
|
||||||
visitor.visit_generics(generics);
|
visitor.visit_generics(generics);
|
||||||
match node {
|
match kind {
|
||||||
ImplItemKind::Const(ty, expr) => {
|
ImplItemKind::Const(ty, expr) => {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
visitor.visit_expr(expr);
|
visitor.visit_expr(expr);
|
||||||
|
|
|
@ -783,7 +783,7 @@ impl<'a> Parser<'a> {
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
let vis = self.parse_visibility(false)?;
|
let vis = self.parse_visibility(false)?;
|
||||||
let defaultness = self.parse_defaultness();
|
let defaultness = self.parse_defaultness();
|
||||||
let (name, node, generics) = if let Some(type_) = self.eat_type() {
|
let (name, kind, generics) = if let Some(type_) = self.eat_type() {
|
||||||
let (name, alias, generics) = type_?;
|
let (name, alias, generics) = type_?;
|
||||||
let kind = match alias {
|
let kind = match alias {
|
||||||
AliasKind::Weak(typ) => ast::ImplItemKind::TyAlias(typ),
|
AliasKind::Weak(typ) => ast::ImplItemKind::TyAlias(typ),
|
||||||
|
@ -802,9 +802,9 @@ impl<'a> Parser<'a> {
|
||||||
self.expect(&token::Semi)?;
|
self.expect(&token::Semi)?;
|
||||||
(name, ast::ImplItemKind::Const(typ, expr), Generics::default())
|
(name, ast::ImplItemKind::Const(typ, expr), Generics::default())
|
||||||
} else {
|
} else {
|
||||||
let (name, inner_attrs, generics, node) = self.parse_impl_method(&vis, at_end)?;
|
let (name, inner_attrs, generics, kind) = self.parse_impl_method(&vis, at_end)?;
|
||||||
attrs.extend(inner_attrs);
|
attrs.extend(inner_attrs);
|
||||||
(name, node, generics)
|
(name, kind, generics)
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(ImplItem {
|
Ok(ImplItem {
|
||||||
|
@ -815,7 +815,7 @@ impl<'a> Parser<'a> {
|
||||||
defaultness,
|
defaultness,
|
||||||
attrs,
|
attrs,
|
||||||
generics,
|
generics,
|
||||||
node,
|
kind,
|
||||||
tokens: None,
|
tokens: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1597,7 +1597,7 @@ impl<'a> State<'a> {
|
||||||
self.maybe_print_comment(ii.span.lo());
|
self.maybe_print_comment(ii.span.lo());
|
||||||
self.print_outer_attributes(&ii.attrs);
|
self.print_outer_attributes(&ii.attrs);
|
||||||
self.print_defaultness(ii.defaultness);
|
self.print_defaultness(ii.defaultness);
|
||||||
match ii.node {
|
match ii.kind {
|
||||||
ast::ImplItemKind::Const(ref ty, ref expr) => {
|
ast::ImplItemKind::Const(ref ty, ref expr) => {
|
||||||
self.print_associated_const(ii.ident, ty, Some(expr), &ii.vis);
|
self.print_associated_const(ii.ident, ty, Some(expr), &ii.vis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -617,7 +617,7 @@ pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplIt
|
||||||
visitor.visit_ident(impl_item.ident);
|
visitor.visit_ident(impl_item.ident);
|
||||||
walk_list!(visitor, visit_attribute, &impl_item.attrs);
|
walk_list!(visitor, visit_attribute, &impl_item.attrs);
|
||||||
visitor.visit_generics(&impl_item.generics);
|
visitor.visit_generics(&impl_item.generics);
|
||||||
match impl_item.node {
|
match impl_item.kind {
|
||||||
ImplItemKind::Const(ref ty, ref expr) => {
|
ImplItemKind::Const(ref ty, ref expr) => {
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
visitor.visit_expr(expr);
|
visitor.visit_expr(expr);
|
||||||
|
|
|
@ -530,7 +530,7 @@ impl<'a> TraitDef<'a> {
|
||||||
defaultness: ast::Defaultness::Final,
|
defaultness: ast::Defaultness::Final,
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
generics: Generics::default(),
|
generics: Generics::default(),
|
||||||
node: ast::ImplItemKind::TyAlias(
|
kind: ast::ImplItemKind::TyAlias(
|
||||||
type_def.to_ty(cx, self.span, type_ident, generics)),
|
type_def.to_ty(cx, self.span, type_ident, generics)),
|
||||||
tokens: None,
|
tokens: None,
|
||||||
}
|
}
|
||||||
|
@ -960,7 +960,7 @@ impl<'a> MethodDef<'a> {
|
||||||
vis: respan(trait_.span.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
vis: respan(trait_.span.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||||
defaultness: ast::Defaultness::Final,
|
defaultness: ast::Defaultness::Final,
|
||||||
ident: method_ident,
|
ident: method_ident,
|
||||||
node: ast::ImplItemKind::Method(ast::MethodSig {
|
kind: ast::ImplItemKind::Method(ast::MethodSig {
|
||||||
header: ast::FnHeader {
|
header: ast::FnHeader {
|
||||||
unsafety, abi,
|
unsafety, abi,
|
||||||
..ast::FnHeader::default()
|
..ast::FnHeader::default()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue