rename TraitItemKind::Method -> Fn

This commit is contained in:
Mark Mansi 2020-03-03 12:46:22 -06:00
parent 98c7ed67fb
commit 3aeb9f0faf
31 changed files with 67 additions and 70 deletions

View File

@ -60,7 +60,7 @@ impl MaybeFnLike for hir::ImplItem<'_> {
impl MaybeFnLike for hir::TraitItem<'_> {
fn is_fn_like(&self) -> bool {
match self.kind {
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
_ => false,
}
}
@ -239,7 +239,7 @@ impl<'a> FnLikeNode<'a> {
_ => bug!("item FnLikeNode that is not fn-like"),
},
Node::TraitItem(ti) => match ti.kind {
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
}
_ => bug!("trait method FnLikeNode that is not fn-like"),

View File

@ -51,7 +51,7 @@ impl<'hir> Entry<'hir> {
},
Node::TraitItem(ref item) => match item.kind {
TraitItemKind::Method(ref sig, _) => Some(&sig.decl),
TraitItemKind::Fn(ref sig, _) => Some(&sig.decl),
_ => None,
},
@ -77,7 +77,7 @@ impl<'hir> Entry<'hir> {
},
Node::TraitItem(item) => match &item.kind {
TraitItemKind::Method(sig, _) => Some(sig),
TraitItemKind::Fn(sig, _) => Some(sig),
_ => None,
},
@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> {
Node::TraitItem(item) => match item.kind {
TraitItemKind::Const(_, Some(body))
| TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body),
| TraitItemKind::Fn(_, TraitMethod::Provided(body)) => Some(body),
_ => None,
},
@ -326,7 +326,7 @@ impl<'hir> Map<'hir> {
},
Node::TraitItem(item) => match item.kind {
TraitItemKind::Const(..) => DefKind::AssocConst,
TraitItemKind::Method(..) => DefKind::AssocFn,
TraitItemKind::Fn(..) => DefKind::AssocFn,
TraitItemKind::Type(..) => DefKind::AssocTy,
},
Node::ImplItem(item) => match item.kind {
@ -473,7 +473,7 @@ impl<'hir> Map<'hir> {
| Node::AnonConst(_) => BodyOwnerKind::Const,
Node::Ctor(..)
| Node::Item(&Item { kind: ItemKind::Fn(..), .. })
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. })
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. })
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn,
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m),
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure,
@ -801,7 +801,7 @@ impl<'hir> Map<'hir> {
_ => false,
},
Node::TraitItem(ti) => match ti.kind {
TraitItemKind::Method(..) => true,
TraitItemKind::Fn(..) => true,
_ => false,
},
Node::ImplItem(ii) => match ii.kind {
@ -1312,7 +1312,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
Some(Node::TraitItem(ti)) => {
let kind = match ti.kind {
TraitItemKind::Const(..) => "assoc constant",
TraitItemKind::Method(..) => "trait method",
TraitItemKind::Fn(..) => "trait method",
TraitItemKind::Type(..) => "assoc type",
};

View File

@ -767,13 +767,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
let names = self.lower_fn_params_to_names(&sig.decl);
let (generics, sig) =
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Required(names)))
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Required(names)))
}
AssocItemKind::Fn(_, ref sig, ref generics, Some(ref body)) => {
let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body));
let (generics, sig) =
self.lower_method_sig(generics, sig, trait_item_def_id, false, None);
(generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id)))
(generics, hir::TraitItemKind::Fn(sig, hir::TraitMethod::Provided(body_id)))
}
AssocItemKind::TyAlias(_, ref generics, ref bounds, ref default) => {
let ty = default.as_ref().map(|x| self.lower_ty(x, ImplTraitContext::disallowed()));

View File

@ -1863,8 +1863,8 @@ pub enum TraitMethod<'hir> {
pub enum TraitItemKind<'hir> {
/// An associated constant with an optional value (otherwise `impl`s must contain a value).
Const(&'hir Ty<'hir>, Option<BodyId>),
/// A method with an optional body.
Method(FnSig<'hir>, TraitMethod<'hir>),
/// An associated function with an optional body.
Fn(FnSig<'hir>, TraitMethod<'hir>),
/// An associated type with (possibly empty) bounds and optional concrete
/// type.
Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
@ -2699,7 +2699,7 @@ impl Node<'_> {
pub fn fn_decl(&self) -> Option<&FnDecl<'_>> {
match self {
Node::TraitItem(TraitItem { kind: TraitItemKind::Method(fn_sig, _), .. })
Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
| Node::ImplItem(ImplItem { kind: ImplItemKind::Method(fn_sig, _), .. })
| Node::Item(Item { kind: ItemKind::Fn(fn_sig, _, _), .. }) => Some(fn_sig.decl),
Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => {

View File

@ -911,14 +911,14 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
visitor.visit_ty(ty);
walk_list!(visitor, visit_nested_body, default);
}
TraitItemKind::Method(ref sig, TraitMethod::Required(param_names)) => {
TraitItemKind::Fn(ref sig, TraitMethod::Required(param_names)) => {
visitor.visit_id(trait_item.hir_id);
visitor.visit_fn_decl(&sig.decl);
for &param_name in param_names {
visitor.visit_ident(param_name);
}
}
TraitItemKind::Method(ref sig, TraitMethod::Provided(body_id)) => {
TraitItemKind::Fn(ref sig, TraitMethod::Provided(body_id)) => {
visitor.visit_fn(
FnKind::Method(trait_item.ident, sig, None, &trait_item.attrs),
&sig.decl,

View File

@ -886,13 +886,13 @@ impl<'a> State<'a> {
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
self.print_associated_const(ti.ident, &ty, default, &vis);
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
let vis =
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
self.print_method_sig(ti.ident, sig, &ti.generics, &vis, arg_names, None);
self.s.word(";");
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
let vis =
Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Inherited };
self.head("");

View File

@ -105,10 +105,10 @@ impl Target {
pub fn from_trait_item(trait_item: &TraitItem<'_>) -> Target {
match trait_item.kind {
TraitItemKind::Const(..) => Target::AssocConst,
TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => {
Target::Method(MethodKind::Trait { body: false })
}
TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => {
Target::Method(MethodKind::Trait { body: true })
}
TraitItemKind::Type(..) => Target::AssocTy,

View File

@ -328,7 +328,7 @@ impl DirtyCleanVisitor<'tcx> {
}
}
HirNode::TraitItem(item) => match item.kind {
TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
TraitItemKind::Fn(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT),
TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT),
TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT),
},

View File

@ -269,7 +269,7 @@ fn item_scope_tag(item: &hir::Item<'_>) -> &'static str {
fn trait_item_scope_tag(item: &hir::TraitItem<'_>) -> &'static str {
match item.kind {
hir::TraitItemKind::Method(..) => "method body",
hir::TraitItemKind::Fn(..) => "method body",
hir::TraitItemKind::Const(..) | hir::TraitItemKind::Type(..) => "associated item",
}
}

View File

@ -33,7 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let fndecl = match self.tcx().hir().get(hir_id) {
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref m, ..), .. })
| Node::TraitItem(&hir::TraitItem {
kind: hir::TraitItemKind::Method(ref m, ..),
kind: hir::TraitItemKind::Fn(ref m, ..),
..
})
| Node::ImplItem(&hir::ImplItem {

View File

@ -70,7 +70,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
})
}
hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)),
kind: hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)),
..
}) => self.describe_generator(*body_id).or_else(|| Some("a trait method")),
hir::Node::ImplItem(hir::ImplItem {

View File

@ -62,7 +62,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
match node {
hir::Node::TraitItem(hir::TraitItem {
generics,
kind: hir::TraitItemKind::Method(..),
kind: hir::TraitItemKind::Fn(..),
..
}) if param_ty && self_ty == self.tcx.types.self_param => {
// Restricting `Self` for a single method.
@ -73,7 +73,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, generics, _), .. })
| hir::Node::TraitItem(hir::TraitItem {
generics,
kind: hir::TraitItemKind::Method(..),
kind: hir::TraitItemKind::Fn(..),
..
})
| hir::Node::ImplItem(hir::ImplItem {
@ -807,7 +807,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
})
| Node::TraitItem(&hir::TraitItem {
span,
kind: hir::TraitItemKind::Method(ref sig, _),
kind: hir::TraitItemKind::Fn(ref sig, _),
..
}) => (
self.tcx.sess.source_map().def_span(span),

View File

@ -465,7 +465,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
let desc = match trait_item.kind {
hir::TraitItemKind::Const(..) => "an associated constant",
hir::TraitItemKind::Method(..) => "a trait method",
hir::TraitItemKind::Fn(..) => "a trait method",
hir::TraitItemKind::Type(..) => "an associated type",
};

View File

@ -343,7 +343,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.kind {
if let hir::TraitItemKind::Fn(_, 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);

View File

@ -805,7 +805,7 @@ impl EncodeContext<'tcx> {
)
}
ty::AssocKind::Method => {
let fn_data = if let hir::TraitItemKind::Method(m_sig, m) = &ast_item.kind {
let fn_data = if let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind {
let param_names = match *m {
hir::TraitMethod::Required(ref names) => {
self.encode_fn_param_names(names)

View File

@ -478,7 +478,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}))
| Some(hir::Node::TraitItem(hir::TraitItem {
ident,
kind: hir::TraitItemKind::Method(sig, _),
kind: hir::TraitItemKind::Fn(sig, _),
..
}))
| Some(hir::Node::ImplItem(hir::ImplItem {
@ -520,7 +520,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn(sig, ..), .. })
| hir::Node::TraitItem(hir::TraitItem {
ident,
kind: hir::TraitItemKind::Method(sig, _),
kind: hir::TraitItemKind::Fn(sig, _),
..
})
| hir::Node::ImplItem(hir::ImplItem {

View File

@ -44,7 +44,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
})
| Node::TraitItem(hir::TraitItem {
kind:
hir::TraitItemKind::Method(hir::FnSig { decl, .. }, hir::TraitMethod::Provided(body_id)),
hir::TraitItemKind::Fn(hir::FnSig { decl, .. }, hir::TraitMethod::Provided(body_id)),
..
}) => (*body_id, decl.output.span()),
Node::Item(hir::Item { kind: hir::ItemKind::Static(ty, _, body_id), .. })

View File

@ -391,7 +391,7 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
let trait_item = self.krate.trait_item(trait_item_ref.id);
match trait_item.kind {
hir::TraitItemKind::Const(_, Some(_))
| hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => {
if has_allow_dead_code_or_lang_attr(
self.tcx,
trait_item.hir_id,
@ -682,11 +682,11 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
match trait_item.kind {
hir::TraitItemKind::Const(_, Some(body_id))
| hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => {
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)) => {
self.visit_nested_body(body_id)
}
hir::TraitItemKind::Const(_, None)
| hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_))
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_))
| hir::TraitItemKind::Type(..) => {}
}
}

View File

@ -162,8 +162,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
},
Some(Node::TraitItem(trait_method)) => 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(_))
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_))
| hir::TraitItemKind::Type(..) => false,
},
Some(Node::ImplItem(impl_item)) => {
@ -278,11 +278,11 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
Node::TraitItem(trait_method) => {
match trait_method.kind {
hir::TraitItemKind::Const(_, None)
| hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Required(_)) => {
// Keep going, nothing to get exported
}
hir::TraitItemKind::Const(_, Some(body_id))
| hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => {
| hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(body_id)) => {
self.visit_nested_body(body_id);
}
hir::TraitItemKind::Type(..) => {}

View File

@ -713,7 +713,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
use self::hir::TraitItemKind::*;
self.missing_named_lifetime_spots.push((&trait_item.generics).into());
match trait_item.kind {
Method(ref sig, _) => {
Fn(ref sig, _) => {
let tcx = self.tcx;
self.visit_early_late(
Some(tcx.hir().get_parent_item(trait_item.hir_id)),
@ -1816,8 +1816,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
match self.tcx.hir().get(fn_id) {
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(..), .. })
| Node::TraitItem(&hir::TraitItem {
kind: hir::TraitItemKind::Method(..),
..
kind: hir::TraitItemKind::Fn(..), ..
})
| Node::ImplItem(&hir::ImplItem {
kind: hir::ImplItemKind::Method(..), ..
@ -2093,9 +2092,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
// `fn` definitions and methods.
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(.., body), .. }) => Some(body),
Node::TraitItem(&hir::TraitItem {
kind: hir::TraitItemKind::Method(_, ref m), ..
}) => {
Node::TraitItem(&hir::TraitItem { kind: hir::TraitItemKind::Fn(_, ref m), .. }) => {
if let hir::ItemKind::Trait(.., ref trait_items) =
self.tcx.hir().expect_item(self.tcx.hir().get_parent_item(parent)).kind
{

View File

@ -185,7 +185,7 @@ crate fn environment(tcx: TyCtxt<'_>, def_id: DefId) -> Environment<'_> {
let node_kind = match node {
Node::TraitItem(item) => match item.kind {
TraitItemKind::Method(..) => NodeKind::Fn,
TraitItemKind::Fn(..) => NodeKind::Fn,
_ => NodeKind::Other,
},

View File

@ -412,8 +412,8 @@ fn extract_spans_for_error_reporting<'a, 'tcx>(
TypeError::Mutability => {
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).kind {
TraitItemKind::Method(ref trait_m_sig, _) => trait_m_sig.decl.inputs.iter(),
_ => bug!("{:?} is not a TraitItemKind::Method", trait_m),
TraitItemKind::Fn(ref trait_m_sig, _) => trait_m_sig.decl.inputs.iter(),
_ => bug!("{:?} is not a TraitItemKind::Fn", trait_m),
};
impl_m_iter
@ -440,10 +440,10 @@ 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_output, trait_m_iter) =
match tcx.hir().expect_trait_item(trait_m_hir_id).kind {
TraitItemKind::Method(ref trait_m_sig, _) => {
TraitItemKind::Fn(ref trait_m_sig, _) => {
(&trait_m_sig.decl.output, trait_m_sig.decl.inputs.iter())
}
_ => bug!("{:?} is not a TraitItemKind::Method", trait_m),
_ => bug!("{:?} is not a TraitItemKind::Fn", trait_m),
};
let impl_iter = impl_sig.inputs().iter();
@ -708,7 +708,7 @@ fn compare_number_of_method_arguments<'tcx>(
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).kind {
TraitItemKind::Method(ref trait_m_sig, _) => {
TraitItemKind::Fn(ref trait_m_sig, _) => {
let pos = if trait_number_args > 0 { trait_number_args - 1 } else { 0 };
if let Some(arg) = trait_m_sig.decl.inputs.get(pos) {
Some(if pos == 0 {

View File

@ -930,7 +930,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let ty::AssocKind::Method = item.kind {
let id = self.tcx.hir().as_local_hir_id(item.def_id);
if let Some(hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Method(fn_sig, method),
kind: hir::TraitItemKind::Fn(fn_sig, method),
..
})) = id.map(|id| self.tcx.hir().get(id))
{

View File

@ -811,7 +811,7 @@ fn primary_body_of(
},
Node::TraitItem(item) => 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)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
Some((body, None, Some(&sig.header), Some(&sig.decl)))
}
_ => None,
@ -1733,7 +1733,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
for item in items.iter() {
let item = tcx.hir().trait_item(item.id);
if let hir::TraitItemKind::Method(sig, _) = &item.kind {
if let hir::TraitItemKind::Fn(sig, _) = &item.kind {
let abi = sig.header.abi;
fn_maybe_err(tcx, item.ident.span, abi);
}
@ -4769,7 +4769,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
Node::TraitItem(&hir::TraitItem {
ident,
kind: hir::TraitItemKind::Method(ref sig, ..),
kind: hir::TraitItemKind::Fn(ref sig, ..),
..
}) => Some((&sig.decl, ident, true)),
Node::ImplItem(&hir::ImplItem {
@ -4863,7 +4863,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
..
}))
| Some(Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Provided(body_id)),
kind: hir::TraitItemKind::Fn(.., hir::TraitMethod::Provided(body_id)),
..
})) => {
let body = hir.body(*body_id);
@ -4934,7 +4934,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.join(", ")
}
Some(Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Method(.., hir::TraitMethod::Required(idents)),
kind: hir::TraitItemKind::Fn(.., hir::TraitMethod::Required(idents)),
..
})) => {
sugg_call = idents

View File

@ -173,7 +173,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: DefId) {
let trait_item = tcx.hir().expect_trait_item(hir_id);
let method_sig = match trait_item.kind {
hir::TraitItemKind::Method(ref sig, _) => Some(sig),
hir::TraitItemKind::Fn(ref sig, _) => Some(sig),
_ => None,
};
check_object_unsafe_self_trait_by_name(tcx, &trait_item);
@ -207,7 +207,7 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
{
trait_should_be_self.push(ty.span)
}
hir::TraitItemKind::Method(sig, _) => {
hir::TraitItemKind::Fn(sig, _) => {
for ty in sig.decl.inputs {
if could_be_self(trait_def_id, ty) {
trait_should_be_self.push(ty.span);

View File

@ -715,7 +715,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
tcx.generics_of(def_id);
match trait_item.kind {
hir::TraitItemKind::Method(..) => {
hir::TraitItemKind::Fn(..) => {
tcx.type_of(def_id);
tcx.fn_sig(def_id);
}
@ -1121,7 +1121,7 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<S
match node {
Node::TraitItem(item) => match item.kind {
hir::TraitItemKind::Method(ref sig, _) => {
hir::TraitItemKind::Fn(ref sig, _) => {
has_late_bound_regions(tcx, &item.generics, &sig.decl)
}
_ => None,
@ -1437,7 +1437,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
match tcx.hir().get(hir_id) {
TraitItem(hir::TraitItem {
kind: TraitItemKind::Method(sig, TraitMethod::Provided(_)),
kind: TraitItemKind::Fn(sig, TraitMethod::Provided(_)),
ident,
generics,
..
@ -1474,7 +1474,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
}
TraitItem(hir::TraitItem {
kind: TraitItemKind::Method(FnSig { header, decl }, _),
kind: TraitItemKind::Fn(FnSig { header, decl }, _),
ident,
generics,
..

View File

@ -27,7 +27,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
match tcx.hir().get(hir_id) {
Node::TraitItem(item) => match item.kind {
TraitItemKind::Method(..) => {
TraitItemKind::Fn(..) => {
let substs = InternalSubsts::identity_for_item(tcx, def_id);
tcx.mk_fn_def(def_id, substs)
}

View File

@ -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.kind {
if let hir::TraitItemKind::Fn(..) = trait_item.kind {
self.visit_node_helper(trait_item.hir_id);
}
}

View File

@ -54,7 +54,7 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] {
},
Node::TraitItem(item) => match item.kind {
hir::TraitItemKind::Method(..) => {}
hir::TraitItemKind::Fn(..) => {}
_ => unsupported(),
},

View File

@ -164,7 +164,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.kind {
if let hir::TraitItemKind::Fn(..) = trait_item.kind {
self.add_inferreds_for_item(trait_item.hir_id);
}
}

View File

@ -1084,10 +1084,10 @@ impl Clean<Item> for hir::TraitItem<'_> {
hir::TraitItemKind::Const(ref ty, default) => {
AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx, e)))
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
MethodItem((sig, &self.generics, body, None).clean(cx))
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref names)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Required(ref names)) => {
let (generics, decl) = enter_impl_trait(cx, || {
(self.generics.clean(cx), (&*sig.decl, &names[..]).clean(cx))
});