mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #69674 - mark-i-m:assoc-fn, r=matthewjasper
Rename DefKind::Method and TraitItemKind::Method r? @eddyb, @Centril, or @matthewjasper cc #69498 #60163
This commit is contained in:
commit
9bc7386970
@ -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"),
|
||||
|
@ -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,12 +326,12 @@ impl<'hir> Map<'hir> {
|
||||
},
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Const(..) => DefKind::AssocConst,
|
||||
TraitItemKind::Method(..) => DefKind::Method,
|
||||
TraitItemKind::Fn(..) => DefKind::AssocFn,
|
||||
TraitItemKind::Type(..) => DefKind::AssocTy,
|
||||
},
|
||||
Node::ImplItem(item) => match item.kind {
|
||||
ImplItemKind::Const(..) => DefKind::AssocConst,
|
||||
ImplItemKind::Method(..) => DefKind::Method,
|
||||
ImplItemKind::Method(..) => DefKind::AssocFn,
|
||||
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
|
||||
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
|
||||
},
|
||||
@ -472,7 +472,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,
|
||||
@ -800,7 +800,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 {
|
||||
@ -1311,7 +1311,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",
|
||||
};
|
||||
|
||||
|
@ -250,7 +250,7 @@ pub enum EvalResult {
|
||||
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool {
|
||||
// Check if `def_id` is a trait method.
|
||||
match tcx.def_kind(def_id) {
|
||||
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
|
||||
Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
|
||||
if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container {
|
||||
// Trait methods do not declare visibility (even
|
||||
// for visibility info in cstore). Use containing
|
||||
|
@ -611,7 +611,7 @@ impl<'tcx> TypeckTables<'tcx> {
|
||||
}
|
||||
|
||||
match self.type_dependent_defs().get(expr.hir_id) {
|
||||
Some(Ok((DefKind::Method, _))) => true,
|
||||
Some(Ok((DefKind::AssocFn, _))) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ impl AssocItem {
|
||||
pub fn def_kind(&self) -> DefKind {
|
||||
match self.kind {
|
||||
AssocKind::Const => DefKind::AssocConst,
|
||||
AssocKind::Method => DefKind::Method,
|
||||
AssocKind::Method => DefKind::AssocFn,
|
||||
AssocKind::Type => DefKind::AssocTy,
|
||||
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
|
||||
}
|
||||
@ -2872,7 +2872,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
} else {
|
||||
match self.def_kind(def_id).expect("no def for `DefId`") {
|
||||
DefKind::AssocConst | DefKind::Method | DefKind::AssocTy => true,
|
||||
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true,
|
||||
_ => false,
|
||||
}
|
||||
};
|
||||
@ -3051,7 +3051,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
|
||||
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
|
||||
let item = if def_id.krate != LOCAL_CRATE {
|
||||
if let Some(DefKind::Method) = self.def_kind(def_id) {
|
||||
if let Some(DefKind::AssocFn) = self.def_kind(def_id) {
|
||||
Some(self.associated_item(def_id))
|
||||
} else {
|
||||
None
|
||||
|
@ -761,13 +761,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()));
|
||||
|
@ -75,7 +75,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
ParenthesizedGenericArgs::Ok
|
||||
}
|
||||
// `a::b::Trait(Args)::TraitItem`
|
||||
Res::Def(DefKind::Method, _)
|
||||
Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
| Res::Def(DefKind::AssocTy, _)
|
||||
if i + 2 == proj_start =>
|
||||
|
@ -72,7 +72,7 @@ pub enum DefKind {
|
||||
Static,
|
||||
/// Refers to the struct or enum variant's constructor.
|
||||
Ctor(CtorOf, CtorKind),
|
||||
Method,
|
||||
AssocFn,
|
||||
AssocConst,
|
||||
|
||||
// Macro namespace
|
||||
@ -107,7 +107,8 @@ impl DefKind {
|
||||
DefKind::Union => "union",
|
||||
DefKind::Trait => "trait",
|
||||
DefKind::ForeignTy => "foreign type",
|
||||
DefKind::Method => "method",
|
||||
// FIXME: Update the description to "assoc fn"
|
||||
DefKind::AssocFn => "method",
|
||||
DefKind::Const => "constant",
|
||||
DefKind::AssocConst => "associated constant",
|
||||
DefKind::TyParam => "type parameter",
|
||||
@ -150,7 +151,7 @@ impl DefKind {
|
||||
| DefKind::ConstParam
|
||||
| DefKind::Static
|
||||
| DefKind::Ctor(..)
|
||||
| DefKind::Method
|
||||
| DefKind::AssocFn
|
||||
| DefKind::AssocConst => ns == Namespace::ValueNS,
|
||||
|
||||
DefKind::Macro(..) => ns == Namespace::MacroNS,
|
||||
|
@ -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, _, _), .. }) => {
|
||||
|
@ -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 ¶m_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,
|
||||
|
@ -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("");
|
||||
|
@ -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,
|
||||
|
@ -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),
|
||||
},
|
||||
|
@ -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",
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
&segment.args,
|
||||
) {
|
||||
let borrow = tables.borrow();
|
||||
if let Some((DefKind::Method, did)) = borrow.type_dependent_def(e.hir_id) {
|
||||
if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) {
|
||||
let generics = self.tcx.generics_of(did);
|
||||
if !generics.params.is_empty() {
|
||||
err.span_suggestion(
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
@ -803,7 +803,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),
|
||||
|
@ -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",
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
||||
match callee.kind {
|
||||
hir::ExprKind::Path(ref qpath) => {
|
||||
match cx.tables.qpath_res(qpath, callee.hir_id) {
|
||||
Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::Method, def_id) => {
|
||||
Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::AssocFn, def_id) => {
|
||||
Some(def_id)
|
||||
}
|
||||
// `Res::Local` if it was a closure, for which we
|
||||
|
@ -505,7 +505,7 @@ impl EntryKind {
|
||||
EntryKind::Struct(_, _) => DefKind::Struct,
|
||||
EntryKind::Union(_, _) => DefKind::Union,
|
||||
EntryKind::Fn(_) | EntryKind::ForeignFn(_) => DefKind::Fn,
|
||||
EntryKind::Method(_) => DefKind::Method,
|
||||
EntryKind::Method(_) => DefKind::AssocFn,
|
||||
EntryKind::Type => DefKind::TyAlias,
|
||||
EntryKind::TypeParam => DefKind::TyParam,
|
||||
EntryKind::ConstParam => DefKind::ConstParam,
|
||||
|
@ -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)
|
||||
|
@ -480,7 +480,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 {
|
||||
@ -522,7 +522,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 {
|
||||
|
@ -545,7 +545,7 @@ fn write_mir_sig(
|
||||
trace!("write_mir_sig: {:?}", src.instance);
|
||||
let kind = tcx.def_kind(src.def_id());
|
||||
let is_function = match kind {
|
||||
Some(DefKind::Fn) | Some(DefKind::Method) | Some(DefKind::Ctor(..)) => true,
|
||||
Some(DefKind::Fn) | Some(DefKind::AssocFn) | Some(DefKind::Ctor(..)) => true,
|
||||
_ => tcx.is_closure(src.def_id()),
|
||||
};
|
||||
match (kind, src.promoted) {
|
||||
|
@ -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), .. })
|
||||
|
@ -600,7 +600,7 @@ fn user_substs_applied_to_res<'tcx>(
|
||||
// a tuple-struct or tuple-variant. This has the type of a
|
||||
// `Fn` but with the user-given substitutions.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
|
||||
| Res::Def(DefKind::Const, _)
|
||||
| Res::Def(DefKind::AssocConst, _) => {
|
||||
@ -703,7 +703,7 @@ fn convert_path_expr<'a, 'tcx>(
|
||||
match res {
|
||||
// A regular function, constructor function or a constant.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
|
||||
| Res::SelfCtor(..) => {
|
||||
let user_ty = user_substs_applied_to_res(cx, expr.hir_id, res);
|
||||
|
@ -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(..) => {}
|
||||
}
|
||||
}
|
||||
|
@ -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(..) => {}
|
||||
|
@ -620,7 +620,7 @@ impl EmbargoVisitor<'tcx> {
|
||||
| DefKind::ForeignTy
|
||||
| DefKind::Fn
|
||||
| DefKind::OpaqueTy
|
||||
| DefKind::Method
|
||||
| DefKind::AssocFn
|
||||
| DefKind::Trait
|
||||
| DefKind::TyParam
|
||||
| DefKind::Variant => (),
|
||||
@ -1298,7 +1298,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
|
||||
_ => None,
|
||||
};
|
||||
let def = def.filter(|(kind, _)| match kind {
|
||||
DefKind::Method
|
||||
DefKind::AssocFn
|
||||
| DefKind::AssocConst
|
||||
| DefKind::AssocTy
|
||||
| DefKind::AssocOpaqueTy
|
||||
|
@ -874,7 +874,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
| Res::PrimTy(..)
|
||||
| Res::ToolMod => self.r.define(parent, ident, TypeNS, (res, vis, span, expansion)),
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Static, _)
|
||||
| Res::Def(DefKind::Const, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
@ -898,7 +898,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
||||
let field_names = cstore.struct_field_names_untracked(def_id, self.r.session);
|
||||
self.insert_field_names(def_id, field_names);
|
||||
}
|
||||
Res::Def(DefKind::Method, def_id) => {
|
||||
Res::Def(DefKind::AssocFn, def_id) => {
|
||||
if cstore.associated_item_cloned_untracked(def_id).method_has_self_argument {
|
||||
self.r.has_self.insert(def_id);
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
|
||||
if sig.decl.has_self() {
|
||||
self.r.has_self.insert(item_def_id);
|
||||
}
|
||||
(Res::Def(DefKind::Method, item_def_id), ValueNS)
|
||||
(Res::Def(DefKind::AssocFn, item_def_id), ValueNS)
|
||||
}
|
||||
AssocItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS),
|
||||
AssocItemKind::Macro(_) => bug!(), // handled above
|
||||
|
@ -266,7 +266,7 @@ impl<'a> PathSource<'a> {
|
||||
| Res::Def(DefKind::Static, _)
|
||||
| Res::Local(..)
|
||||
| Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
| Res::SelfCtor(..)
|
||||
| Res::Def(DefKind::ConstParam, _) => true,
|
||||
@ -293,7 +293,7 @@ impl<'a> PathSource<'a> {
|
||||
_ => false,
|
||||
},
|
||||
PathSource::TraitItem(ns) => match res {
|
||||
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _)
|
||||
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocFn, _)
|
||||
if ns == ValueNS =>
|
||||
{
|
||||
true
|
||||
|
@ -124,7 +124,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
Res::Def(DefKind::Ctor(..), _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Const, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
| Res::SelfCtor(_)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -741,7 +741,7 @@ impl<'a> NameBinding<'a> {
|
||||
fn is_importable(&self) -> bool {
|
||||
match self.res() {
|
||||
Res::Def(DefKind::AssocConst, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::AssocTy, _) => false,
|
||||
_ => true,
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
|
||||
| Res::Def(HirDefKind::Ctor(..), _) => {
|
||||
Some(Ref { kind: RefKind::Variable, span, ref_id: id_from_def_id(res.def_id()) })
|
||||
}
|
||||
Res::Def(HirDefKind::Method, decl_id) => {
|
||||
Res::Def(HirDefKind::AssocFn, decl_id) => {
|
||||
let def_id = if decl_id.is_local() {
|
||||
let ti = self.tcx.associated_item(decl_id);
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
|
||||
|
@ -2588,7 +2588,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
}
|
||||
|
||||
// Case 4. Reference to a method or associated const.
|
||||
DefKind::Method | DefKind::AssocConst => {
|
||||
DefKind::AssocFn | DefKind::AssocConst => {
|
||||
if segments.len() >= 2 {
|
||||
let generics = tcx.generics_of(def_id);
|
||||
path_segs.push(PathSeg(generics.parent.unwrap(), last - 1));
|
||||
|
@ -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 {
|
||||
|
@ -237,7 +237,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
|
||||
// ZST in a temporary, so skip its type, just in case it
|
||||
// can significantly complicate the generator type.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => {
|
||||
// NOTE(eddyb) this assumes a path expression has
|
||||
// no nested expressions to keep track of.
|
||||
|
@ -933,7 +933,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))
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
@ -2976,7 +2976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
pub fn write_method_call(&self, hir_id: hir::HirId, method: MethodCallee<'tcx>) {
|
||||
debug!("write_method_call(hir_id={:?}, method={:?})", hir_id, method);
|
||||
self.write_resolution(hir_id, Ok((DefKind::Method, method.def_id)));
|
||||
self.write_resolution(hir_id, Ok((DefKind::AssocFn, method.def_id)));
|
||||
self.write_substs(hir_id, method.substs);
|
||||
|
||||
// When the method is confirmed, the `method.substs` includes
|
||||
@ -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
|
||||
@ -5364,7 +5364,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
is_alias_variant_ctor = true;
|
||||
}
|
||||
}
|
||||
Res::Def(DefKind::Method, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
|
||||
Res::Def(DefKind::AssocFn, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
|
||||
let container = tcx.associated_item(def_id).container;
|
||||
debug!("instantiate_value_path: def_id={:?} container={:?}", def_id, container);
|
||||
match container {
|
||||
|
@ -707,7 +707,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.set_tainted_by_errors();
|
||||
return tcx.types.err;
|
||||
}
|
||||
Res::Def(DefKind::Method, _)
|
||||
Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => {
|
||||
report_unexpected_variant_res(tcx, res, pat.span, qpath);
|
||||
@ -793,7 +793,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
);
|
||||
let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg);
|
||||
match (res, &pat.kind) {
|
||||
(Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::Method, _), _) => {
|
||||
(Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::AssocFn, _), _) => {
|
||||
err.span_label(pat.span, "`fn` calls are not allowed in patterns");
|
||||
err.help(
|
||||
"for more information, visit \
|
||||
@ -830,7 +830,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
on_error();
|
||||
return tcx.types.err;
|
||||
}
|
||||
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _) => {
|
||||
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocFn, _) => {
|
||||
report_unexpected_res(res);
|
||||
return tcx.types.err;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
..
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
||||
| Res::Def(DefKind::ConstParam, _)
|
||||
| Res::Def(DefKind::AssocConst, _)
|
||||
| Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::Method, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::SelfCtor(..) => Ok(self.cat_rvalue(hir_id, span, expr_ty)),
|
||||
|
||||
Res::Def(DefKind::Static, _) => Ok(Place {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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(),
|
||||
},
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -1082,10 +1082,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))
|
||||
});
|
||||
|
@ -149,7 +149,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
|
||||
// In case this is a trait item, skip the
|
||||
// early return and try looking for the trait.
|
||||
let value = match res {
|
||||
Res::Def(DefKind::Method, _) | Res::Def(DefKind::AssocConst, _) => true,
|
||||
Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::AssocConst, _) => true,
|
||||
Res::Def(DefKind::AssocTy, _) => false,
|
||||
Res::Def(DefKind::Variant, _) => {
|
||||
return handle_variant(cx, res, extra_fragment);
|
||||
@ -813,7 +813,7 @@ fn ambiguity_error(
|
||||
|
||||
for (res, ns) in candidates {
|
||||
let (action, mut suggestion) = match res {
|
||||
Res::Def(DefKind::Method, _) | Res::Def(DefKind::Fn, _) => {
|
||||
Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Fn, _) => {
|
||||
("add parentheses", format!("{}()", path_str))
|
||||
}
|
||||
Res::Def(DefKind::Macro(..), _) => {
|
||||
|
Loading…
Reference in New Issue
Block a user