Skip to content
Permalink
Browse files

Rename `TraitItem.node` to `TraitItem.kind`

  • Loading branch information...
varkor committed Sep 26, 2019
1 parent 17726f6 commit d4573c9c1e8118be5ffc662c6a64db329db0a245
Showing with 82 additions and 82 deletions.
  1. +1 −1 src/librustc/hir/intravisit.rs
  2. +1 −1 src/librustc/hir/lowering.rs
  3. +5 −5 src/librustc/hir/lowering/item.rs
  4. +2 −2 src/librustc/hir/map/blocks.rs
  5. +1 −1 src/librustc/hir/map/def_collector.rs
  6. +8 −8 src/librustc/hir/map/mod.rs
  7. +1 −1 src/librustc/hir/mod.rs
  8. +1 −1 src/librustc/hir/print.rs
  9. +2 −2 src/librustc/ich/impls_hir.rs
  10. +1 −1 src/librustc/infer/error_reporting/mod.rs
  11. +1 −1 src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs
  12. +2 −2 src/librustc/middle/dead.rs
  13. +2 −2 src/librustc/middle/reachable.rs
  14. +3 −3 src/librustc/middle/resolve_lifetime.rs
  15. +1 −1 src/librustc/traits/error_reporting.rs
  16. +1 −1 src/librustc_incremental/persist/dirty_clean.rs
  17. +1 −1 src/librustc_interface/util.rs
  18. +3 −3 src/librustc_lint/builtin.rs
  19. +2 −2 src/librustc_lint/nonstandard_style.rs
  20. +2 −2 src/librustc_metadata/encoder.rs
  21. +2 −2 src/librustc_mir/build/mod.rs
  22. +1 −1 src/librustc_passes/ast_validation.rs
  23. +2 −2 src/librustc_resolve/build_reduced_graph.rs
  24. +2 −2 src/librustc_resolve/late.rs
  25. +1 −1 src/librustc_save_analysis/dump_visitor.rs
  26. +1 −1 src/librustc_traits/lowering/environment.rs
  27. +4 −4 src/librustc_typeck/check/compare_method.rs
  28. +5 −5 src/librustc_typeck/check/mod.rs
  29. +1 −1 src/librustc_typeck/check/wfcheck.rs
  30. +7 −7 src/librustc_typeck/collect.rs
  31. +1 −1 src/librustc_typeck/variance/constraints.rs
  32. +1 −1 src/librustc_typeck/variance/mod.rs
  33. +1 −1 src/librustc_typeck/variance/terms.rs
  34. +1 −1 src/librustdoc/clean/mod.rs
  35. +1 −1 src/libsyntax/ast.rs
  36. +1 −1 src/libsyntax/ext/expand.rs
  37. +2 −2 src/libsyntax/ext/placeholders.rs
  38. +1 −1 src/libsyntax/feature_gate/check.rs
  39. +2 −2 src/libsyntax/mut_visit.rs
  40. +2 −2 src/libsyntax/parse/parser/item.rs
  41. +1 −1 src/libsyntax/print/pprust.rs
  42. +1 −1 src/libsyntax/visit.rs
@@ -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,15 +200,15 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem {
ident,
ref attrs,
ref generics,
ref node,
ref kind,
span
} = *self;

hcx.hash_hir_item_like(|hcx| {
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);

0 comments on commit d4573c9

Please sign in to comment.
You can’t perform that action at this time.