mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
DefKind::Method -> DefKind::AssocFn
This commit is contained in:
parent
b135c739fb
commit
98c7ed67fb
@ -326,12 +326,12 @@ impl<'hir> Map<'hir> {
|
||||
},
|
||||
Node::TraitItem(item) => match item.kind {
|
||||
TraitItemKind::Const(..) => DefKind::AssocConst,
|
||||
TraitItemKind::Method(..) => DefKind::Method,
|
||||
TraitItemKind::Method(..) => 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,
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -504,7 +504,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,
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -887,7 +887,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, _)
|
||||
@ -911,7 +911,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);
|
||||
}
|
||||
@ -1257,7 +1257,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(_)
|
||||
|
@ -742,7 +742,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,
|
||||
}
|
||||
|
@ -716,7 +716,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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
@ -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 {
|
||||
|
@ -682,7 +682,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);
|
||||
@ -729,7 +729,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 \
|
||||
@ -766,7 +766,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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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