Skip to content

Commit

Permalink
Auto merge of #60955 - agnxy:rename-assoc, r=oli-obk,Centril
Browse files Browse the repository at this point in the history
Rename "Associated*" to "Assoc*"

This change is for #60163.

r? @oli-obk
  • Loading branch information
bors committed May 28, 2019
2 parents 87ed0b4 + c963596 commit 837b72c
Show file tree
Hide file tree
Showing 63 changed files with 350 additions and 350 deletions.
18 changes: 9 additions & 9 deletions src/librustc/hir/def.rs
Expand Up @@ -61,9 +61,9 @@ pub enum DefKind {
TyAlias,
ForeignTy,
TraitAlias,
AssociatedTy,
AssocTy,
/// `existential type Foo: Bar;`
AssociatedExistential,
AssocExistential,
TyParam,

// Value namespace
Expand All @@ -74,7 +74,7 @@ pub enum DefKind {
/// Refers to the struct or enum variant's constructor.
Ctor(CtorOf, CtorKind),
Method,
AssociatedConst,
AssocConst,

// Macro namespace
Macro(MacroKind),
Expand All @@ -99,14 +99,14 @@ impl DefKind {
DefKind::Existential => "existential type",
DefKind::TyAlias => "type alias",
DefKind::TraitAlias => "trait alias",
DefKind::AssociatedTy => "associated type",
DefKind::AssociatedExistential => "associated existential type",
DefKind::AssocTy => "associated type",
DefKind::AssocExistential => "associated existential type",
DefKind::Union => "union",
DefKind::Trait => "trait",
DefKind::ForeignTy => "foreign type",
DefKind::Method => "method",
DefKind::Const => "constant",
DefKind::AssociatedConst => "associated constant",
DefKind::AssocConst => "associated constant",
DefKind::TyParam => "type parameter",
DefKind::ConstParam => "const parameter",
DefKind::Macro(macro_kind) => macro_kind.descr(),
Expand All @@ -116,9 +116,9 @@ impl DefKind {
/// An English article for the def.
pub fn article(&self) -> &'static str {
match *self {
DefKind::AssociatedTy
| DefKind::AssociatedConst
| DefKind::AssociatedExistential
DefKind::AssocTy
| DefKind::AssocConst
| DefKind::AssocExistential
| DefKind::Enum
| DefKind::Existential => "an",
DefKind::Macro(macro_kind) => macro_kind.article(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/intravisit.rs
Expand Up @@ -370,7 +370,7 @@ pub trait Visitor<'v> : Sized {
fn visit_vis(&mut self, vis: &'v Visibility) {
walk_vis(self, vis)
}
fn visit_associated_item_kind(&mut self, kind: &'v AssociatedItemKind) {
fn visit_associated_item_kind(&mut self, kind: &'v AssocItemKind) {
walk_associated_item_kind(self, kind);
}
fn visit_defaultness(&mut self, defaultness: &'v Defaultness) {
Expand Down Expand Up @@ -1120,7 +1120,7 @@ pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
}
}

pub fn walk_associated_item_kind<'v, V: Visitor<'v>>(_: &mut V, _: &'v AssociatedItemKind) {
pub fn walk_associated_item_kind<'v, V: Visitor<'v>>(_: &mut V, _: &'v AssocItemKind) {
// No visitable content here: this fn exists so you can call it if
// the right thing to do, should content be added in the future,
// would be to walk it.
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/hir/lowering.rs
Expand Up @@ -1860,7 +1860,7 @@ impl<'a> LoweringContext<'a> {
index: this.def_key(def_id).parent.expect("missing parent"),
};
let type_def_id = match partial_res.base_res() {
Res::Def(DefKind::AssociatedTy, def_id) if i + 2 == proj_start => {
Res::Def(DefKind::AssocTy, def_id) if i + 2 == proj_start => {
Some(parent_def_id(self, def_id))
}
Res::Def(DefKind::Variant, def_id) if i + 1 == proj_start => {
Expand All @@ -1882,8 +1882,8 @@ impl<'a> LoweringContext<'a> {
if i + 1 == proj_start => ParenthesizedGenericArgs::Ok,
// `a::b::Trait(Args)::TraitItem`
Res::Def(DefKind::Method, _)
| Res::Def(DefKind::AssociatedConst, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::AssocTy, _)
if i + 2 == proj_start =>
{
ParenthesizedGenericArgs::Ok
Expand Down Expand Up @@ -3589,13 +3589,13 @@ impl<'a> LoweringContext<'a> {
fn lower_trait_item_ref(&mut self, i: &TraitItem) -> hir::TraitItemRef {
let (kind, has_default) = match i.node {
TraitItemKind::Const(_, ref default) => {
(hir::AssociatedItemKind::Const, default.is_some())
(hir::AssocItemKind::Const, default.is_some())
}
TraitItemKind::Type(_, ref default) => {
(hir::AssociatedItemKind::Type, default.is_some())
(hir::AssocItemKind::Type, default.is_some())
}
TraitItemKind::Method(ref sig, ref default) => (
hir::AssociatedItemKind::Method {
hir::AssocItemKind::Method {
has_self: sig.decl.has_self(),
},
default.is_some(),
Expand Down Expand Up @@ -3695,10 +3695,10 @@ impl<'a> LoweringContext<'a> {
vis: self.lower_visibility(&i.vis, Some(i.id)),
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
kind: match i.node {
ImplItemKind::Const(..) => hir::AssociatedItemKind::Const,
ImplItemKind::Type(..) => hir::AssociatedItemKind::Type,
ImplItemKind::Existential(..) => hir::AssociatedItemKind::Existential,
ImplItemKind::Method(ref sig, _) => hir::AssociatedItemKind::Method {
ImplItemKind::Const(..) => hir::AssocItemKind::Const,
ImplItemKind::Type(..) => hir::AssocItemKind::Type,
ImplItemKind::Existential(..) => hir::AssocItemKind::Existential,
ImplItemKind::Method(ref sig, _) => hir::AssocItemKind::Method {
has_self: sig.decl.has_self(),
},
ImplItemKind::Macro(..) => unimplemented!(),
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/hir/map/mod.rs
Expand Up @@ -337,17 +337,17 @@ impl<'hir> Map<'hir> {
}
Node::TraitItem(item) => {
match item.node {
TraitItemKind::Const(..) => DefKind::AssociatedConst,
TraitItemKind::Const(..) => DefKind::AssocConst,
TraitItemKind::Method(..) => DefKind::Method,
TraitItemKind::Type(..) => DefKind::AssociatedTy,
TraitItemKind::Type(..) => DefKind::AssocTy,
}
}
Node::ImplItem(item) => {
match item.node {
ImplItemKind::Const(..) => DefKind::AssociatedConst,
ImplItemKind::Const(..) => DefKind::AssocConst,
ImplItemKind::Method(..) => DefKind::Method,
ImplItemKind::Type(..) => DefKind::AssociatedTy,
ImplItemKind::Existential(..) => DefKind::AssociatedExistential,
ImplItemKind::Type(..) => DefKind::AssocTy,
ImplItemKind::Existential(..) => DefKind::AssocExistential,
}
}
Node::Variant(_) => DefKind::Variant,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/mod.rs
Expand Up @@ -2422,7 +2422,7 @@ pub struct TraitItemRef {
pub id: TraitItemId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssociatedItemKind,
pub kind: AssocItemKind,
pub span: Span,
pub defaultness: Defaultness,
}
Expand All @@ -2438,14 +2438,14 @@ pub struct ImplItemRef {
pub id: ImplItemId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssociatedItemKind,
pub kind: AssocItemKind,
pub span: Span,
pub vis: Visibility,
pub defaultness: Defaultness,
}

#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum AssociatedItemKind {
pub enum AssocItemKind {
Const,
Method { has_self: bool },
Type,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dead.rs
Expand Up @@ -72,7 +72,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
fn handle_res(&mut self, res: Res) {
match res {
Res::Def(DefKind::Const, _)
| Res::Def(DefKind::AssociatedConst, _)
| Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::TyAlias, _) => {
self.check_def_id(res.def_id());
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -909,7 +909,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
| Res::Def(DefKind::Ctor(..), _)
| Res::Def(DefKind::Union, _)
| Res::Def(DefKind::TyAlias, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocTy, _)
| Res::SelfTy(..) => {
debug!("struct cmt_pat={:?} pat={:?}", cmt_pat, pat);
delegate.matched_pat(pat, &cmt_pat, match_mode);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Expand Up @@ -703,7 +703,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
Res::Def(DefKind::Ctor(..), _)
| Res::Def(DefKind::Const, _)
| Res::Def(DefKind::ConstParam, _)
| Res::Def(DefKind::AssociatedConst, _)
| Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::Fn, _)
| Res::Def(DefKind::Method, _)
| Res::SelfCtor(..) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Expand Up @@ -118,7 +118,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
// If this path leads to a constant, then we need to
// recurse into the constant to continue finding
// items that are reachable.
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssociatedConst, _) => {
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {
self.worklist.push(hir_id);
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve_lifetime.rs
Expand Up @@ -1924,7 +1924,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
};
let type_def_id = match res {
Res::Def(DefKind::AssociatedTy, def_id)
Res::Def(DefKind::AssocTy, def_id)
if depth == 1 => Some(parent_def_id(self, def_id)),
Res::Def(DefKind::Variant, def_id)
if depth == 0 => Some(parent_def_id(self, def_id)),
Expand Down Expand Up @@ -2112,7 +2112,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
};

let has_self = match assoc_item_kind {
Some(hir::AssociatedItemKind::Method { has_self }) => has_self,
Some(hir::AssocItemKind::Method { has_self }) => has_self,
_ => false,
};

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/stability.rs
Expand Up @@ -527,8 +527,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// Check if `def_id` is a trait method.
match self.def_kind(def_id) {
Some(DefKind::Method) |
Some(DefKind::AssociatedTy) |
Some(DefKind::AssociatedConst) => {
Some(DefKind::AssocTy) |
Some(DefKind::AssocConst) => {
if let ty::TraitContainer(trait_def_id) = self.associated_item(def_id).container {
// Trait methods do not declare visibility (even
// for visibility info in cstore). Use containing
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Expand Up @@ -265,7 +265,7 @@ rustc_queries! {
query associated_item_def_ids(_: DefId) -> &'tcx [DefId] {}

/// Maps from a trait item to the trait item "descriptor".
query associated_item(_: DefId) -> ty::AssociatedItem {}
query associated_item(_: DefId) -> ty::AssocItem {}

query impl_trait_ref(_: DefId) -> Option<ty::TraitRef<'tcx>> {}
query impl_polarity(_: DefId) -> hir::ImplPolarity {}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/mod.rs
Expand Up @@ -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.
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/traits/object_safety.rs
Expand Up @@ -35,7 +35,7 @@ pub enum ObjectSafetyViolation {
Method(ast::Name, MethodViolationCode),

/// Associated const.
AssociatedConst(ast::Name),
AssocConst(ast::Name),
}

impl ObjectSafetyViolation {
Expand All @@ -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(),
}
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 837b72c

Please sign in to comment.