diff options
| author | Andrew Xu <andrewxuyuan@gmail.com> | 2019-05-19 16:26:08 +0800 |
|---|---|---|
| committer | Andrew Xu <andrewxuyuan@gmail.com> | 2019-05-26 17:49:02 +0800 |
| commit | 46b9ed4fa1feae35a3ab31fbfe50b9b1d9bbcea8 (patch) | |
| tree | e34fa813504eeb4064e236db5b1ba4bfdee0e4f0 /src/librustc/traits | |
| parent | 2268d9923bcb34a6c921d285cca7fa3dba857c02 (diff) | |
| download | rust-46b9ed4fa1feae35a3ab31fbfe50b9b1d9bbcea8.tar.gz rust-46b9ed4fa1feae35a3ab31fbfe50b9b1d9bbcea8.zip | |
Rename "Associated*" to "Assoc*"
We are going to uniform the terminology of all associated items. Methods that may or may not have `self` are called "associated functions". Because `AssociatedFn` is a bit long, we rename `Associated` to `Assoc`.
Diffstat (limited to 'src/librustc/traits')
| -rw-r--r-- | src/librustc/traits/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc/traits/object_safety.rs | 20 | ||||
| -rw-r--r-- | src/librustc/traits/project.rs | 24 | ||||
| -rw-r--r-- | src/librustc/traits/specialize/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc/traits/specialize/specialization_graph.rs | 8 | ||||
| -rw-r--r-- | src/librustc/traits/util.rs | 6 |
6 files changed, 31 insertions, 31 deletions
diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index a4b9ed0a206..4b555e54f39 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -993,7 +993,7 @@ fn vtable_methods<'a, 'tcx>( tcx.arena.alloc_from_iter( supertraits(tcx, trait_ref).flat_map(move |trait_ref| { let trait_methods = tcx.associated_items(trait_ref.def_id()) - .filter(|item| item.kind == ty::AssociatedKind::Method); + .filter(|item| item.kind == ty::AssocKind::Method); // Now list each method's DefId and InternalSubsts (for within its trait). // If the method can never be called from this object, produce None. diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 55216f644a1..5006ff75667 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -35,7 +35,7 @@ pub enum ObjectSafetyViolation { Method(ast::Name, MethodViolationCode), /// Associated const. - AssociatedConst(ast::Name), + AssocConst(ast::Name), } impl ObjectSafetyViolation { @@ -58,7 +58,7 @@ impl ObjectSafetyViolation { format!("method `{}` has generic type parameters", name).into(), ObjectSafetyViolation::Method(name, MethodViolationCode::UndispatchableReceiver) => format!("method `{}`'s receiver cannot be dispatched on", name).into(), - ObjectSafetyViolation::AssociatedConst(name) => + ObjectSafetyViolation::AssocConst(name) => format!("the trait cannot contain associated consts like `{}`", name).into(), } } @@ -119,7 +119,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { { // Check methods for violations. let mut violations: Vec<_> = self.associated_items(trait_def_id) - .filter(|item| item.kind == ty::AssociatedKind::Method) + .filter(|item| item.kind == ty::AssocKind::Method) .filter_map(|item| self.object_safety_violation_for_method(trait_def_id, &item) .map(|code| ObjectSafetyViolation::Method(item.ident.name, code)) @@ -151,8 +151,8 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { } violations.extend(self.associated_items(trait_def_id) - .filter(|item| item.kind == ty::AssociatedKind::Const) - .map(|item| ObjectSafetyViolation::AssociatedConst(item.ident.name))); + .filter(|item| item.kind == ty::AssocKind::Const) + .map(|item| ObjectSafetyViolation::AssocConst(item.ident.name))); debug!("object_safety_violations_for_trait(trait_def_id={:?}) = {:?}", trait_def_id, @@ -251,7 +251,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { /// Returns `Some(_)` if this method makes the containing trait not object safe. fn object_safety_violation_for_method(self, trait_def_id: DefId, - method: &ty::AssociatedItem) + method: &ty::AssocItem) -> Option<MethodViolationCode> { debug!("object_safety_violation_for_method({:?}, {:?})", trait_def_id, method); @@ -270,7 +270,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { /// otherwise ensure that they cannot be used when `Self=Trait`. pub fn is_vtable_safe_method(self, trait_def_id: DefId, - method: &ty::AssociatedItem) + method: &ty::AssocItem) -> bool { debug!("is_vtable_safe_method({:?}, {:?})", trait_def_id, method); @@ -291,7 +291,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { /// `Self:Sized`. fn virtual_call_violation_for_method(self, trait_def_id: DefId, - method: &ty::AssociatedItem) + method: &ty::AssocItem) -> Option<MethodViolationCode> { // The method's first parameter must be named `self` @@ -439,7 +439,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { self.associated_items(super_trait_ref.def_id()) .map(move |item| (super_trait_ref, item)) }) - .filter(|(_, item)| item.kind == ty::AssociatedKind::Type) + .filter(|(_, item)| item.kind == ty::AssocKind::Type) .collect::<Vec<_>>(); // existential predicates need to be in a specific order @@ -520,7 +520,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { #[allow(dead_code)] fn receiver_is_dispatchable( self, - method: &ty::AssociatedItem, + method: &ty::AssocItem, receiver_ty: Ty<'tcx>, ) -> bool { debug!("receiver_is_dispatchable: method = {:?}, receiver_ty = {:?}", method, receiver_ty); diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index b1c4e409112..92d5d4f0319 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -275,7 +275,7 @@ pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>( where T : TypeFoldable<'tcx> { debug!("normalize_with_depth(depth={}, value={:?})", depth, value); - let mut normalizer = AssociatedTypeNormalizer::new(selcx, param_env, cause, depth); + let mut normalizer = AssocTypeNormalizer::new(selcx, param_env, cause, depth); let result = normalizer.fold(value); debug!("normalize_with_depth: depth={} result={:?} with {} obligations", depth, result, normalizer.obligations.len()); @@ -287,7 +287,7 @@ pub fn normalize_with_depth<'a, 'b, 'gcx, 'tcx, T>( } } -struct AssociatedTypeNormalizer<'a, 'b: 'a, 'gcx: 'b+'tcx, 'tcx: 'b> { +struct AssocTypeNormalizer<'a, 'b: 'a, 'gcx: 'b+'tcx, 'tcx: 'b> { selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, @@ -295,14 +295,14 @@ struct AssociatedTypeNormalizer<'a, 'b: 'a, 'gcx: 'b+'tcx, 'tcx: 'b> { depth: usize, } -impl<'a, 'b, 'gcx, 'tcx> AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> { +impl<'a, 'b, 'gcx, 'tcx> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { fn new(selcx: &'a mut SelectionContext<'b, 'gcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, depth: usize) - -> AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> + -> AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { - AssociatedTypeNormalizer { + AssocTypeNormalizer { selcx, param_env, cause, @@ -322,7 +322,7 @@ impl<'a, 'b, 'gcx, 'tcx> AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> { } } -impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> { +impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssocTypeNormalizer<'a, 'b, 'gcx, 'tcx> { fn tcx<'c>(&'c self) -> TyCtxt<'c, 'gcx, 'tcx> { self.selcx.tcx() } @@ -388,7 +388,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, self.cause.clone(), self.depth, &mut self.obligations); - debug!("AssociatedTypeNormalizer: depth={} normalized {:?} to {:?}, \ + debug!("AssocTypeNormalizer: depth={} normalized {:?} to {:?}, \ now with {} obligations", self.depth, ty, normalized_ty, self.obligations.len()); normalized_ty @@ -635,7 +635,7 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>( projected_obligations); let result = if projected_ty.has_projections() { - let mut normalizer = AssociatedTypeNormalizer::new(selcx, + let mut normalizer = AssocTypeNormalizer::new(selcx, param_env, cause, depth+1); @@ -1496,7 +1496,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>( }; } let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node); - let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind { + let ty = if let ty::AssocKind::Existential = assoc_ty.item.kind { let item_substs = InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id); tcx.mk_opaque(assoc_ty.item.def_id, item_substs) } else { @@ -1517,7 +1517,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>( selcx: &SelectionContext<'cx, 'gcx, 'tcx>, impl_def_id: DefId, assoc_ty_def_id: DefId) - -> specialization_graph::NodeItem<ty::AssociatedItem> + -> specialization_graph::NodeItem<ty::AssocItem> { let tcx = selcx.tcx(); let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).ident; @@ -1532,7 +1532,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>( // cycle error if the specialization graph is currently being built. let impl_node = specialization_graph::Node::Impl(impl_def_id); for item in impl_node.items(tcx) { - if item.kind == ty::AssociatedKind::Type && + if item.kind == ty::AssocKind::Type && tcx.hygienic_eq(item.ident, assoc_ty_name, trait_def_id) { return specialization_graph::NodeItem { node: specialization_graph::Node::Impl(impl_def_id), @@ -1543,7 +1543,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>( if let Some(assoc_item) = trait_def .ancestors(tcx, impl_def_id) - .defs(tcx, assoc_ty_name, ty::AssociatedKind::Type, trait_def_id) + .defs(tcx, assoc_ty_name, ty::AssocKind::Type, trait_def_id) .next() { assoc_item } else { diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index fdd1a821e31..5da4a1b9c5f 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -112,7 +112,7 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, pub fn find_associated_item<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, - item: &ty::AssociatedItem, + item: &ty::AssocItem, substs: SubstsRef<'tcx>, impl_data: &super::VtableImplData<'tcx, ()>, ) -> (DefId, SubstsRef<'tcx>) { diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index dae1518d722..9a90b9fdaea 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -426,7 +426,7 @@ impl<'a, 'gcx, 'tcx> Node { pub fn items( &self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - ) -> ty::AssociatedItemsIterator<'a, 'gcx, 'tcx> { + ) -> ty::AssocItemsIterator<'a, 'gcx, 'tcx> { tcx.associated_items(self.def_id()) } @@ -484,11 +484,11 @@ impl<'a, 'gcx, 'tcx> Ancestors<'gcx> { self, tcx: TyCtxt<'a, 'gcx, 'tcx>, trait_item_name: Ident, - trait_item_kind: ty::AssociatedKind, + trait_item_kind: ty::AssocKind, trait_def_id: DefId, - ) -> impl Iterator<Item = NodeItem<ty::AssociatedItem>> + Captures<'gcx> + Captures<'tcx> + 'a { + ) -> impl Iterator<Item = NodeItem<ty::AssocItem>> + Captures<'gcx> + Captures<'tcx> + 'a { self.flat_map(move |node| { - use crate::ty::AssociatedKind::*; + use crate::ty::AssocKind::*; node.items(tcx).filter(move |impl_item| match (trait_item_kind, impl_item.kind) { | (Const, Const) | (Method, Method) diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 5ba23a9c45a..2f87a743a01 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -594,7 +594,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // Count number of methods and add them to the total offset. // Skip over associated types and constants. for trait_item in self.associated_items(trait_ref.def_id()) { - if trait_item.kind == ty::AssociatedKind::Method { + if trait_item.kind == ty::AssocKind::Method { entries += 1; } } @@ -614,10 +614,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { for trait_item in self.associated_items(object.upcast_trait_ref.def_id()) { if trait_item.def_id == method_def_id { // The item with the ID we were given really ought to be a method. - assert_eq!(trait_item.kind, ty::AssociatedKind::Method); + assert_eq!(trait_item.kind, ty::AssocKind::Method); return entries; } - if trait_item.kind == ty::AssociatedKind::Method { + if trait_item.kind == ty::AssocKind::Method { entries += 1; } } |
