Rename TraitItem.node
to TraitItem.kind
This commit is contained in:
parent
17726f6b52
commit
d4573c9c1e
@ -856,7 +856,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
|
||||
visitor.visit_ident(trait_item.ident);
|
||||
walk_list!(visitor, visit_attribute, &trait_item.attrs);
|
||||
visitor.visit_generics(&trait_item.generics);
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
TraitItemKind::Const(ref ty, default) => {
|
||||
visitor.visit_id(trait_item.hir_id);
|
||||
visitor.visit_ty(ty);
|
||||
|
@ -469,7 +469,7 @@ impl<'a> LoweringContext<'a> {
|
||||
fn visit_trait_item(&mut self, item: &'tcx TraitItem) {
|
||||
self.lctx.allocate_hir_id_counter(item.id);
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Method(_, None) => {
|
||||
// Ignore patterns in trait methods without bodies
|
||||
self.with_hir_id_owner(None, |this| {
|
||||
|
@ -818,7 +818,7 @@ impl LoweringContext<'_> {
|
||||
fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
|
||||
let trait_item_def_id = self.resolver.definitions().local_def_id(i.id);
|
||||
|
||||
let (generics, node) = match i.node {
|
||||
let (generics, kind) = match i.kind {
|
||||
TraitItemKind::Const(ref ty, ref default) => (
|
||||
self.lower_generics(&i.generics, ImplTraitContext::disallowed()),
|
||||
hir::TraitItemKind::Const(
|
||||
@ -852,14 +852,14 @@ impl LoweringContext<'_> {
|
||||
}
|
||||
TraitItemKind::Type(ref bounds, ref default) => {
|
||||
let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
|
||||
let node = hir::TraitItemKind::Type(
|
||||
let kind = hir::TraitItemKind::Type(
|
||||
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
|
||||
default
|
||||
.as_ref()
|
||||
.map(|x| self.lower_ty(x, ImplTraitContext::disallowed())),
|
||||
);
|
||||
|
||||
(generics, node)
|
||||
(generics, kind)
|
||||
},
|
||||
TraitItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"),
|
||||
};
|
||||
@ -869,13 +869,13 @@ impl LoweringContext<'_> {
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(&i.attrs),
|
||||
generics,
|
||||
node,
|
||||
kind,
|
||||
span: i.span,
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_trait_item_ref(&mut self, i: &TraitItem) -> hir::TraitItemRef {
|
||||
let (kind, has_default) = match i.node {
|
||||
let (kind, has_default) = match i.kind {
|
||||
TraitItemKind::Const(_, ref default) => {
|
||||
(hir::AssocItemKind::Const, default.is_some())
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl MaybeFnLike for ast::ImplItem {
|
||||
|
||||
impl MaybeFnLike for ast::TraitItem {
|
||||
fn is_fn_like(&self) -> bool {
|
||||
match self.node {
|
||||
match self.kind {
|
||||
ast::TraitItemKind::Method(_, ast::TraitMethod::Provided(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
@ -230,7 +230,7 @@ impl<'a> FnLikeNode<'a> {
|
||||
}),
|
||||
_ => bug!("item FnLikeNode that is not fn-like"),
|
||||
},
|
||||
map::Node::TraitItem(ti) => match ti.node {
|
||||
map::Node::TraitItem(ti) => match ti.kind {
|
||||
ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
|
||||
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'a TraitItem) {
|
||||
let def_data = match ti.node {
|
||||
let def_data = match ti.kind {
|
||||
TraitItemKind::Method(..) | TraitItemKind::Const(..) =>
|
||||
DefPathData::ValueNs(ti.ident.as_interned_str()),
|
||||
TraitItemKind::Type(..) => {
|
||||
|
@ -57,7 +57,7 @@ impl<'hir> Entry<'hir> {
|
||||
}
|
||||
|
||||
Node::TraitItem(ref item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
|
||||
_ => None
|
||||
}
|
||||
@ -93,7 +93,7 @@ impl<'hir> Entry<'hir> {
|
||||
}
|
||||
|
||||
Node::TraitItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Const(_, Some(body)) |
|
||||
TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body),
|
||||
_ => None
|
||||
@ -320,7 +320,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
}
|
||||
Node::TraitItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Const(..) => DefKind::AssocConst,
|
||||
TraitItemKind::Method(..) => DefKind::Method,
|
||||
TraitItemKind::Type(..) => DefKind::AssocTy,
|
||||
@ -454,14 +454,14 @@ impl<'hir> Map<'hir> {
|
||||
pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
|
||||
match self.get(id) {
|
||||
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { kind: TraitItemKind::Const(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { kind: ImplItemKind::Const(..), .. }) |
|
||||
Node::AnonConst(_) => {
|
||||
BodyOwnerKind::Const
|
||||
}
|
||||
Node::Ctor(..) |
|
||||
Node::Item(&Item { node: ItemKind::Fn(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { node: TraitItemKind::Method(..), .. }) |
|
||||
Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. }) |
|
||||
Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => {
|
||||
BodyOwnerKind::Fn
|
||||
}
|
||||
@ -653,7 +653,7 @@ impl<'hir> Map<'hir> {
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&TraitItem {
|
||||
node: TraitItemKind::Const(..),
|
||||
kind: TraitItemKind::Const(..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&ImplItem {
|
||||
@ -826,7 +826,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
},
|
||||
Node::TraitItem(ti) => {
|
||||
match ti.node {
|
||||
match ti.kind {
|
||||
TraitItemKind::Method(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
@ -1326,7 +1326,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
|
||||
}
|
||||
}
|
||||
Some(Node::TraitItem(ti)) => {
|
||||
let kind = match ti.node {
|
||||
let kind = match ti.kind {
|
||||
TraitItemKind::Const(..) => "assoc constant",
|
||||
TraitItemKind::Method(..) => "trait method",
|
||||
TraitItemKind::Type(..) => "assoc type",
|
||||
|
@ -1830,7 +1830,7 @@ pub struct TraitItem {
|
||||
pub hir_id: HirId,
|
||||
pub attrs: HirVec<Attribute>,
|
||||
pub generics: Generics,
|
||||
pub node: TraitItemKind,
|
||||
pub kind: TraitItemKind,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
|
@ -858,7 +858,7 @@ impl<'a> State<'a> {
|
||||
self.hardbreak_if_not_bol();
|
||||
self.maybe_print_comment(ti.span.lo());
|
||||
self.print_outer_attributes(&ti.attrs);
|
||||
match ti.node {
|
||||
match ti.kind {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
let vis = Spanned { span: syntax_pos::DUMMY_SP,
|
||||
node: hir::VisibilityKind::Inherited };
|
||||
|
@ -200,7 +200,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
|
||||
ident,
|
||||
ref attrs,
|
||||
ref generics,
|
||||
ref node,
|
||||
ref kind,
|
||||
span
|
||||
} = *self;
|
||||
|
||||
@ -208,7 +208,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
|
||||
ident.name.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
generics.hash_stable(hcx, hasher);
|
||||
node.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
});
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
fn trait_item_scope_tag(item: &hir::TraitItem) -> &'static str {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::TraitItemKind::Method(..) => "method body",
|
||||
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => "associated item",
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
..
|
||||
}) => &fndecl,
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(ref m, ..),
|
||||
kind: hir::TraitItemKind::Method(ref m, ..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
|
@ -384,7 +384,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
|
||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||
for trait_item_ref in trait_item_refs {
|
||||
let trait_item = self.krate.trait_item(trait_item_ref.id);
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Const(_, Some(_)) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
|
||||
if has_allow_dead_code_or_lang_attr(self.tcx,
|
||||
@ -652,7 +652,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
|
||||
|
||||
// Overwrite so that we don't warn the trait item itself.
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Const(_, Some(body_id)) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => {
|
||||
self.visit_nested_body(body_id)
|
||||
|
@ -164,7 +164,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
Some(Node::TraitItem(trait_method)) => {
|
||||
match trait_method.node {
|
||||
match trait_method.kind {
|
||||
hir::TraitItemKind::Const(_, ref default) => default.is_some(),
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) |
|
||||
@ -286,7 +286,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
Node::TraitItem(trait_method) => {
|
||||
match trait_method.node {
|
||||
match trait_method.kind {
|
||||
hir::TraitItemKind::Const(_, None) |
|
||||
hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
|
||||
// Keep going, nothing to get exported
|
||||
|
@ -778,7 +778,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
use self::hir::TraitItemKind::*;
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
Method(ref sig, _) => {
|
||||
let tcx = self.tcx;
|
||||
self.visit_early_late(
|
||||
@ -1871,7 +1871,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
..
|
||||
})
|
||||
| Node::TraitItem(&hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(..),
|
||||
kind: hir::TraitItemKind::Method(..),
|
||||
..
|
||||
})
|
||||
| Node::ImplItem(&hir::ImplItem {
|
||||
@ -2170,7 +2170,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||
}) => Some(body),
|
||||
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(_, ref m),
|
||||
kind: hir::TraitItemKind::Method(_, ref m),
|
||||
..
|
||||
}) => {
|
||||
if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx
|
||||
|
@ -1173,7 +1173,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
}) |
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
span,
|
||||
node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||
kind: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
|
||||
..
|
||||
}) => {
|
||||
(self.tcx.sess.source_map().def_span(span), decl.inputs.iter()
|
||||
|
@ -397,7 +397,7 @@ impl DirtyCleanVisitor<'tcx> {
|
||||
}
|
||||
},
|
||||
HirNode::TraitItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
|
||||
TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT),
|
||||
TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT),
|
||||
|
@ -796,7 +796,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
|
||||
}
|
||||
|
||||
fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
|
||||
let is_const = match i.node {
|
||||
let is_const = match i.kind {
|
||||
ast::TraitItemKind::Const(..) => true,
|
||||
ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
|
||||
header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
|
||||
|
@ -268,7 +268,7 @@ impl EarlyLintPass for UnsafeCode {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::TraitItem) {
|
||||
if let ast::TraitItemKind::Method(ref sig, None) = item.node {
|
||||
if let ast::TraitItemKind::Method(ref sig, None) = item.kind {
|
||||
if sig.header.unsafety == ast::Unsafety::Unsafe {
|
||||
self.report_unsafe(cx, item.span, "declaration of an `unsafe` method")
|
||||
}
|
||||
@ -440,7 +440,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
|
||||
return;
|
||||
}
|
||||
|
||||
let desc = match trait_item.node {
|
||||
let desc = match trait_item.kind {
|
||||
hir::TraitItemKind::Const(..) => "an associated constant",
|
||||
hir::TraitItemKind::Method(..) => "a trait method",
|
||||
hir::TraitItemKind::Type(..) => "an associated type",
|
||||
@ -611,7 +611,7 @@ declare_lint_pass!(
|
||||
|
||||
impl EarlyLintPass for AnonymousParameters {
|
||||
fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::TraitItem) {
|
||||
match it.node {
|
||||
match it.kind {
|
||||
ast::TraitItemKind::Method(ref sig, _) => {
|
||||
for arg in sig.decl.inputs.iter() {
|
||||
match arg.pat.kind {
|
||||
|
@ -332,7 +332,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.node {
|
||||
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.kind {
|
||||
self.check_snake_case(cx, "trait method", &item.ident);
|
||||
for param_name in pnames {
|
||||
self.check_snake_case(cx, "variable", param_name);
|
||||
@ -399,7 +399,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, ti: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Const(..) = ti.node {
|
||||
if let hir::TraitItemKind::Const(..) = ti.kind {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ti.ident);
|
||||
}
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ impl EncodeContext<'tcx> {
|
||||
let kind = match trait_item.kind {
|
||||
ty::AssocKind::Const => {
|
||||
let const_qualif =
|
||||
if let hir::TraitItemKind::Const(_, Some(body)) = ast_item.node {
|
||||
if let hir::TraitItemKind::Const(_, Some(body)) = ast_item.kind {
|
||||
self.const_qualif(0, body)
|
||||
} else {
|
||||
ConstQualif { mir: 0, ast_promotable: false }
|
||||
@ -875,7 +875,7 @@ impl EncodeContext<'tcx> {
|
||||
EntryKind::AssocConst(container, const_qualif, rendered_const)
|
||||
}
|
||||
ty::AssocKind::Method => {
|
||||
let fn_data = if let hir::TraitItemKind::Method(method_sig, m) = &ast_item.node {
|
||||
let fn_data = if let hir::TraitItemKind::Method(method_sig, m) = &ast_item.kind {
|
||||
let param_names = match *m {
|
||||
hir::TraitMethod::Required(ref names) => {
|
||||
self.encode_fn_param_names(names)
|
||||
|
@ -37,7 +37,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||
)
|
||||
| Node::TraitItem(
|
||||
hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(
|
||||
kind: hir::TraitItemKind::Method(
|
||||
hir::MethodSig { decl, .. },
|
||||
hir::TraitMethod::Provided(body_id),
|
||||
),
|
||||
@ -50,7 +50,7 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
|
||||
| Node::Item(hir::Item { node: hir::ItemKind::Const(ty, body_id), .. })
|
||||
| Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(ty, body_id), .. })
|
||||
| Node::TraitItem(
|
||||
hir::TraitItem { node: hir::TraitItemKind::Const(ty, Some(body_id)), .. }
|
||||
hir::TraitItem { kind: hir::TraitItemKind::Const(ty, Some(body_id)), .. }
|
||||
) => {
|
||||
(*body_id, ty.span)
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
}
|
||||
self.no_questions_in_bounds(bounds, "supertraits", true);
|
||||
for trait_item in trait_items {
|
||||
if let TraitItemKind::Method(ref sig, ref block) = trait_item.node {
|
||||
if let TraitItemKind::Method(ref sig, ref block) = trait_item.kind {
|
||||
self.check_fn_decl(&sig.decl);
|
||||
self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness.node);
|
||||
self.check_trait_fn_not_const(sig.header.constness);
|
||||
|
@ -1190,14 +1190,14 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
||||
fn visit_trait_item(&mut self, item: &'b TraitItem) {
|
||||
let parent = self.parent_scope.module;
|
||||
|
||||
if let TraitItemKind::Macro(_) = item.node {
|
||||
if let TraitItemKind::Macro(_) = item.kind {
|
||||
self.visit_invoc(item.id);
|
||||
return
|
||||
}
|
||||
|
||||
// Add the item to the trait info.
|
||||
let item_def_id = self.r.definitions.local_def_id(item.id);
|
||||
let (res, ns) = match item.node {
|
||||
let (res, ns) = match item.kind {
|
||||
TraitItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
|
||||
TraitItemKind::Method(ref sig, _) => {
|
||||
if sig.decl.has_self() {
|
||||
|
@ -740,7 +740,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
||||
AssocItemRibKind,
|
||||
);
|
||||
this.with_generic_param_rib(generic_params, |this| {
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
TraitItemKind::Const(ref ty, ref default) => {
|
||||
this.visit_ty(ty);
|
||||
|
||||
@ -938,7 +938,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
|
||||
) -> T {
|
||||
let trait_assoc_types = replace(
|
||||
&mut self.current_trait_assoc_types,
|
||||
trait_items.iter().filter_map(|item| match &item.node {
|
||||
trait_items.iter().filter_map(|item| match &item.kind {
|
||||
TraitItemKind::Type(bounds, _) if bounds.len() == 0 => Some(item.ident),
|
||||
_ => None,
|
||||
}).collect(),
|
||||
|
@ -1007,7 +1007,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
||||
fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) {
|
||||
self.process_macro_use(trait_item.span);
|
||||
let vis_span = trait_item.span.shrink_to_lo();
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
ast::TraitItemKind::Const(ref ty, ref expr) => {
|
||||
self.process_assoc_const(
|
||||
trait_item.id,
|
||||
|
@ -195,7 +195,7 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {
|
||||
};
|
||||
|
||||
let node_kind = match node {
|
||||
Node::TraitItem(item) => match item.node {
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Method(..) => NodeKind::Fn,
|
||||
_ => NodeKind::Other,
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
||||
if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) {
|
||||
let trait_m_iter = match tcx.hir()
|
||||
.expect_trait_item(trait_m_hir_id)
|
||||
.node {
|
||||
.kind {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
trait_m_sig.decl.inputs.iter()
|
||||
}
|
||||
@ -463,7 +463,7 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
|
||||
TypeError::Sorts(ExpectedFound { .. }) => {
|
||||
if let Some(trait_m_hir_id) = tcx.hir().as_local_hir_id(trait_m.def_id) {
|
||||
let (trait_m_output, trait_m_iter) =
|
||||
match tcx.hir().expect_trait_item(trait_m_hir_id).node {
|
||||
match tcx.hir().expect_trait_item(trait_m_hir_id).kind {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
(&trait_m_sig.decl.output, trait_m_sig.decl.inputs.iter())
|
||||
}
|
||||
@ -715,7 +715,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||
if trait_number_args != impl_number_args {
|
||||
let trait_m_hir_id = tcx.hir().as_local_hir_id(trait_m.def_id);
|
||||
let trait_span = if let Some(trait_id) = trait_m_hir_id {
|
||||
match tcx.hir().expect_trait_item(trait_id).node {
|
||||
match tcx.hir().expect_trait_item(trait_id).kind {
|
||||
TraitItemKind::Method(ref trait_m_sig, _) => {
|
||||
let pos = if trait_number_args > 0 {
|
||||
trait_number_args - 1
|
||||
@ -1029,7 +1029,7 @@ pub fn compare_const_impl<'tcx>(
|
||||
let trait_c_hir_id = tcx.hir().as_local_hir_id(trait_c.def_id);
|
||||
let trait_c_span = trait_c_hir_id.map(|trait_c_hir_id| {
|
||||
// Add a label to the Span containing just the type of the const
|
||||
match tcx.hir().expect_trait_item(trait_c_hir_id).node {
|
||||
match tcx.hir().expect_trait_item(trait_c_hir_id).kind {
|
||||
TraitItemKind::Const(ref ty, _) => ty.span,
|
||||
_ => bug!("{:?} is not a trait const", trait_c),
|
||||
}
|
||||
|
@ -803,7 +803,7 @@ fn primary_body_of(
|
||||
}
|
||||
}
|
||||
Node::TraitItem(item) => {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
hir::TraitItemKind::Const(ref ty, Some(body)) =>
|
||||
Some((body, Some(ty), None, None)),
|
||||
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) =>
|
||||
@ -1520,7 +1520,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item) {
|
||||
|
||||
for item in items.iter() {
|
||||
let item = tcx.hir().trait_item(item.id);
|
||||
if let hir::TraitItemKind::Method(sig, _) = &item.node {
|
||||
if let hir::TraitItemKind::Method(sig, _) = &item.kind {
|
||||
let abi = sig.header.abi;
|
||||
fn_maybe_err(tcx, item.ident.span, abi);
|
||||
}
|
||||
@ -4102,7 +4102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
Some((decl, ident, ident.name != sym::main))
|
||||
}
|
||||
Node::TraitItem(&hir::TraitItem {
|
||||
ident, node: hir::TraitItemKind::Method(hir::MethodSig {
|
||||
ident, kind: hir::TraitItemKind::Method(hir::MethodSig {
|
||||
ref decl, ..
|
||||
}, ..), ..
|
||||
}) => Some((decl, ident, true)),
|
||||
@ -4200,7 +4200,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
..
|
||||
})) |
|
||||
Some(Node::TraitItem(hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(.., hir::TraitMethod::Provided(body_id)),
|
||||
kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Provided(body_id)),
|
||||
..
|
||||
})) => {
|
||||
let body = hir.body(*body_id);
|
||||
@ -4246,7 +4246,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
..
|
||||
})) |
|
||||
Some(Node::TraitItem(hir::TraitItem {
|
||||
node: hir::TraitItemKind::Method(.., hir::TraitMethod::Required(idents)),
|
||||
kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Required(idents)),
|
||||
..
|
||||
})) => sugg_call = idents.iter()
|
||||
.map(|ident| if ident.name != kw::SelfLower {
|
||||
|
@ -167,7 +167,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: DefId) {
|
||||
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
|
||||
let trait_item = tcx.hir().expect_trait_item(hir_id);
|
||||
|
||||
let method_sig = match trait_item.node {
|
||||
let method_sig = match trait_item.kind {
|
||||
hir::TraitItemKind::Method(ref sig, _) => Some(sig),
|
||||
_ => None
|
||||
};
|
||||
|
@ -486,12 +486,12 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
|
||||
let def_id = tcx.hir().local_def_id(trait_item.hir_id);
|
||||
tcx.generics_of(def_id);
|
||||
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
hir::TraitItemKind::Const(..)
|
||||
| hir::TraitItemKind::Type(_, Some(_))
|
||||
| hir::TraitItemKind::Method(..) => {
|
||||
tcx.type_of(def_id);
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.node {
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.kind {
|
||||
tcx.fn_sig(def_id);
|
||||
}
|
||||
}
|
||||
@ -860,7 +860,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
|
||||
}
|
||||
|
||||
match node {
|
||||
Node::TraitItem(item) => match item.node {
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
hir::TraitItemKind::Method(ref sig, _) => {
|
||||
has_late_bound_regions(tcx, &item.generics, &sig.decl)
|
||||
}
|
||||
@ -1207,7 +1207,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty<
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
|
||||
Some(match tcx.hir().get(hir_id) {
|
||||
Node::TraitItem(item) => match item.node {
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Method(..) => {
|
||||
let substs = InternalSubsts::identity_for_item(tcx, def_id);
|
||||
tcx.mk_fn_def(def_id, substs)
|
||||
@ -1786,7 +1786,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
|
||||
match tcx.hir().get(hir_id) {
|
||||
TraitItem(hir::TraitItem {
|
||||
node: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)),
|
||||
kind: TraitItemKind::Method(MethodSig { header, decl }, TraitMethod::Provided(_)),
|
||||
..
|
||||
})
|
||||
| ImplItem(hir::ImplItem {
|
||||
@ -1816,7 +1816,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
},
|
||||
|
||||
TraitItem(hir::TraitItem {
|
||||
node: TraitItemKind::Method(MethodSig { header, decl }, _),
|
||||
kind: TraitItemKind::Method(MethodSig { header, decl }, _),
|
||||
..
|
||||
}) => {
|
||||
AstConv::ty_of_fn(&icx, header.unsafety, header.abi, decl)
|
||||
@ -2281,7 +2281,7 @@ fn explicit_predicates_of(
|
||||
if let Some((self_trait_ref, trait_items)) = is_trait {
|
||||
predicates.extend(trait_items.iter().flat_map(|trait_item_ref| {
|
||||
let trait_item = tcx.hir().trait_item(trait_item_ref.id);
|
||||
let bounds = match trait_item.node {
|
||||
let bounds = match trait_item.kind {
|
||||
hir::TraitItemKind::Type(ref bounds, _) => bounds,
|
||||
_ => return Vec::new().into_iter()
|
||||
};
|
||||
|
@ -105,7 +105,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.node {
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.kind {
|
||||
self.visit_node_helper(trait_item.hir_id);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] {
|
||||
_ => unsupported()
|
||||
},
|
||||
|
||||
Node::TraitItem(item) => match item.node {
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
hir::TraitItemKind::Method(..) => {}
|
||||
|
||||
_ => unsupported()
|
||||
|
@ -168,7 +168,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for TermsContext<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.node {
|
||||
if let hir::TraitItemKind::Method(..) = trait_item.kind {
|
||||
self.add_inferreds_for_item(trait_item.hir_id);
|
||||
}
|
||||
}
|
||||
|
@ -2280,7 +2280,7 @@ impl Clean<PolyTrait> for hir::PolyTraitRef {
|
||||
|
||||
impl Clean<Item> for hir::TraitItem {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let inner = match self.node {
|
||||
let inner = match self.kind {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
AssocConstItem(ty.clean(cx),
|
||||
default.map(|e| print_const_expr(cx, e)))
|
||||
|
@ -1474,7 +1474,7 @@ pub struct TraitItem {
|
||||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub generics: Generics,
|
||||
pub node: TraitItemKind,
|
||||
pub kind: TraitItemKind,
|
||||
pub span: Span,
|
||||
/// See `Item::tokens` for what this is.
|
||||
pub tokens: Option<TokenStream>,
|
||||
|
@ -1318,7 +1318,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
|
||||
AstFragmentKind::TraitItems, after_derive).make_trait_items()
|
||||
}
|
||||
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::TraitItemKind::Macro(mac) => {
|
||||
let ast::TraitItem { attrs, span, .. } = item;
|
||||
self.check_attributes(&attrs);
|
||||
|
@ -53,7 +53,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
|
||||
})]),
|
||||
AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![ast::TraitItem {
|
||||
id, span, ident, attrs, generics,
|
||||
node: ast::TraitItemKind::Macro(mac_placeholder()),
|
||||
kind: ast::TraitItemKind::Macro(mac_placeholder()),
|
||||
tokens: None,
|
||||
}]),
|
||||
AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![ast::ImplItem {
|
||||
@ -261,7 +261,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
|
||||
}
|
||||
|
||||
fn flat_map_trait_item(&mut self, item: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
|
||||
match item.node {
|
||||
match item.kind {
|
||||
ast::TraitItemKind::Macro(_) => self.remove(item.id).make_trait_items(),
|
||||
_ => noop_flat_map_trait_item(item, self),
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
|
||||
match ti.node {
|
||||
match ti.kind {
|
||||
ast::TraitItemKind::Method(ref sig, ref block) => {
|
||||
if block.is_none() {
|
||||
self.check_abi(sig.header.abi, ti.span);
|
||||
|
@ -921,12 +921,12 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
|
||||
pub fn noop_flat_map_trait_item<T: MutVisitor>(mut item: TraitItem, vis: &mut T)
|
||||
-> SmallVec<[TraitItem; 1]>
|
||||
{
|
||||
let TraitItem { id, ident, attrs, generics, node, span, tokens: _ } = &mut item;
|
||||
let TraitItem { id, ident, attrs, generics, kind, span, tokens: _ } = &mut item;
|
||||
vis.visit_id(id);
|
||||
vis.visit_ident(ident);
|
||||
visit_attrs(attrs, vis);
|
||||
vis.visit_generics(generics);
|
||||
match node {
|
||||
match kind {
|
||||
TraitItemKind::Const(ty, default) => {
|
||||
vis.visit_ty(ty);
|
||||
visit_opt(default, |default| vis.visit_expr(default));
|
||||
|
@ -1009,7 +1009,7 @@ impl<'a> Parser<'a> {
|
||||
mut attrs: Vec<Attribute>) -> PResult<'a, TraitItem> {
|
||||
let lo = self.token.span;
|
||||
self.eat_bad_pub();
|
||||
let (name, node, generics) = if self.eat_keyword(kw::Type) {
|
||||
let (name, kind, generics) = if self.eat_keyword(kw::Type) {
|
||||
self.parse_trait_item_assoc_ty()?
|
||||
} else if self.is_const_item() {
|
||||
self.expect_keyword(kw::Const)?;
|
||||
@ -1094,7 +1094,7 @@ impl<'a> Parser<'a> {
|
||||
ident: name,
|
||||
attrs,
|
||||
generics,
|
||||
node,
|
||||
kind,
|
||||
span: lo.to(self.prev_span),
|
||||
tokens: None,
|
||||
})
|
||||
|
@ -1550,7 +1550,7 @@ impl<'a> State<'a> {
|
||||
self.hardbreak_if_not_bol();
|
||||
self.maybe_print_comment(ti.span.lo());
|
||||
self.print_outer_attributes(&ti.attrs);
|
||||
match ti.node {
|
||||
match ti.kind {
|
||||
ast::TraitItemKind::Const(ref ty, ref default) => {
|
||||
self.print_associated_const(
|
||||
ti.ident,
|
||||
|
@ -589,7 +589,7 @@ pub fn walk_trait_item<'a, V: Visitor<'a>>(visitor: &mut V, trait_item: &'a Trai
|
||||
visitor.visit_ident(trait_item.ident);
|
||||
walk_list!(visitor, visit_attribute, &trait_item.attrs);
|
||||
visitor.visit_generics(&trait_item.generics);
|
||||
match trait_item.node {
|
||||
match trait_item.kind {
|
||||
TraitItemKind::Const(ref ty, ref default) => {
|
||||
visitor.visit_ty(ty);
|
||||
walk_list!(visitor, visit_expr, default);
|
||||
|
Loading…
x
Reference in New Issue
Block a user