Skip to content

Commit 513a647

Browse files
committed
Auto merge of #70643 - Rustin-Liu:rustin-patch-rename, r=eddyb
Rename AssocKind::Method to AssocKind::Fn Part of #60163. #60163 (comment)
2 parents 47f4969 + b07e7fe commit 513a647

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+119
-126
lines changed

src/librustc_ast_lowering/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
796796
(hir::AssocItemKind::Type, default.is_some())
797797
}
798798
AssocItemKind::Fn(_, sig, _, default) => {
799-
(hir::AssocItemKind::Method { has_self: sig.decl.has_self() }, default.is_some())
799+
(hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }, default.is_some())
800800
}
801801
AssocItemKind::MacCall(..) => unimplemented!(),
802802
};
@@ -894,7 +894,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
894894
}
895895
}
896896
AssocItemKind::Fn(_, sig, ..) => {
897-
hir::AssocItemKind::Method { has_self: sig.decl.has_self() }
897+
hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }
898898
}
899899
AssocItemKind::MacCall(..) => unimplemented!(),
900900
},

src/librustc_hir/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2515,7 +2515,7 @@ pub struct ImplItemRef<'hir> {
25152515
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
25162516
pub enum AssocItemKind {
25172517
Const,
2518-
Method { has_self: bool },
2518+
Fn { has_self: bool },
25192519
Type,
25202520
OpaqueTy,
25212521
}

src/librustc_infer/infer/error_reporting/nice_region_error/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
118118
// enable E0621 for it.
119119
pub(super) fn is_self_anon(&self, is_first: bool, scope_def_id: DefId) -> bool {
120120
is_first
121-
&& self.tcx().opt_associated_item(scope_def_id).map(|i| i.method_has_self_argument)
121+
&& self.tcx().opt_associated_item(scope_def_id).map(|i| i.fn_has_self_parameter)
122122
== Some(true)
123123
}
124124
}

src/librustc_metadata/rmeta/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11531153
EntryKind::AssocConst(container, _, _) => (ty::AssocKind::Const, container, false),
11541154
EntryKind::AssocFn(data) => {
11551155
let data = data.decode(self);
1156-
(ty::AssocKind::Method, data.container, data.has_self)
1156+
(ty::AssocKind::Fn, data.container, data.has_self)
11571157
}
11581158
EntryKind::AssocType(container) => (ty::AssocKind::Type, container, false),
11591159
EntryKind::AssocOpaqueTy(container) => (ty::AssocKind::OpaqueTy, container, false),
@@ -1167,7 +1167,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11671167
defaultness: container.defaultness(),
11681168
def_id: self.local_def_id(id),
11691169
container: container.with_def_id(parent),
1170-
method_has_self_argument: has_self,
1170+
fn_has_self_parameter: has_self,
11711171
}
11721172
}
11731173

