Skip to content

Commit 98c7ed6

Browse files
committed
DefKind::Method -> DefKind::AssocFn
1 parent b135c73 commit 98c7ed6

File tree

23 files changed

+38
-37
lines changed

23 files changed

+38
-37
lines changed

src/librustc/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,12 @@ impl<'hir> Map<'hir> {
326326
},
327327
Node::TraitItem(item) => match item.kind {
328328
TraitItemKind::Const(..) => DefKind::AssocConst,
329-
TraitItemKind::Method(..) => DefKind::Method,
329+
TraitItemKind::Method(..) => DefKind::AssocFn,
330330
TraitItemKind::Type(..) => DefKind::AssocTy,
331331
},
332332
Node::ImplItem(item) => match item.kind {
333333
ImplItemKind::Const(..) => DefKind::AssocConst,
334-
ImplItemKind::Method(..) => DefKind::Method,
334+
ImplItemKind::Method(..) => DefKind::AssocFn,
335335
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
336336
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
337337
},

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub enum EvalResult {
250250
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool {
251251
// Check if `def_id` is a trait method.
252252
match tcx.def_kind(def_id) {
253-
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
253+
Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
254254
if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container {
255255
// Trait methods do not declare visibility (even
256256
// for visibility info in cstore). Use containing

src/librustc/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl<'tcx> TypeckTables<'tcx> {
611611
}
612612

613613
match self.type_dependent_defs().get(expr.hir_id) {
614-
Some(Ok((DefKind::Method, _))) => true,
614+
Some(Ok((DefKind::AssocFn, _))) => true,
615615
_ => false,
616616
}
617617
}

src/librustc/ty/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl AssocItem {
230230
pub fn def_kind(&self) -> DefKind {
231231
match self.kind {
232232
AssocKind::Const => DefKind::AssocConst,
233-
AssocKind::Method => DefKind::Method,
233+
AssocKind::Method => DefKind::AssocFn,
234234
AssocKind::Type => DefKind::AssocTy,
235235
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
236236
}
@@ -2872,7 +2872,7 @@ impl<'tcx> TyCtxt<'tcx> {
28722872
}
28732873
} else {
28742874
match self.def_kind(def_id).expect("no def for `DefId`") {
2875-
DefKind::AssocConst | DefKind::Method | DefKind::AssocTy => true,
2875+
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true,
28762876
_ => false,
28772877
}
28782878
};
@@ -3051,7 +3051,7 @@ impl<'tcx> TyCtxt<'tcx> {
30513051
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
30523052
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
30533053
let item = if def_id.krate != LOCAL_CRATE {
3054-
if let Some(DefKind::Method) = self.def_kind(def_id) {
3054+
if let Some(DefKind::AssocFn) = self.def_kind(def_id) {
30553055
Some(self.associated_item(def_id))
30563056
} else {
30573057
None

src/librustc_ast_lowering/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
7575
ParenthesizedGenericArgs::Ok
7676
}
7777
// `a::b::Trait(Args)::TraitItem`
78-
Res::Def(DefKind::Method, _)
78+
Res::Def(DefKind::AssocFn, _)
7979
| Res::Def(DefKind::AssocConst, _)
8080
| Res::Def(DefKind::AssocTy, _)
8181
if i + 2 == proj_start =>

src/librustc_hir/def.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub enum DefKind {
7272
Static,
7373
/// Refers to the struct or enum variant's constructor.
7474
Ctor(CtorOf, CtorKind),
75-
Method,
75+
AssocFn,
7676
AssocConst,
7777

7878
// Macro namespace
@@ -107,7 +107,8 @@ impl DefKind {
107107
DefKind::Union => "union",
108108
DefKind::Trait => "trait",
109109
DefKind::ForeignTy => "foreign type",
110-
DefKind::Method => "method",
110+
// FIXME: Update the description to "assoc fn"
111+
DefKind::AssocFn => "method",
111112
DefKind::Const => "constant",
112113
DefKind::AssocConst => "associated constant",
113114
DefKind::TyParam => "type parameter",
@@ -150,7 +151,7 @@ impl DefKind {
150151
| DefKind::ConstParam
151152
| DefKind::Static
152153
| DefKind::Ctor(..)
153-
| DefKind::Method
154+
| DefKind::AssocFn
154155
| DefKind::AssocConst => ns == Namespace::ValueNS,
155156

156157
DefKind::Macro(..) => ns == Namespace::MacroNS,

src/librustc_infer/infer/error_reporting/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
468468
&segment.args,
469469
) {
470470
let borrow = tables.borrow();
471-
if let Some((DefKind::Method, did)) = borrow.type_dependent_def(e.hir_id) {
471+
if let Some((DefKind::AssocFn, did)) = borrow.type_dependent_def(e.hir_id) {
472472
let generics = self.tcx.generics_of(did);
473473
if !generics.params.is_empty() {
474474
err.span_suggestion(

src/librustc_lint/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
5454
match callee.kind {
5555
hir::ExprKind::Path(ref qpath) => {
5656
match cx.tables.qpath_res(qpath, callee.hir_id) {
57-
Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::Method, def_id) => {
57+
Res::Def(DefKind::Fn, def_id) | Res::Def(DefKind::AssocFn, def_id) => {
5858
Some(def_id)
5959
}
6060
// `Res::Local` if it was a closure, for which we

src/librustc_metadata/rmeta/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ impl EntryKind {
504504
EntryKind::Struct(_, _) => DefKind::Struct,
505505
EntryKind::Union(_, _) => DefKind::Union,
506506
EntryKind::Fn(_) | EntryKind::ForeignFn(_) => DefKind::Fn,
507-
EntryKind::Method(_) => DefKind::Method,
507+
EntryKind::Method(_) => DefKind::AssocFn,
508508
EntryKind::Type => DefKind::TyAlias,
509509
EntryKind::TypeParam => DefKind::TyParam,
510510
EntryKind::ConstParam => DefKind::ConstParam,

src/librustc_mir/util/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ fn write_mir_sig(
545545
trace!("write_mir_sig: {:?}", src.instance);
546546
let kind = tcx.def_kind(src.def_id());
547547
let is_function = match kind {
548-
Some(DefKind::Fn) | Some(DefKind::Method) | Some(DefKind::Ctor(..)) => true,
548+
Some(DefKind::Fn) | Some(DefKind::AssocFn) | Some(DefKind::Ctor(..)) => true,
549549
_ => tcx.is_closure(src.def_id()),
550550
};
551551
match (kind, src.promoted) {

src/librustc_mir_build/hair/cx/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ fn user_substs_applied_to_res<'tcx>(
600600
// a tuple-struct or tuple-variant. This has the type of a
601601
// `Fn` but with the user-given substitutions.
602602
Res::Def(DefKind::Fn, _)
603-
| Res::Def(DefKind::Method, _)
603+
| Res::Def(DefKind::AssocFn, _)
604604
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
605605
| Res::Def(DefKind::Const, _)
606606
| Res::Def(DefKind::AssocConst, _) => {
@@ -703,7 +703,7 @@ fn convert_path_expr<'a, 'tcx>(
703703
match res {
704704
// A regular function, constructor function or a constant.
705705
Res::Def(DefKind::Fn, _)
706-
| Res::Def(DefKind::Method, _)
706+
| Res::Def(DefKind::AssocFn, _)
707707
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
708708
| Res::SelfCtor(..) => {
709709
let user_ty = user_substs_applied_to_res(cx, expr.hir_id, res);

src/librustc_privacy/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ impl EmbargoVisitor<'tcx> {
620620
| DefKind::ForeignTy
621621
| DefKind::Fn
622622
| DefKind::OpaqueTy
623-
| DefKind::Method
623+
| DefKind::AssocFn
624624
| DefKind::Trait
625625
| DefKind::TyParam
626626
| DefKind::Variant => (),
@@ -1298,7 +1298,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
12981298
_ => None,
12991299
};
13001300
let def = def.filter(|(kind, _)| match kind {
1301-
DefKind::Method
1301+
DefKind::AssocFn
13021302
| DefKind::AssocConst
13031303
| DefKind::AssocTy
13041304
| DefKind::AssocOpaqueTy

src/librustc_resolve/build_reduced_graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
887887
| Res::PrimTy(..)
888888
| Res::ToolMod => self.r.define(parent, ident, TypeNS, (res, vis, span, expansion)),
889889
Res::Def(DefKind::Fn, _)
890-
| Res::Def(DefKind::Method, _)
890+
| Res::Def(DefKind::AssocFn, _)
891891
| Res::Def(DefKind::Static, _)
892892
| Res::Def(DefKind::Const, _)
893893
| Res::Def(DefKind::AssocConst, _)
@@ -911,7 +911,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
911911
let field_names = cstore.struct_field_names_untracked(def_id, self.r.session);
912912
self.insert_field_names(def_id, field_names);
913913
}
914-
Res::Def(DefKind::Method, def_id) => {
914+
Res::Def(DefKind::AssocFn, def_id) => {
915915
if cstore.associated_item_cloned_untracked(def_id).method_has_self_argument {
916916
self.r.has_self.insert(def_id);
917917
}
@@ -1257,7 +1257,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
12571257
if sig.decl.has_self() {
12581258
self.r.has_self.insert(item_def_id);
12591259
}
1260-
(Res::Def(DefKind::Method, item_def_id), ValueNS)
1260+
(Res::Def(DefKind::AssocFn, item_def_id), ValueNS)
12611261
}
12621262
AssocItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS),
12631263
AssocItemKind::Macro(_) => bug!(), // handled above

src/librustc_resolve/late.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl<'a> PathSource<'a> {
266266
| Res::Def(DefKind::Static, _)
267267
| Res::Local(..)
268268
| Res::Def(DefKind::Fn, _)
269-
| Res::Def(DefKind::Method, _)
269+
| Res::Def(DefKind::AssocFn, _)
270270
| Res::Def(DefKind::AssocConst, _)
271271
| Res::SelfCtor(..)
272272
| Res::Def(DefKind::ConstParam, _) => true,
@@ -293,7 +293,7 @@ impl<'a> PathSource<'a> {
293293
_ => false,
294294
},
295295
PathSource::TraitItem(ns) => match res {
296-
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _)
296+
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocFn, _)
297297
if ns == ValueNS =>
298298
{
299299
true

src/librustc_resolve/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
124124
.unwrap_or(false)
125125
}
126126
Res::Def(DefKind::Ctor(..), _)
127-
| Res::Def(DefKind::Method, _)
127+
| Res::Def(DefKind::AssocFn, _)
128128
| Res::Def(DefKind::Const, _)
129129
| Res::Def(DefKind::AssocConst, _)
130130
| Res::SelfCtor(_)

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ impl<'a> NameBinding<'a> {
742742
fn is_importable(&self) -> bool {
743743
match self.res() {
744744
Res::Def(DefKind::AssocConst, _)
745-
| Res::Def(DefKind::Method, _)
745+
| Res::Def(DefKind::AssocFn, _)
746746
| Res::Def(DefKind::AssocTy, _) => false,
747747
_ => true,
748748
}

src/librustc_save_analysis/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
716716
| Res::Def(HirDefKind::Ctor(..), _) => {
717717
Some(Ref { kind: RefKind::Variable, span, ref_id: id_from_def_id(res.def_id()) })
718718
}
719-
Res::Def(HirDefKind::Method, decl_id) => {
719+
Res::Def(HirDefKind::AssocFn, decl_id) => {
720720
let def_id = if decl_id.is_local() {
721721
let ti = self.tcx.associated_item(decl_id);
722722

src/librustc_typeck/astconv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25882588
}
25892589

25902590
// Case 4. Reference to a method or associated const.
2591-
DefKind::Method | DefKind::AssocConst => {
2591+
DefKind::AssocFn | DefKind::AssocConst => {
25922592
if segments.len() >= 2 {
25932593
let generics = tcx.generics_of(def_id);
25942594
path_segs.push(PathSeg(generics.parent.unwrap(), last - 1));

src/librustc_typeck/check/generator_interior.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
237237
// ZST in a temporary, so skip its type, just in case it
238238
// can significantly complicate the generator type.
239239
Res::Def(DefKind::Fn, _)
240-
| Res::Def(DefKind::Method, _)
240+
| Res::Def(DefKind::AssocFn, _)
241241
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => {
242242
// NOTE(eddyb) this assumes a path expression has
243243
// no nested expressions to keep track of.

src/librustc_typeck/check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2976,7 +2976,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29762976

29772977
pub fn write_method_call(&self, hir_id: hir::HirId, method: MethodCallee<'tcx>) {
29782978
debug!("write_method_call(hir_id={:?}, method={:?})", hir_id, method);
2979-
self.write_resolution(hir_id, Ok((DefKind::Method, method.def_id)));
2979+
self.write_resolution(hir_id, Ok((DefKind::AssocFn, method.def_id)));
29802980
self.write_substs(hir_id, method.substs);
29812981

29822982
// When the method is confirmed, the `method.substs` includes
@@ -5364,7 +5364,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
53645364
is_alias_variant_ctor = true;
53655365
}
53665366
}
5367-
Res::Def(DefKind::Method, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
5367+
Res::Def(DefKind::AssocFn, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
53685368
let container = tcx.associated_item(def_id).container;
53695369
debug!("instantiate_value_path: def_id={:?} container={:?}", def_id, container);
53705370
match container {

src/librustc_typeck/check/pat.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
682682
self.set_tainted_by_errors();
683683
return tcx.types.err;
684684
}
685-
Res::Def(DefKind::Method, _)
685+
Res::Def(DefKind::AssocFn, _)
686686
| Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _)
687687
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => {
688688
report_unexpected_variant_res(tcx, res, pat.span, qpath);
@@ -729,7 +729,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
729729
);
730730
let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg);
731731
match (res, &pat.kind) {
732-
(Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::Method, _), _) => {
732+
(Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::AssocFn, _), _) => {
733733
err.span_label(pat.span, "`fn` calls are not allowed in patterns");
734734
err.help(
735735
"for more information, visit \
@@ -766,7 +766,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
766766
on_error();
767767
return tcx.types.err;
768768
}
769-
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _) => {
769+
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::AssocFn, _) => {
770770
report_unexpected_res(res);
771771
return tcx.types.err;
772772
}

src/librustc_typeck/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
425425
| Res::Def(DefKind::ConstParam, _)
426426
| Res::Def(DefKind::AssocConst, _)
427427
| Res::Def(DefKind::Fn, _)
428-
| Res::Def(DefKind::Method, _)
428+
| Res::Def(DefKind::AssocFn, _)
429429
| Res::SelfCtor(..) => Ok(self.cat_rvalue(hir_id, span, expr_ty)),
430430

431431
Res::Def(DefKind::Static, _) => Ok(Place {

src/librustdoc/passes/collect_intra_doc_links.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
149149
// In case this is a trait item, skip the
150150
// early return and try looking for the trait.
151151
let value = match res {
152-
Res::Def(DefKind::Method, _) | Res::Def(DefKind::AssocConst, _) => true,
152+
Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::AssocConst, _) => true,
153153
Res::Def(DefKind::AssocTy, _) => false,
154154
Res::Def(DefKind::Variant, _) => {
155155
return handle_variant(cx, res, extra_fragment);
@@ -813,7 +813,7 @@ fn ambiguity_error(
813813

814814
for (res, ns) in candidates {
815815
let (action, mut suggestion) = match res {
816-
Res::Def(DefKind::Method, _) | Res::Def(DefKind::Fn, _) => {
816+
Res::Def(DefKind::AssocFn, _) | Res::Def(DefKind::Fn, _) => {
817817
("add parentheses", format!("{}()", path_str))
818818
}
819819
Res::Def(DefKind::Macro(..), _) => {

0 commit comments

Comments
 (0)