diff options
| author | Rustin-Liu <rustin.liu@gmail.com> | 2020-04-01 10:09:50 +0800 |
|---|---|---|
| committer | Rustin-Liu <rustin.liu@gmail.com> | 2020-04-14 07:12:07 +0800 |
| commit | b07e7fe0474849e62ce870af472eba6a985572d1 (patch) | |
| tree | 3a6fa6b490803e48adb45f18f50d5ac2db053019 /src/librustc_middle | |
| parent | 8e18e26f12b1e8b3e913b15278bf6185f0f61add (diff) | |
| download | rust-b07e7fe0474849e62ce870af472eba6a985572d1.tar.gz rust-b07e7fe0474849e62ce870af472eba6a985572d1.zip | |
Rename AssocKind::Method to AssocKind::Fn
Rename fn_has_self_argument to fn_has_self_parameter Rename AssocItemKind::Method to AssocItemKind::Fn Refine has_no_input_arg Refine has_no_input_arg Revert has_no_input_arg Refine suggestion_descr Move as_def_kind into AssocKind Signed-off-by: Rustin-Liu <rustin.liu@gmail.com> Fix tidy check issue Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
Diffstat (limited to 'src/librustc_middle')
| -rw-r--r-- | src/librustc_middle/traits/specialization_graph.rs | 4 | ||||
| -rw-r--r-- | src/librustc_middle/ty/adjustment.rs | 2 | ||||
| -rw-r--r-- | src/librustc_middle/ty/instance.rs | 2 | ||||
| -rw-r--r-- | src/librustc_middle/ty/mod.rs | 34 |
4 files changed, 16 insertions, 26 deletions
diff --git a/src/librustc_middle/traits/specialization_graph.rs b/src/librustc_middle/traits/specialization_graph.rs index a2793f98050..bc743666e4a 100644 --- a/src/librustc_middle/traits/specialization_graph.rs +++ b/src/librustc_middle/traits/specialization_graph.rs @@ -107,13 +107,13 @@ impl<'tcx> Node { .find(move |impl_item| { match (trait_item_kind, impl_item.kind) { | (Const, Const) - | (Method, Method) + | (Fn, Fn) | (Type, Type) | (Type, OpaqueTy) // assoc. types can be made opaque in impls => tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id), | (Const, _) - | (Method, _) + | (Fn, _) | (Type, _) | (OpaqueTy, _) => false, diff --git a/src/librustc_middle/ty/adjustment.rs b/src/librustc_middle/ty/adjustment.rs index 851bffc2065..efd5adeba8c 100644 --- a/src/librustc_middle/ty/adjustment.rs +++ b/src/librustc_middle/ty/adjustment.rs @@ -123,7 +123,7 @@ impl<'tcx> OverloadedDeref<'tcx> { let method_def_id = tcx .associated_items(trait_def_id.unwrap()) .in_definition_order() - .find(|m| m.kind == ty::AssocKind::Method) + .find(|m| m.kind == ty::AssocKind::Fn) .unwrap() .def_id; (method_def_id, tcx.mk_substs_trait(source, &[])) diff --git a/src/librustc_middle/ty/instance.rs b/src/librustc_middle/ty/instance.rs index 894f9070ce1..ca76cfb1492 100644 --- a/src/librustc_middle/ty/instance.rs +++ b/src/librustc_middle/ty/instance.rs @@ -366,7 +366,7 @@ impl<'tcx> Instance<'tcx> { let call_once = tcx .associated_items(fn_once) .in_definition_order() - .find(|it| it.kind == ty::AssocKind::Method) + .find(|it| it.kind == ty::AssocKind::Fn) .unwrap() .def_id; let def = ty::InstanceDef::ClosureOnceShim { call_once }; diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 0e6c4f26222..8d50f560a83 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -1,5 +1,3 @@ -// ignore-tidy-filelength - pub use self::fold::{TypeFoldable, TypeVisitor}; pub use self::AssocItemContainer::*; pub use self::BorrowKind::*; @@ -192,58 +190,50 @@ pub struct AssocItem { pub container: AssocItemContainer, /// Whether this is a method with an explicit self - /// as its first argument, allowing method calls. - pub method_has_self_argument: bool, + /// as its first parameter, allowing method calls. + pub fn_has_self_parameter: bool, } #[derive(Copy, Clone, PartialEq, Debug, HashStable)] pub enum AssocKind { Const, - Method, + Fn, OpaqueTy, Type, } impl AssocKind { - pub fn suggestion_descr(&self) -> &'static str { - match self { - ty::AssocKind::Method => "method call", - ty::AssocKind::Type | ty::AssocKind::OpaqueTy => "associated type", - ty::AssocKind::Const => "associated constant", - } - } - pub fn namespace(&self) -> Namespace { match *self { ty::AssocKind::OpaqueTy | ty::AssocKind::Type => Namespace::TypeNS, - ty::AssocKind::Const | ty::AssocKind::Method => Namespace::ValueNS, + ty::AssocKind::Const | ty::AssocKind::Fn => Namespace::ValueNS, } } -} -impl AssocItem { - pub fn def_kind(&self) -> DefKind { - match self.kind { + pub fn as_def_kind(&self) -> DefKind { + match self { AssocKind::Const => DefKind::AssocConst, - AssocKind::Method => DefKind::AssocFn, + AssocKind::Fn => DefKind::AssocFn, AssocKind::Type => DefKind::AssocTy, AssocKind::OpaqueTy => DefKind::AssocOpaqueTy, } } +} +impl AssocItem { /// Tests whether the associated item admits a non-trivial implementation /// for ! pub fn relevant_for_never(&self) -> bool { match self.kind { AssocKind::OpaqueTy | AssocKind::Const | AssocKind::Type => true, // FIXME(canndrew): Be more thorough here, check if any argument is uninhabited. - AssocKind::Method => !self.method_has_self_argument, + AssocKind::Fn => !self.fn_has_self_parameter, } } pub fn signature(&self, tcx: TyCtxt<'_>) -> String { match self.kind { - ty::AssocKind::Method => { + ty::AssocKind::Fn => { // We skip the binder here because the binder would deanonymize all // late-bound regions, and we don't want method signatures to show up // `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound @@ -2664,7 +2654,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> { self.associated_items(id) .in_definition_order() - .filter(|item| item.kind == AssocKind::Method && item.defaultness.has_value()) + .filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value()) } pub fn trait_relevant_for_never(self, did: DefId) -> bool { |