src/librustc_metadata/rmeta/encoder.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ impl EncodeContext<'tcx> {
839839
rendered_const,
840840
)
841841
}
842-
ty::AssocKind::Method => {
842+
ty::AssocKind::Fn => {
843843
let fn_data = if let hir::TraitItemKind::Fn(m_sig, m) = &ast_item.kind {
844844
let param_names = match *m {
845845
hir::TraitFn::Required(ref names) => {
@@ -860,7 +860,7 @@ impl EncodeContext<'tcx> {
860860
EntryKind::AssocFn(self.lazy(AssocFnData {
861861
fn_data,
862862
container,
863-
has_self: trait_item.method_has_self_argument,
863+
has_self: trait_item.fn_has_self_parameter,
864864
}))
865865
}
866866
ty::AssocKind::Type => EntryKind::AssocType(container),
@@ -874,7 +874,7 @@ impl EncodeContext<'tcx> {
874874
self.encode_const_stability(def_id);
875875
self.encode_deprecation(def_id);
876876
match trait_item.kind {
877-
ty::AssocKind::Const | ty::AssocKind::Method => {
877+
ty::AssocKind::Const | ty::AssocKind::Fn => {
878878
self.encode_item_type(def_id);
879879
}
880880
ty::AssocKind::Type => {
@@ -884,7 +884,7 @@ impl EncodeContext<'tcx> {
884884
}
885885
ty::AssocKind::OpaqueTy => unreachable!(),
886886
}
887-
if trait_item.kind == ty::AssocKind::Method {
887+
if trait_item.kind == ty::AssocKind::Fn {
888888
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
889889
self.encode_variances_of(def_id);
890890
}
@@ -931,7 +931,7 @@ impl EncodeContext<'tcx> {
931931
bug!()
932932
}
933933
}
934-
ty::AssocKind::Method => {
934+
ty::AssocKind::Fn => {
935935
let fn_data = if let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind {
936936
FnData {
937937
asyncness: sig.header.asyncness,
@@ -944,7 +944,7 @@ impl EncodeContext<'tcx> {
944944
EntryKind::AssocFn(self.lazy(AssocFnData {
945945
fn_data,
946946
container,
947-
has_self: impl_item.method_has_self_argument,
947+
has_self: impl_item.fn_has_self_parameter,
948948
}))
949949
}
950950
ty::AssocKind::OpaqueTy => EntryKind::AssocOpaqueTy(container),
@@ -958,7 +958,7 @@ impl EncodeContext<'tcx> {
958958
self.encode_const_stability(def_id);
959959
self.encode_deprecation(def_id);
960960
self.encode_item_type(def_id);
961-
if impl_item.kind == ty::AssocKind::Method {
961+
if impl_item.kind == ty::AssocKind::Fn {
962962
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
963963
self.encode_variances_of(def_id);
964964
}

src/librustc_middle/traits/specialization_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ impl<'tcx> Node {
107107
.find(move |impl_item| {
108108
match (trait_item_kind, impl_item.kind) {
109109
| (Const, Const)
110-
| (Method, Method)
110+
| (Fn, Fn)
111111
| (Type, Type)
112112
| (Type, OpaqueTy) // assoc. types can be made opaque in impls
113113
=> tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id),
114114

115115
| (Const, _)
116-
| (Method, _)
116+
| (Fn, _)
117117
| (Type, _)
118118
| (OpaqueTy, _)
119119
=> false,

src/librustc_middle/ty/adjustment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'tcx> OverloadedDeref<'tcx> {
123123
let method_def_id = tcx
124124
.associated_items(trait_def_id.unwrap())
125125
.in_definition_order()
126-
.find(|m| m.kind == ty::AssocKind::Method)
126+
.find(|m| m.kind == ty::AssocKind::Fn)
127127
.unwrap()
128128
.def_id;
129129
(method_def_id, tcx.mk_substs_trait(source, &[]))

src/librustc_middle/ty/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl<'tcx> Instance<'tcx> {
366366
let call_once = tcx
367367
.associated_items(fn_once)
368368
.in_definition_order()
369-
.find(|it| it.kind == ty::AssocKind::Method)
369+
.find(|it| it.kind == ty::AssocKind::Fn)
370370
.unwrap()
371371
.def_id;
372372
let def = ty::InstanceDef::ClosureOnceShim { call_once };

src/librustc_middle/ty/mod.rs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-tidy-filelength
2-
31
pub use self::fold::{TypeFoldable, TypeVisitor};
42
pub use self::AssocItemContainer::*;
53
pub use self::BorrowKind::*;
@@ -192,58 +190,50 @@ pub struct AssocItem {
192190
pub container: AssocItemContainer,
193191

194192
/// Whether this is a method with an explicit self
195-
/// as its first argument, allowing method calls.
196-
pub method_has_self_argument: bool,
193+
/// as its first parameter, allowing method calls.
194+
pub fn_has_self_parameter: bool,
197195
}
198196

199197
#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
200198
pub enum AssocKind {
201199
Const,
202-
Method,
200+
Fn,
203201
OpaqueTy,
204202
Type,
205203
}
206204

207205
impl AssocKind {
208-
pub fn suggestion_descr(&self) -> &'static str {
209-
match self {
210-
ty::AssocKind::Method => "method call",
211-
ty::AssocKind::Type | ty::AssocKind::OpaqueTy => "associated type",
212-
ty::AssocKind::Const => "associated constant",
213-
}
214-
}
215-
216206
pub fn namespace(&self) -> Namespace {
217207
match *self {
218208
ty::AssocKind::OpaqueTy | ty::AssocKind::Type => Namespace::TypeNS,
219-
ty::AssocKind::Const | ty::AssocKind::Method => Namespace::ValueNS,
209+
ty::AssocKind::Const | ty::AssocKind::Fn => Namespace::ValueNS,
220210
}
221211
}
222-
}
223212

224-
impl AssocItem {
225-
pub fn def_kind(&self) -> DefKind {
226-
match self.kind {
213+
pub fn as_def_kind(&self) -> DefKind {
214+
match self {
227215
AssocKind::Const => DefKind::AssocConst,
228-
AssocKind::Method => DefKind::AssocFn,
216+
AssocKind::Fn => DefKind::AssocFn,
229217
AssocKind::Type => DefKind::AssocTy,
230218
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
231219
}
232220
}
221+
}
233222

223+
impl AssocItem {
234224
/// Tests whether the associated item admits a non-trivial implementation
235225
/// for !
236226
pub fn relevant_for_never(&self) -> bool {
237227
match self.kind {
238228
AssocKind::OpaqueTy | AssocKind::Const | AssocKind::Type => true,
239229
// FIXME(canndrew): Be more thorough here, check if any argument is uninhabited.
240-
AssocKind::Method => !self.method_has_self_argument,
230+
AssocKind::Fn => !self.fn_has_self_parameter,
241231
}
242232
}
243233

244234
pub fn signature(&self, tcx: TyCtxt<'_>) -> String {
245235
match self.kind {
246-
ty::AssocKind::Method => {
236+
ty::AssocKind::Fn => {
247237
// We skip the binder here because the binder would deanonymize all
248238
// late-bound regions, and we don't want method signatures to show up
249239
// `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound
@@ -2664,7 +2654,7 @@ impl<'tcx> TyCtxt<'tcx> {
26642654
pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> {
26652655
self.associated_items(id)
26662656
.in_definition_order()
2667-
.filter(|item| item.kind == AssocKind::Method && item.defaultness.has_value())
2657+
.filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value())
26682658
}
26692659

26702660
pub fn trait_relevant_for_never(self, did: DefId) -> bool {

src/librustc_mir/shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> &'tcx
7474
let call_mut = tcx
7575
.associated_items(fn_mut)
7676
.in_definition_order()
77-
.find(|it| it.kind == ty::AssocKind::Method)
77+
.find(|it| it.kind == ty::AssocKind::Fn)
7878
.unwrap()
7979
.def_id;
8080

0 commit comments

Comments
 (0)