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`.
This commit is contained in:
Andrew Xu 2019-05-19 16:26:08 +08:00
parent 2268d9923b
commit 46b9ed4fa1
62 changed files with 349 additions and 349 deletions

View File

@ -61,9 +61,9 @@ pub enum DefKind {
TyAlias,
ForeignTy,
TraitAlias,
AssociatedTy,
AssocTy,
/// `existential type Foo: Bar;`
AssociatedExistential,
AssocExistential,
TyParam,
// Value namespace
@ -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),
@ -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(),
@ -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(),

View File

@ -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) {
@ -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.

View File

@ -1862,7 +1862,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 => {
@ -1884,8 +1884,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
@ -3591,13 +3591,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(),
@ -3697,10 +3697,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!(),

View File

@ -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,

View File

@ -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,
}
@ -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,

View File

@ -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());
}

View File

@ -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);

View File

@ -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(..) => {

View File

@ -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);
}

View File

@ -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)),
@ -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,
};

View File

@ -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

View File

@ -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 {}

View File

@ -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.

View File

@ -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);

View File

@ -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 {

View File

@ -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>) {

View File

@ -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)

View File

@ -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;
}
}

View File

@ -111,7 +111,7 @@ impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> {
hir::MutMutable => tcx.lang_items().deref_mut_trait()
};
let method_def_id = tcx.associated_items(trait_def_id.unwrap())
.find(|m| m.kind == ty::AssociatedKind::Method).unwrap().def_id;
.find(|m| m.kind == ty::AssocKind::Method).unwrap().def_id;
(method_def_id, tcx.mk_substs_trait(source, &[]))
}
}

View File

@ -341,7 +341,7 @@ impl<'a, 'b, 'tcx> Instance<'tcx> {
fn resolve_associated_item<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
trait_item: &ty::AssociatedItem,
trait_item: &ty::AssocItem,
param_env: ty::ParamEnv<'tcx>,
trait_id: DefId,
rcvr_substs: SubstsRef<'tcx>,
@ -450,7 +450,7 @@ fn fn_once_adapter_instance<'a, 'tcx>(
substs);
let fn_once = tcx.lang_items().fn_once_trait().unwrap();
let call_once = tcx.associated_items(fn_once)
.find(|it| it.kind == ty::AssociatedKind::Method)
.find(|it| it.kind == ty::AssocKind::Method)
.unwrap().def_id;
let def = ty::InstanceDef::ClosureOnceShim { call_once };

View File

@ -3,7 +3,7 @@
#![allow(usage_of_ty_tykind)]
pub use self::Variance::*;
pub use self::AssociatedItemContainer::*;
pub use self::AssocItemContainer::*;
pub use self::BorrowKind::*;
pub use self::IntVarValue::*;
pub use self::fold::TypeFoldable;
@ -134,12 +134,12 @@ pub struct Resolutions {
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable)]
pub enum AssociatedItemContainer {
pub enum AssocItemContainer {
TraitContainer(DefId),
ImplContainer(DefId),
}
impl AssociatedItemContainer {
impl AssocItemContainer {
/// Asserts that this is the `DefId` of an associated item declared
/// in a trait, and returns the trait `DefId`.
pub fn assert_trait(&self) -> DefId {
@ -169,14 +169,14 @@ pub struct ImplHeader<'tcx> {
}
#[derive(Copy, Clone, Debug, PartialEq, HashStable)]
pub struct AssociatedItem {
pub struct AssocItem {
pub def_id: DefId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssociatedKind,
pub kind: AssocKind,
pub vis: Visibility,
pub defaultness: hir::Defaultness,
pub container: AssociatedItemContainer,
pub container: AssocItemContainer,
/// Whether this is a method with an explicit self
/// as its first argument, allowing method calls.
@ -184,20 +184,20 @@ pub struct AssociatedItem {
}
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, RustcEncodable, RustcDecodable, HashStable)]
pub enum AssociatedKind {
pub enum AssocKind {
Const,
Method,
Existential,
Type
}
impl AssociatedItem {
impl AssocItem {
pub fn def_kind(&self) -> DefKind {
match self.kind {
AssociatedKind::Const => DefKind::AssociatedConst,
AssociatedKind::Method => DefKind::Method,
AssociatedKind::Type => DefKind::AssociatedTy,
AssociatedKind::Existential => DefKind::AssociatedExistential,
AssocKind::Const => DefKind::AssocConst,
AssocKind::Method => DefKind::Method,
AssocKind::Type => DefKind::AssocTy,
AssocKind::Existential => DefKind::AssocExistential,
}
}
@ -205,26 +205,26 @@ impl AssociatedItem {
/// for !
pub fn relevant_for_never<'tcx>(&self) -> bool {
match self.kind {
AssociatedKind::Existential |
AssociatedKind::Const |
AssociatedKind::Type => true,
AssocKind::Existential |
AssocKind::Const |
AssocKind::Type => true,
// FIXME(canndrew): Be more thorough here, check if any argument is uninhabited.
AssociatedKind::Method => !self.method_has_self_argument,
AssocKind::Method => !self.method_has_self_argument,
}
}
pub fn signature<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> String {
match self.kind {
ty::AssociatedKind::Method => {
ty::AssocKind::Method => {
// 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
// regions just fine, showing `fn(&MyType)`.
tcx.fn_sig(self.def_id).skip_binder().to_string()
}
ty::AssociatedKind::Type => format!("type {};", self.ident),
ty::AssociatedKind::Existential => format!("existential type {};", self.ident),
ty::AssociatedKind::Const => {
ty::AssocKind::Type => format!("type {};", self.ident),
ty::AssocKind::Existential => format!("existential type {};", self.ident),
ty::AssocKind::Const => {
format!("const {}: {:?};", self.ident, tcx.type_of(self.def_id))
}
}
@ -2343,7 +2343,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
Res::Def(DefKind::Variant, vid) => self.variant_with_id(vid),
Res::Def(DefKind::Ctor(..), cid) => self.variant_with_ctor_id(cid),
Res::Def(DefKind::Struct, _) | Res::Def(DefKind::Union, _) |
Res::Def(DefKind::TyAlias, _) | Res::Def(DefKind::AssociatedTy, _) | Res::SelfTy(..) |
Res::Def(DefKind::TyAlias, _) | Res::Def(DefKind::AssocTy, _) | Res::SelfTy(..) |
Res::SelfCtor(..) => self.non_enum_variant(),
_ => bug!("unexpected res {:?} in variant_of_res", res)
}
@ -2793,9 +2793,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
pub fn provided_trait_methods(self, id: DefId) -> Vec<AssociatedItem> {
pub fn provided_trait_methods(self, id: DefId) -> Vec<AssocItem> {
self.associated_items(id)
.filter(|item| item.kind == AssociatedKind::Method && item.defaultness.has_value())
.filter(|item| item.kind == AssocKind::Method && item.defaultness.has_value())
.collect()
}
@ -2805,7 +2805,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
})
}
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssociatedItem> {
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
let is_associated_item = if let Some(hir_id) = self.hir().as_local_hir_id(def_id) {
match self.hir().get_by_hir_id(hir_id) {
Node::TraitItem(_) | Node::ImplItem(_) => true,
@ -2813,9 +2813,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
} else {
match self.def_kind(def_id).expect("no def for def-id") {
DefKind::AssociatedConst
DefKind::AssocConst
| DefKind::Method
| DefKind::AssociatedTy => true,
| DefKind::AssocTy => true,
_ => false,
}
};
@ -2831,18 +2831,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
parent_def_id: DefId,
parent_vis: &hir::Visibility,
trait_item_ref: &hir::TraitItemRef)
-> AssociatedItem {
-> AssocItem {
let def_id = self.hir().local_def_id_from_hir_id(trait_item_ref.id.hir_id);
let (kind, has_self) = match trait_item_ref.kind {
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
hir::AssociatedItemKind::Method { has_self } => {
(ty::AssociatedKind::Method, has_self)
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
hir::AssocItemKind::Method { has_self } => {
(ty::AssocKind::Method, has_self)
}
hir::AssociatedItemKind::Type => (ty::AssociatedKind::Type, false),
hir::AssociatedItemKind::Existential => bug!("only impls can have existentials"),
hir::AssocItemKind::Type => (ty::AssocKind::Type, false),
hir::AssocItemKind::Existential => bug!("only impls can have existentials"),
};
AssociatedItem {
AssocItem {
ident: trait_item_ref.ident,
kind,
// Visibility of trait items is inherited from their traits.
@ -2857,18 +2857,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
fn associated_item_from_impl_item_ref(self,
parent_def_id: DefId,
impl_item_ref: &hir::ImplItemRef)
-> AssociatedItem {
-> AssocItem {
let def_id = self.hir().local_def_id_from_hir_id(impl_item_ref.id.hir_id);
let (kind, has_self) = match impl_item_ref.kind {
hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false),
hir::AssociatedItemKind::Method { has_self } => {
(ty::AssociatedKind::Method, has_self)
hir::AssocItemKind::Const => (ty::AssocKind::Const, false),
hir::AssocItemKind::Method { has_self } => {
(ty::AssocKind::Method, has_self)
}
hir::AssociatedItemKind::Type => (ty::AssociatedKind::Type, false),
hir::AssociatedItemKind::Existential => (ty::AssociatedKind::Existential, false),
hir::AssocItemKind::Type => (ty::AssocKind::Type, false),
hir::AssocItemKind::Existential => (ty::AssocKind::Existential, false),
};
AssociatedItem {
AssocItem {
ident: impl_item_ref.ident,
kind,
// Visibility of trait impl items doesn't matter.
@ -2893,13 +2893,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn associated_items(
self,
def_id: DefId,
) -> AssociatedItemsIterator<'a, 'gcx, 'tcx> {
) -> AssocItemsIterator<'a, 'gcx, 'tcx> {
// Ideally, we would use `-> impl Iterator` here, but it falls
// afoul of the conservative "capture [restrictions]" we put
// in place, so we use a hand-written iterator.
//
// [restrictions]: https://github.com/rust-lang/rust/issues/34511#issuecomment-373423999
AssociatedItemsIterator {
AssocItemsIterator {
tcx: self,
def_ids: self.associated_item_def_ids(def_id),
next_index: 0,
@ -3104,23 +3104,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}
pub struct AssociatedItemsIterator<'a, 'gcx: 'tcx, 'tcx: 'a> {
pub struct AssocItemsIterator<'a, 'gcx: 'tcx, 'tcx: 'a> {
tcx: TyCtxt<'a, 'gcx, 'tcx>,
def_ids: &'gcx [DefId],
next_index: usize,
}
impl Iterator for AssociatedItemsIterator<'_, '_, '_> {
type Item = AssociatedItem;
impl Iterator for AssocItemsIterator<'_, '_, '_> {
type Item = AssocItem;
fn next(&mut self) -> Option<AssociatedItem> {
fn next(&mut self) -> Option<AssocItem> {
let def_id = self.def_ids.get(self.next_index)?;
self.next_index += 1;
Some(self.tcx.associated_item(*def_id))
}
}
fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem {
fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssocItem {
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
let parent_id = tcx.hir().get_parent_item(id);
let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id);

View File

@ -998,7 +998,7 @@ impl<'a, 'tcx> ProjectionTy<'tcx> {
tcx: TyCtxt<'_, '_, '_>, trait_ref: ty::TraitRef<'tcx>, item_name: Ident
) -> ProjectionTy<'tcx> {
let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| {
item.kind == ty::AssociatedKind::Type &&
item.kind == ty::AssocKind::Type &&
tcx.hygienic_eq(item_name, item.ident, trait_ref.def_id)
}).unwrap().def_id;

View File

@ -473,7 +473,7 @@ impl cstore::CStore {
})
}
pub fn associated_item_cloned_untracked(&self, def: DefId) -> ty::AssociatedItem {
pub fn associated_item_cloned_untracked(&self, def: DefId) -> ty::AssocItem {
self.get_crate_data(def.krate).get_associated_item(def.index)
}
}

View File

@ -401,7 +401,7 @@ impl<'tcx> EntryKind<'tcx> {
fn def_kind(&self) -> Option<DefKind> {
Some(match *self {
EntryKind::Const(..) => DefKind::Const,
EntryKind::AssociatedConst(..) => DefKind::AssociatedConst,
EntryKind::AssocConst(..) => DefKind::AssocConst,
EntryKind::ImmStatic |
EntryKind::MutStatic |
EntryKind::ForeignImmStatic |
@ -415,8 +415,8 @@ impl<'tcx> EntryKind<'tcx> {
EntryKind::TypeParam => DefKind::TyParam,
EntryKind::ConstParam => DefKind::ConstParam,
EntryKind::Existential => DefKind::Existential,
EntryKind::AssociatedType(_) => DefKind::AssociatedTy,
EntryKind::AssociatedExistential(_) => DefKind::AssociatedExistential,
EntryKind::AssocType(_) => DefKind::AssocTy,
EntryKind::AssocExistential(_) => DefKind::AssocExistential,
EntryKind::Mod(_) => DefKind::Mod,
EntryKind::Variant(_) => DefKind::Variant,
EntryKind::Trait(_) => DefKind::Trait,
@ -873,7 +873,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn const_is_rvalue_promotable_to_static(&self, id: DefIndex) -> bool {
match self.entry(id).kind {
EntryKind::AssociatedConst(_, data, _) |
EntryKind::AssocConst(_, data, _) |
EntryKind::Const(data, _) => data.ast_promotable,
_ => bug!(),
}
@ -897,38 +897,38 @@ impl<'a, 'tcx> CrateMetadata {
pub fn mir_const_qualif(&self, id: DefIndex) -> u8 {
match self.entry(id).kind {
EntryKind::Const(qualif, _) |
EntryKind::AssociatedConst(AssociatedContainer::ImplDefault, qualif, _) |
EntryKind::AssociatedConst(AssociatedContainer::ImplFinal, qualif, _) => {
EntryKind::AssocConst(AssocContainer::ImplDefault, qualif, _) |
EntryKind::AssocConst(AssocContainer::ImplFinal, qualif, _) => {
qualif.mir
}
_ => bug!(),
}
}
pub fn get_associated_item(&self, id: DefIndex) -> ty::AssociatedItem {
pub fn get_associated_item(&self, id: DefIndex) -> ty::AssocItem {
let item = self.entry(id);
let def_key = self.def_key(id);
let parent = self.local_def_id(def_key.parent.unwrap());
let name = def_key.disambiguated_data.data.get_opt_name().unwrap();
let (kind, container, has_self) = match item.kind {
EntryKind::AssociatedConst(container, _, _) => {
(ty::AssociatedKind::Const, container, false)
EntryKind::AssocConst(container, _, _) => {
(ty::AssocKind::Const, container, false)
}
EntryKind::Method(data) => {
let data = data.decode(self);
(ty::AssociatedKind::Method, data.container, data.has_self)
(ty::AssocKind::Method, data.container, data.has_self)
}
EntryKind::AssociatedType(container) => {
(ty::AssociatedKind::Type, container, false)
EntryKind::AssocType(container) => {
(ty::AssocKind::Type, container, false)
}
EntryKind::AssociatedExistential(container) => {
(ty::AssociatedKind::Existential, container, false)
EntryKind::AssocExistential(container) => {
(ty::AssocKind::Existential, container, false)
}
_ => bug!("cannot get associated-item of `{:?}`", def_key)
};
ty::AssociatedItem {
ty::AssocItem {
ident: Ident::from_interned_str(name),
kind,
vis: item.visibility.decode(self),
@ -1150,7 +1150,7 @@ impl<'a, 'tcx> CrateMetadata {
pub fn get_rendered_const(&self, id: DefIndex) -> String {
match self.entry(id).kind {
EntryKind::Const(_, data) |
EntryKind::AssociatedConst(_, _, data) => data.decode(self).0,
EntryKind::AssocConst(_, _, data) => data.decode(self).0,
_ => bug!(),
}
}

View File

@ -822,15 +822,15 @@ impl EncodeContext<'_, 'tcx> {
let container = match trait_item.defaultness {
hir::Defaultness::Default { has_value: true } =>
AssociatedContainer::TraitWithDefault,
AssocContainer::TraitWithDefault,
hir::Defaultness::Default { has_value: false } =>
AssociatedContainer::TraitRequired,
AssocContainer::TraitRequired,
hir::Defaultness::Final =>
span_bug!(ast_item.span, "traits cannot have final items"),
};
let kind = match trait_item.kind {
ty::AssociatedKind::Const => {
ty::AssocKind::Const => {
let const_qualif =
if let hir::TraitItemKind::Const(_, Some(body)) = ast_item.node {
self.const_qualif(0, body)
@ -842,9 +842,9 @@ impl EncodeContext<'_, 'tcx> {
hir::print::to_string(self.tcx.hir(), |s| s.print_trait_item(ast_item));
let rendered_const = self.lazy(&RenderedConst(rendered));
EntryKind::AssociatedConst(container, const_qualif, rendered_const)
EntryKind::AssocConst(container, const_qualif, rendered_const)
}
ty::AssociatedKind::Method => {
ty::AssocKind::Method => {
let fn_data = if let hir::TraitItemKind::Method(_, ref m) = ast_item.node {
let arg_names = match *m {
hir::TraitMethod::Required(ref names) => {
@ -868,8 +868,8 @@ impl EncodeContext<'_, 'tcx> {
has_self: trait_item.method_has_self_argument,
}))
}
ty::AssociatedKind::Type => EntryKind::AssociatedType(container),
ty::AssociatedKind::Existential =>
ty::AssocKind::Type => EntryKind::AssocType(container),
ty::AssocKind::Existential =>
span_bug!(ast_item.span, "existential type in trait"),
};
@ -883,21 +883,21 @@ impl EncodeContext<'_, 'tcx> {
deprecation: self.encode_deprecation(def_id),
ty: match trait_item.kind {
ty::AssociatedKind::Const |
ty::AssociatedKind::Method => {
ty::AssocKind::Const |
ty::AssocKind::Method => {
Some(self.encode_item_type(def_id))
}
ty::AssociatedKind::Type => {
ty::AssocKind::Type => {
if trait_item.defaultness.has_value() {
Some(self.encode_item_type(def_id))
} else {
None
}
}
ty::AssociatedKind::Existential => unreachable!(),
ty::AssocKind::Existential => unreachable!(),
},
inherent_impls: LazySeq::empty(),
variances: if trait_item.kind == ty::AssociatedKind::Method {
variances: if trait_item.kind == ty::AssocKind::Method {
self.encode_variances_of(def_id)
} else {
LazySeq::empty()
@ -931,25 +931,25 @@ impl EncodeContext<'_, 'tcx> {
let impl_item = self.tcx.associated_item(def_id);
let container = match impl_item.defaultness {
hir::Defaultness::Default { has_value: true } => AssociatedContainer::ImplDefault,
hir::Defaultness::Final => AssociatedContainer::ImplFinal,
hir::Defaultness::Default { has_value: true } => AssocContainer::ImplDefault,
hir::Defaultness::Final => AssocContainer::ImplFinal,
hir::Defaultness::Default { has_value: false } =>
span_bug!(ast_item.span, "impl items always have values (currently)"),
};
let kind = match impl_item.kind {
ty::AssociatedKind::Const => {
ty::AssocKind::Const => {
if let hir::ImplItemKind::Const(_, body_id) = ast_item.node {
let mir = self.tcx.at(ast_item.span).mir_const_qualif(def_id).0;
EntryKind::AssociatedConst(container,
EntryKind::AssocConst(container,
self.const_qualif(mir, body_id),
self.encode_rendered_const_for_body(body_id))
} else {
bug!()
}
}
ty::AssociatedKind::Method => {
ty::AssocKind::Method => {
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
FnData {
constness: sig.header.constness,
@ -965,8 +965,8 @@ impl EncodeContext<'_, 'tcx> {
has_self: impl_item.method_has_self_argument,
}))
}
ty::AssociatedKind::Existential => EntryKind::AssociatedExistential(container),
ty::AssociatedKind::Type => EntryKind::AssociatedType(container)
ty::AssocKind::Existential => EntryKind::AssocExistential(container),
ty::AssocKind::Type => EntryKind::AssocType(container)
};
let mir =
@ -996,7 +996,7 @@ impl EncodeContext<'_, 'tcx> {
ty: Some(self.encode_item_type(def_id)),
inherent_impls: LazySeq::empty(),
variances: if impl_item.kind == ty::AssociatedKind::Method {
variances: if impl_item.kind == ty::AssocKind::Method {
self.encode_variances_of(def_id)
} else {
LazySeq::empty()

View File

@ -253,13 +253,13 @@ pub enum EntryKind<'tcx> {
Trait(Lazy<TraitData<'tcx>>),
Impl(Lazy<ImplData<'tcx>>),
Method(Lazy<MethodData<'tcx>>),
AssociatedType(AssociatedContainer),
AssociatedExistential(AssociatedContainer),
AssociatedConst(AssociatedContainer, ConstQualif, Lazy<RenderedConst>),
AssocType(AssocContainer),
AssocExistential(AssocContainer),
AssocConst(AssocContainer, ConstQualif, Lazy<RenderedConst>),
TraitAlias(Lazy<TraitAliasData<'tcx>>),
}
/// Additional data for EntryKind::Const and EntryKind::AssociatedConst
/// Additional data for EntryKind::Const and EntryKind::AssocConst
#[derive(Clone, Copy, RustcEncodable, RustcDecodable)]
pub struct ConstQualif {
pub mir: u8,
@ -330,36 +330,36 @@ pub struct ImplData<'tcx> {
/// is a trait or an impl and whether, in a trait, it has
/// a default, or an in impl, whether it's marked "default".
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub enum AssociatedContainer {
pub enum AssocContainer {
TraitRequired,
TraitWithDefault,
ImplDefault,
ImplFinal,
}
impl AssociatedContainer {
pub fn with_def_id(&self, def_id: DefId) -> ty::AssociatedItemContainer {
impl AssocContainer {
pub fn with_def_id(&self, def_id: DefId) -> ty::AssocItemContainer {
match *self {
AssociatedContainer::TraitRequired |
AssociatedContainer::TraitWithDefault => ty::TraitContainer(def_id),
AssocContainer::TraitRequired |
AssocContainer::TraitWithDefault => ty::TraitContainer(def_id),
AssociatedContainer::ImplDefault |
AssociatedContainer::ImplFinal => ty::ImplContainer(def_id),
AssocContainer::ImplDefault |
AssocContainer::ImplFinal => ty::ImplContainer(def_id),
}
}
pub fn defaultness(&self) -> hir::Defaultness {
match *self {
AssociatedContainer::TraitRequired => hir::Defaultness::Default {
AssocContainer::TraitRequired => hir::Defaultness::Default {
has_value: false,
},
AssociatedContainer::TraitWithDefault |
AssociatedContainer::ImplDefault => hir::Defaultness::Default {
AssocContainer::TraitWithDefault |
AssocContainer::ImplDefault => hir::Defaultness::Default {
has_value: true,
},
AssociatedContainer::ImplFinal => hir::Defaultness::Final,
AssocContainer::ImplFinal => hir::Defaultness::Final,
}
}
}
@ -367,7 +367,7 @@ impl AssociatedContainer {
#[derive(RustcEncodable, RustcDecodable)]
pub struct MethodData<'tcx> {
pub fn_data: FnData<'tcx>,
pub container: AssociatedContainer,
pub container: AssocContainer,
pub has_self: bool,
}

View File

@ -667,7 +667,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
// note that validation may still cause a hard error on this very same constant,
// because any code that existed before validation could not have failed validation
// thus preventing such a hard error from being a backwards compatibility hazard
Some(DefKind::Const) | Some(DefKind::AssociatedConst) => {
Some(DefKind::Const) | Some(DefKind::AssocConst) => {
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
err.report_as_lint(
tcx.at(tcx.def_span(def_id)),

View File

@ -787,7 +787,7 @@ fn user_substs_applied_to_res(
Res::Def(DefKind::Method, _) |
Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) |
Res::Def(DefKind::Const, _) |
Res::Def(DefKind::AssociatedConst, _) =>
Res::Def(DefKind::AssocConst, _) =>
cx.tables().user_provided_types().get(hir_id).map(|u_ty| *u_ty),
// A unit struct/variant which is used as a value (e.g.,
@ -924,7 +924,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
}
Res::Def(DefKind::Const, def_id) |
Res::Def(DefKind::AssociatedConst, def_id) => {
Res::Def(DefKind::AssocConst, def_id) => {
let user_ty = user_substs_applied_to_res(cx, expr.hir_id, res);
debug!("convert_path_expr: (const) user_ty={:?}", user_ty);
ExprKind::Literal {

View File

@ -170,7 +170,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
let method_name = Symbol::intern(method_name);
let substs = self.tcx.mk_substs_trait(self_ty, params);
for item in self.tcx.associated_items(trait_def_id) {
if item.kind == ty::AssociatedKind::Method && item.ident.name == method_name {
if item.kind == ty::AssocKind::Method && item.ident.name == method_name {
let method_ty = self.tcx.type_of(item.def_id);
let method_ty = method_ty.subst(self.tcx, substs);
return (method_ty, ty::Const::zero_sized(self.tcx, method_ty));

View File

@ -102,7 +102,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
PatternError::StaticInPattern(span) => {
self.span_e0158(span, "statics cannot be referenced in patterns")
}
PatternError::AssociatedConstInPattern(span) => {
PatternError::AssocConstInPattern(span) => {
self.span_e0158(span, "associated consts cannot be referenced in patterns")
}
PatternError::FloatBug => {

View File

@ -32,7 +32,7 @@ use syntax_pos::Span;
#[derive(Clone, Debug)]
pub enum PatternError {
AssociatedConstInPattern(Span),
AssocConstInPattern(Span),
StaticInPattern(Span),
FloatBug,
NonConstPath(Span),
@ -769,7 +769,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
| Res::Def(DefKind::Ctor(CtorOf::Struct, ..), _)
| Res::Def(DefKind::Union, _)
| Res::Def(DefKind::TyAlias, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocTy, _)
| Res::SelfTy(..)
| Res::SelfCtor(..) => {
PatternKind::Leaf { subpatterns }
@ -811,11 +811,11 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
let ty = self.tables.node_type(id);
let res = self.tables.qpath_res(qpath, id);
let is_associated_const = match res {
Res::Def(DefKind::AssociatedConst, _) => true,
Res::Def(DefKind::AssocConst, _) => true,
_ => false,
};
let kind = match res {
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssociatedConst, def_id) => {
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
let substs = self.tables.node_substs(id);
match ty::Instance::resolve(
self.tcx,
@ -869,7 +869,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
},
None => {
self.errors.push(if is_associated_const {
PatternError::AssociatedConstInPattern(span)
PatternError::AssocConstInPattern(span)
} else {
PatternError::StaticInPattern(span)
});

View File

@ -513,7 +513,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tc
// statics and constants don't have `Storage*` statements, no need to look for them
Some(DefKind::Static)
| Some(DefKind::Const)
| Some(DefKind::AssociatedConst) => {},
| Some(DefKind::AssocConst) => {},
_ => {
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
for block in mir.basic_blocks() {

View File

@ -4,7 +4,7 @@ use rustc::hir::intravisit::FnKind;
use rustc::hir::map::blocks::FnLikeNode;
use rustc::lint::builtin::UNCONDITIONAL_RECURSION;
use rustc::mir::{self, Mir, TerminatorKind};
use rustc::ty::{self, AssociatedItem, AssociatedItemContainer, Instance, TyCtxt};
use rustc::ty::{self, AssocItem, AssocItemContainer, Instance, TyCtxt};
use rustc::ty::subst::InternalSubsts;
pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
@ -63,8 +63,8 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let param_env = tcx.param_env(def_id);
let trait_substs_count =
match tcx.opt_associated_item(def_id) {
Some(AssociatedItem {
container: AssociatedItemContainer::TraitContainer(trait_def_id),
Some(AssocItem {
container: AssocItemContainer::TraitContainer(trait_def_id),
..
}) => tcx.generics_of(trait_def_id).count(),
_ => 0

View File

@ -65,7 +65,7 @@ fn fn_once_adapter_instance<'a, 'tcx>(
substs);
let fn_once = tcx.lang_items().fn_once_trait().unwrap();
let call_once = tcx.associated_items(fn_once)
.find(|it| it.kind == ty::AssociatedKind::Method)
.find(|it| it.kind == ty::AssocKind::Method)
.unwrap().def_id;
let def = ty::InstanceDef::ClosureOnceShim { call_once };

View File

@ -84,7 +84,7 @@ fn make_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let fn_mut = tcx.lang_items().fn_mut_trait().unwrap();
let call_mut = tcx.global_tcx()
.associated_items(fn_mut)
.find(|it| it.kind == ty::AssociatedKind::Method)
.find(|it| it.kind == ty::AssocKind::Method)
.unwrap().def_id;
build_call_shim(

View File

@ -45,7 +45,7 @@ impl MirPass for ConstProp {
let is_fn_like = FnLikeNode::from_node(tcx.hir().get_by_hir_id(hir_id)).is_some();
let is_assoc_const = match tcx.def_kind(source.def_id()) {
Some(DefKind::AssociatedConst) => true,
Some(DefKind::AssocConst) => true,
_ => false,
};

View File

@ -588,7 +588,7 @@ fn write_mir_sig(
match (kind, src.promoted) {
(_, Some(i)) => write!(w, "{:?} in ", i)?,
(Some(DefKind::Const), _)
| (Some(DefKind::AssociatedConst), _) => write!(w, "const ")?,
| (Some(DefKind::AssocConst), _) => write!(w, "const ")?,
(Some(DefKind::Static), _) =>
write!(w, "static {}", if tcx.is_mutable_static(src.def_id()) { "mut " } else { "" })?,
(_, _) if is_function => write!(w, "fn ")?,

View File

@ -351,7 +351,7 @@ fn check_expr_kind<'a, 'tcx>(
}
Res::Def(DefKind::Const, did) |
Res::Def(DefKind::AssociatedConst, did) => {
Res::Def(DefKind::AssocConst, did) => {
let promotable = if v.tcx.trait_of_item(did).is_some() {
// Don't peek inside trait associated constants.
NotPromotable

View File

@ -11,7 +11,7 @@
#[macro_use] extern crate syntax;
use rustc::bug;
use rustc::hir::{self, Node, PatKind, AssociatedItemKind};
use rustc::hir::{self, Node, PatKind, AssocItemKind};
use rustc::hir::def::{Res, DefKind};
use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, CrateNum, DefId};
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
@ -624,7 +624,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
let mut reach = self.reach(trait_item_ref.id.hir_id, item_level);
reach.generics().predicates();
if trait_item_ref.kind == AssociatedItemKind::Type &&
if trait_item_ref.kind == AssocItemKind::Type &&
!trait_item_ref.defaultness.has_value() {
// No type to visit.
} else {
@ -1112,9 +1112,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
let def = def.filter(|(kind, _)| {
match kind {
DefKind::Method
| DefKind::AssociatedConst
| DefKind::AssociatedTy
| DefKind::AssociatedExistential
| DefKind::AssocConst
| DefKind::AssocTy
| DefKind::AssocExistential
| DefKind::Static => true,
_ => false,
}
@ -1448,11 +1448,11 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
if self.item_is_public(&impl_item_ref.id.hir_id, &impl_item_ref.vis) {
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
match impl_item_ref.kind {
AssociatedItemKind::Const => {
AssocItemKind::Const => {
found_pub_static = true;
intravisit::walk_impl_item(self, impl_item);
}
AssociatedItemKind::Method { has_self: false } => {
AssocItemKind::Method { has_self: false } => {
found_pub_static = true;
intravisit::walk_impl_item(self, impl_item);
}
@ -1703,16 +1703,16 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
}
}
fn check_trait_or_impl_item(&self, hir_id: hir::HirId, assoc_item_kind: AssociatedItemKind,
fn check_trait_or_impl_item(&self, hir_id: hir::HirId, assoc_item_kind: AssocItemKind,
defaultness: hir::Defaultness, vis: ty::Visibility) {
let mut check = self.check(hir_id, vis);
let (check_ty, is_assoc_ty) = match assoc_item_kind {
AssociatedItemKind::Const | AssociatedItemKind::Method { .. } => (true, false),
AssociatedItemKind::Type => (defaultness.has_value(), true),
AssocItemKind::Const | AssocItemKind::Method { .. } => (true, false),
AssocItemKind::Type => (defaultness.has_value(), true),
// `ty()` for existential types is the underlying type,
// it's not a part of interface, so we skip it.
AssociatedItemKind::Existential => (false, true),
AssocItemKind::Existential => (false, true),
};
check.in_assoc_ty = is_assoc_ty;
check.generics().predicates();

View File

@ -705,7 +705,7 @@ impl<'a> Resolver<'a> {
for child in self.cstore.item_children_untracked(def_id, self.session) {
let res = child.res.map_id(|_| panic!("unexpected id"));
let ns = if let Res::Def(DefKind::AssociatedTy, _) = res {
let ns = if let Res::Def(DefKind::AssocTy, _) = res {
TypeNS
} else { ValueNS };
self.define(module, child.ident, ns,
@ -1033,14 +1033,14 @@ impl<'a, 'b> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b> {
// Add the item to the trait info.
let item_def_id = self.resolver.definitions.local_def_id(item.id);
let (res, ns) = match item.node {
TraitItemKind::Const(..) => (Res::Def(DefKind::AssociatedConst, item_def_id), ValueNS),
TraitItemKind::Const(..) => (Res::Def(DefKind::AssocConst, item_def_id), ValueNS),
TraitItemKind::Method(ref sig, _) => {
if sig.decl.has_self() {
self.resolver.has_self.insert(item_def_id);
}
(Res::Def(DefKind::Method, item_def_id), ValueNS)
}
TraitItemKind::Type(..) => (Res::Def(DefKind::AssociatedTy, item_def_id), TypeNS),
TraitItemKind::Type(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS),
TraitItemKind::Macro(_) => bug!(), // handled above
};

View File

@ -432,7 +432,7 @@ impl<'a> Resolver<'a> {
err.note("can't use `Self` as a constructor, you must use the implemented struct");
}
(Res::Def(DefKind::TyAlias, _), _)
| (Res::Def(DefKind::AssociatedTy, _), _) if ns == ValueNS => {
| (Res::Def(DefKind::AssocTy, _), _) if ns == ValueNS => {
err.note("can't use a type alias as a constructor");
}
_ => return false,

View File

@ -589,7 +589,7 @@ impl<'a> PathSource<'a> {
| Res::Def(DefKind::Trait, _)
| Res::Def(DefKind::TraitAlias, _)
| Res::Def(DefKind::TyAlias, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocTy, _)
| Res::PrimTy(..)
| Res::Def(DefKind::TyParam, _)
| Res::SelfTy(..)
@ -615,14 +615,14 @@ impl<'a> PathSource<'a> {
| Res::Upvar(..)
| Res::Def(DefKind::Fn, _)
| Res::Def(DefKind::Method, _)
| Res::Def(DefKind::AssociatedConst, _)
| Res::Def(DefKind::AssocConst, _)
| Res::SelfCtor(..)
| Res::Def(DefKind::ConstParam, _) => true,
_ => false,
},
PathSource::Pat => match res {
Res::Def(DefKind::Ctor(_, CtorKind::Const), _) |
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssociatedConst, _) |
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) |
Res::SelfCtor(..) => true,
_ => false,
},
@ -635,14 +635,14 @@ impl<'a> PathSource<'a> {
| Res::Def(DefKind::Union, _)
| Res::Def(DefKind::Variant, _)
| Res::Def(DefKind::TyAlias, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocTy, _)
| Res::SelfTy(..) => true,
_ => false,
},
PathSource::TraitItem(ns) => match res {
Res::Def(DefKind::AssociatedConst, _)
Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::Method, _) if ns == ValueNS => true,
Res::Def(DefKind::AssociatedTy, _) if ns == TypeNS => true,
Res::Def(DefKind::AssocTy, _) if ns == TypeNS => true,
_ => false,
},
PathSource::Visibility => match res {
@ -1511,9 +1511,9 @@ impl<'a> NameBinding<'a> {
fn is_importable(&self) -> bool {
match self.res() {
Res::Def(DefKind::AssociatedConst, _)
Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::Method, _)
| Res::Def(DefKind::AssociatedTy, _) => false,
| Res::Def(DefKind::AssocTy, _) => false,
_ => true,
}
}

View File

@ -961,11 +961,11 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
}
Res::Def(HirDefKind::Ctor(..), _) |
Res::Def(HirDefKind::Const, _) |
Res::Def(HirDefKind::AssociatedConst, _) |
Res::Def(HirDefKind::AssocConst, _) |
Res::Def(HirDefKind::Struct, _) |
Res::Def(HirDefKind::Variant, _) |
Res::Def(HirDefKind::TyAlias, _) |
Res::Def(HirDefKind::AssociatedTy, _) |
Res::Def(HirDefKind::AssocTy, _) |
Res::SelfTy(..) => {
self.dump_path_ref(id, &ast::Path::from_ident(ident));
}

View File

@ -723,8 +723,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
Res::Def(HirDefKind::TyAlias, def_id) |
Res::Def(HirDefKind::ForeignTy, def_id) |
Res::Def(HirDefKind::TraitAlias, def_id) |
Res::Def(HirDefKind::AssociatedExistential, def_id) |
Res::Def(HirDefKind::AssociatedTy, def_id) |
Res::Def(HirDefKind::AssocExistential, def_id) |
Res::Def(HirDefKind::AssocTy, def_id) |
Res::Def(HirDefKind::Trait, def_id) |
Res::Def(HirDefKind::Existential, def_id) |
Res::Def(HirDefKind::TyParam, def_id) => {
@ -754,7 +754,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
}
Res::Def(HirDefKind::Static, _) |
Res::Def(HirDefKind::Const, _) |
Res::Def(HirDefKind::AssociatedConst, _) |
Res::Def(HirDefKind::AssocConst, _) |
Res::Def(HirDefKind::Ctor(..), _) => {
Some(Ref {
kind: RefKind::Variable,

View File

@ -586,7 +586,7 @@ impl Sig for ast::Path {
refs: vec![],
})
}
Res::Def(DefKind::AssociatedConst, _)
Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::Variant, _)
| Res::Def(DefKind::Ctor(..), _) => {
let len = self.segments.len();

View File

@ -166,10 +166,10 @@ crate fn program_clauses_for<'a, 'tcx>(
| Some(DefKind::TraitAlias) => program_clauses_for_trait(tcx, def_id),
// FIXME(eddyb) deduplicate this `associated_item` call with
// `program_clauses_for_associated_type_{value,def}`.
Some(DefKind::AssociatedTy) => match tcx.associated_item(def_id).container {
ty::AssociatedItemContainer::ImplContainer(_) =>
Some(DefKind::AssocTy) => match tcx.associated_item(def_id).container {
ty::AssocItemContainer::ImplContainer(_) =>
program_clauses_for_associated_type_value(tcx, def_id),
ty::AssociatedItemContainer::TraitContainer(_) =>
ty::AssocItemContainer::TraitContainer(_) =>
program_clauses_for_associated_type_def(tcx, def_id)
},
Some(DefKind::Struct)
@ -444,9 +444,9 @@ pub fn program_clauses_for_associated_type_def<'a, 'tcx>(
// ```
let item = tcx.associated_item(item_id);
debug_assert_eq!(item.kind, ty::AssociatedKind::Type);
debug_assert_eq!(item.kind, ty::AssocKind::Type);
let trait_id = match item.container {
ty::AssociatedItemContainer::TraitContainer(trait_id) => trait_id,
ty::AssocItemContainer::TraitContainer(trait_id) => trait_id,
_ => bug!("not an trait container"),
};
@ -582,9 +582,9 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
// ```
let item = tcx.associated_item(item_id);
debug_assert_eq!(item.kind, ty::AssociatedKind::Type);
debug_assert_eq!(item.kind, ty::AssocKind::Type);
let impl_id = match item.container {
ty::AssociatedItemContainer::ImplContainer(impl_id) => impl_id,
ty::AssocItemContainer::ImplContainer(impl_id) => impl_id,
_ => bug!("not an impl container"),
};

View File

@ -823,7 +823,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
-> bool
{
self.tcx().associated_items(trait_def_id).any(|item| {
item.kind == ty::AssociatedKind::Type &&
item.kind == ty::AssocKind::Type &&
self.tcx().hygienic_eq(assoc_name, item.ident, trait_def_id)
})
}
@ -905,7 +905,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
let (assoc_ident, def_scope) =
tcx.adjust_ident(binding.item_name, candidate.def_id(), hir_ref_id);
let assoc_ty = tcx.associated_items(candidate.def_id()).find(|i| {
i.kind == ty::AssociatedKind::Type && i.ident.modern() == assoc_ident
i.kind == ty::AssocKind::Type && i.ident.modern() == assoc_ident
}).expect("missing associated type");
if !assoc_ty.vis.is_accessible_from(def_scope, tcx) {
@ -1045,7 +1045,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
ty::Predicate::Trait(pred) => {
associated_types
.extend(tcx.associated_items(pred.def_id())
.filter(|item| item.kind == ty::AssociatedKind::Type)
.filter(|item| item.kind == ty::AssocKind::Type)
.map(|item| item.def_id));
}
ty::Predicate::Projection(pred) => {
@ -1300,7 +1300,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
for bound in bounds {
let bound_span = self.tcx().associated_items(bound.def_id()).find(|item| {
item.kind == ty::AssociatedKind::Type &&
item.kind == ty::AssocKind::Type &&
self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id())
})
.and_then(|item| self.tcx().hir().span_if_local(item.def_id));
@ -1442,7 +1442,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
let ty = self.projected_ty_from_poly_trait_ref(span, item.def_id, bound);
let ty = self.normalize_ty(span, ty);
let kind = DefKind::AssociatedTy;
let kind = DefKind::AssocTy;
if !item.vis.is_accessible_from(def_scope, tcx) {
let msg = format!("{} `{}` is private", kind.descr(), assoc_ident);
tcx.sess.span_err(span, &msg);
@ -1685,7 +1685,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
// Case 4. Reference to a method or associated const.
DefKind::Method
| DefKind::AssociatedConst => {
| DefKind::AssocConst => {
if segments.len() >= 2 {
let generics = tcx.generics_of(def_id);
path_segs.push(PathSeg(generics.parent.unwrap(), last - 1));
@ -1779,7 +1779,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
self.prohibit_generics(&path.segments);
tcx.mk_self_type()
}
Res::Def(DefKind::AssociatedTy, def_id) => {
Res::Def(DefKind::AssocTy, def_id) => {
debug_assert!(path.segments.len() >= 2);
self.prohibit_generics(&path.segments[..path.segments.len() - 2]);
self.qpath_to_ty(span,

View File

@ -67,7 +67,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
PatKind::Path(ref qpath) => {
let (def, _, _) = self.resolve_ty_and_res_ufcs(qpath, pat.hir_id, pat.span);
match def {
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssociatedConst, _) => false,
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => false,
_ => true,
}
}
@ -1050,7 +1050,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
return tcx.types.err;
}
Res::Def(DefKind::Ctor(_, CtorKind::Const), _) | Res::SelfCtor(..) |
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssociatedConst, _) => {} // OK
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {} // OK
_ => bug!("unexpected pattern resolution: {:?}", res)
}
@ -1107,7 +1107,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
on_error();
return tcx.types.err;
}
Res::Def(DefKind::AssociatedConst, _) | Res::Def(DefKind::Method, _) => {
Res::Def(DefKind::AssocConst, _) | Res::Def(DefKind::Method, _) => {
report_unexpected_res(res);
return tcx.types.err;
}

View File

@ -24,9 +24,9 @@ use super::{Inherited, FnCtxt, potentially_plural_count};
/// - `impl_trait_ref`: the TraitRef corresponding to the trait implementation
pub fn compare_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m: &ty::AssociatedItem,
impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssociatedItem,
trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>,
trait_item_span: Option<Span>) {
debug!("compare_impl_method(impl_trait_ref={:?})",
@ -74,9 +74,9 @@ pub fn compare_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m: &ty::AssociatedItem,
impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssociatedItem,
trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>)
-> Result<(), ErrorReported> {
let trait_to_impl_substs = impl_trait_ref.substs;
@ -357,8 +357,8 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
span: Span,
impl_m: &ty::AssociatedItem,
trait_m: &ty::AssociatedItem,
impl_m: &ty::AssocItem,
trait_m: &ty::AssocItem,
trait_generics: &ty::Generics,
impl_generics: &ty::Generics,
trait_to_skol_substs: SubstsRef<'tcx>)
@ -410,9 +410,9 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
param_env: ty::ParamEnv<'tcx>,
terr: &TypeError<'_>,
cause: &ObligationCause<'tcx>,
impl_m: &ty::AssociatedItem,
impl_m: &ty::AssocItem,
impl_sig: ty::FnSig<'tcx>,
trait_m: &ty::AssociatedItem,
trait_m: &ty::AssocItem,
trait_sig: ty::FnSig<'tcx>)
-> (Span, Option<Span>) {
let tcx = infcx.tcx;
@ -496,9 +496,9 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a
}
fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m: &ty::AssociatedItem,
impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssociatedItem,
trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>)
-> Result<(), ErrorReported>
{
@ -510,7 +510,7 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// inscrutable, particularly for cases where one method has no
// self.
let self_string = |method: &ty::AssociatedItem| {
let self_string = |method: &ty::AssocItem| {
let untransformed_self_ty = match method.container {
ty::ImplContainer(_) => impl_trait_ref.self_ty(),
ty::TraitContainer(_) => tcx.mk_self_type()
@ -582,9 +582,9 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn compare_number_of_generics<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_: &ty::AssociatedItem,
impl_: &ty::AssocItem,
impl_span: Span,
trait_: &ty::AssociatedItem,
trait_: &ty::AssocItem,
trait_span: Option<Span>,
) -> Result<(), ErrorReported> {
let trait_own_counts = tcx.generics_of(trait_.def_id).own_counts();
@ -655,9 +655,9 @@ fn compare_number_of_generics<'a, 'tcx>(
}
fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m: &ty::AssociatedItem,
impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssociatedItem,
trait_m: &ty::AssocItem,
trait_item_span: Option<Span>)
-> Result<(), ErrorReported> {
let impl_m_fty = tcx.fn_sig(impl_m.def_id);
@ -739,8 +739,8 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m: &ty::AssociatedItem,
trait_m: &ty::AssociatedItem)
impl_m: &ty::AssocItem,
trait_m: &ty::AssocItem)
-> Result<(), ErrorReported> {
// FIXME(chrisvittal) Clean up this function, list of FIXME items:
// 1. Better messages for the span labels
@ -911,9 +911,9 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_c: &ty::AssociatedItem,
impl_c: &ty::AssocItem,
impl_c_span: Span,
trait_c: &ty::AssociatedItem,
trait_c: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>) {
debug!("compare_const_impl(impl_trait_ref={:?})", impl_trait_ref);

View File

@ -8,7 +8,7 @@ use syntax_pos::Span;
use rustc::hir;
use rustc::hir::Node;
use rustc::hir::{print, lowering::is_range_literal};
use rustc::ty::{self, Ty, AssociatedItem};
use rustc::ty::{self, Ty, AssocItem};
use rustc::ty::adjustment::AllowTwoPhase;
use errors::{Applicability, DiagnosticBuilder};
@ -179,7 +179,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
pub fn get_conversion_methods(&self, span: Span, expected: Ty<'tcx>, checked_ty: Ty<'tcx>)
-> Vec<AssociatedItem> {
-> Vec<AssocItem> {
let mut methods = self.probe_for_return_type(span,
probe::Mode::MethodCall,
expected,
@ -205,9 +205,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
// This function checks if the method isn't static and takes other arguments than `self`.
fn has_no_input_arg(&self, method: &AssociatedItem) -> bool {
fn has_no_input_arg(&self, method: &AssocItem) -> bool {
match method.kind {
ty::AssociatedKind::Method => {
ty::AssocKind::Method => {
self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1
}
_ => false,

View File

@ -71,7 +71,7 @@ pub struct NoMatchData<'tcx> {
pub static_candidates: Vec<CandidateSource>,
pub unsatisfied_predicates: Vec<TraitRef<'tcx>>,
pub out_of_scope_traits: Vec<DefId>,
pub lev_candidate: Option<ty::AssociatedItem>,
pub lev_candidate: Option<ty::AssocItem>,
pub mode: probe::Mode,
}
@ -79,7 +79,7 @@ impl<'tcx> NoMatchData<'tcx> {
pub fn new(static_candidates: Vec<CandidateSource>,
unsatisfied_predicates: Vec<TraitRef<'tcx>>,
out_of_scope_traits: Vec<DefId>,
lev_candidate: Option<ty::AssociatedItem>,
lev_candidate: Option<ty::AssocItem>,
mode: probe::Mode)
-> Self {
NoMatchData {
@ -450,7 +450,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// Finds item with name `item_name` defined in impl/trait `def_id`
/// and return it, or `None`, if no such item was defined there.
pub fn associated_item(&self, def_id: DefId, item_name: ast::Ident, ns: Namespace)
-> Option<ty::AssociatedItem> {
-> Option<ty::AssocItem> {
self.tcx.associated_items(def_id).find(|item| {
Namespace::from(item.kind) == ns &&
self.tcx.hygienic_eq(item_name, item.ident, def_id)

View File

@ -89,7 +89,7 @@ impl<'a, 'gcx, 'tcx> Deref for ProbeContext<'a, 'gcx, 'tcx> {
#[derive(Debug)]
struct Candidate<'tcx> {
// Candidates are (I'm not quite sure, but they are mostly) basically
// some metadata on top of a `ty::AssociatedItem` (without substs).
// some metadata on top of a `ty::AssocItem` (without substs).
//
// However, method probing wants to be able to evaluate the predicates
// for a function with the substs applied - for example, if a function
@ -121,7 +121,7 @@ struct Candidate<'tcx> {
// if `T: Sized`.
xform_self_ty: Ty<'tcx>,
xform_ret_ty: Option<Ty<'tcx>>,
item: ty::AssociatedItem,
item: ty::AssocItem,
kind: CandidateKind<'tcx>,
import_ids: SmallVec<[hir::HirId; 1]>,
}
@ -146,7 +146,7 @@ enum ProbeResult {
#[derive(Debug, PartialEq, Clone)]
pub struct Pick<'tcx> {
pub item: ty::AssociatedItem,
pub item: ty::AssocItem,
pub kind: PickKind<'tcx>,
pub import_ids: SmallVec<[hir::HirId; 1]>,
@ -213,7 +213,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
return_type: Ty<'tcx>,
self_ty: Ty<'tcx>,
scope_expr_id: hir::HirId)
-> Vec<ty::AssociatedItem> {
-> Vec<ty::AssocItem> {
debug!("probe(self_ty={:?}, return_type={}, scope_expr_id={})",
self_ty,
return_type,
@ -812,7 +812,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
mut mk_cand: F)
where F: for<'b> FnMut(&mut ProbeContext<'b, 'gcx, 'tcx>,
ty::PolyTraitRef<'tcx>,
ty::AssociatedItem)
ty::AssocItem)
{
let tcx = self.tcx;
for bound_trait_ref in traits::transitive_bounds(tcx, bounds) {
@ -861,11 +861,11 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
}
pub fn matches_return_type(&self,
method: &ty::AssociatedItem,
method: &ty::AssocItem,
self_ty: Option<Ty<'tcx>>,
expected: Ty<'tcx>) -> bool {
match method.kind {
ty::AssociatedKind::Method => {
ty::AssocKind::Method => {
let fty = self.tcx.fn_sig(method.def_id);
self.probe(|_| {
let substs = self.fresh_substs_for_item(self.span, method.def_id);
@ -1425,7 +1425,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
/// Similarly to `probe_for_return_type`, this method attempts to find the best matching
/// candidate method where the method name may have been misspelt. Similarly to other
/// Levenshtein based suggestions, we provide at most one such suggestion.
fn probe_for_lev_candidate(&mut self) -> Result<Option<ty::AssociatedItem>, MethodError<'tcx>> {
fn probe_for_lev_candidate(&mut self) -> Result<Option<ty::AssocItem>, MethodError<'tcx>> {
debug!("Probing for method names similar to {:?}",
self.method_name);
@ -1441,7 +1441,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
let method_names = pcx.candidate_method_names();
pcx.allow_similar_names = false;
let applicable_close_candidates: Vec<ty::AssociatedItem> = method_names
let applicable_close_candidates: Vec<ty::AssocItem> = method_names
.iter()
.filter_map(|&method_name| {
pcx.reset();
@ -1474,7 +1474,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
///////////////////////////////////////////////////////////////////////////
// MISCELLANY
fn has_applicable_self(&self, item: &ty::AssociatedItem) -> bool {
fn has_applicable_self(&self, item: &ty::AssocItem) -> bool {
// "Fast track" -- check for usage of sugar when in method call
// mode.
//
@ -1483,9 +1483,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
match self.mode {
Mode::MethodCall => item.method_has_self_argument,
Mode::Path => match item.kind {
ty::AssociatedKind::Existential |
ty::AssociatedKind::Type => false,
ty::AssociatedKind::Method | ty::AssociatedKind::Const => true
ty::AssocKind::Existential |
ty::AssocKind::Type => false,
ty::AssocKind::Method | ty::AssocKind::Const => true
},
}
// FIXME -- check for types that deref to `Self`,
@ -1501,11 +1501,11 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
}
fn xform_self_ty(&self,
item: &ty::AssociatedItem,
item: &ty::AssocItem,
impl_ty: Ty<'tcx>,
substs: SubstsRef<'tcx>)
-> (Ty<'tcx>, Option<Ty<'tcx>>) {
if item.kind == ty::AssociatedKind::Method && self.mode == Mode::MethodCall {
if item.kind == ty::AssocKind::Method && self.mode == Mode::MethodCall {
let sig = self.xform_method_sig(item.def_id, substs);
(sig.inputs()[0], Some(sig.output()))
} else {
@ -1610,7 +1610,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
/// Finds the method with the appropriate name (or return type, as the case may be). If
/// `allow_similar_names` is set, find methods with close-matching names.
fn impl_or_trait_item(&self, def_id: DefId) -> Vec<ty::AssociatedItem> {
fn impl_or_trait_item(&self, def_id: DefId) -> Vec<ty::AssocItem> {
if let Some(name) = self.method_name {
if self.allow_similar_names {
let max_dist = max(name.as_str().len(), 3) / 3;

View File

@ -1499,17 +1499,17 @@ fn report_forbidden_specialization<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
fn check_specialization_validity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
trait_def: &ty::TraitDef,
trait_item: &ty::AssociatedItem,
trait_item: &ty::AssocItem,
impl_id: DefId,
impl_item: &hir::ImplItem)
{
let ancestors = trait_def.ancestors(tcx, impl_id);
let kind = match impl_item.node {
hir::ImplItemKind::Const(..) => ty::AssociatedKind::Const,
hir::ImplItemKind::Method(..) => ty::AssociatedKind::Method,
hir::ImplItemKind::Existential(..) => ty::AssociatedKind::Existential,
hir::ImplItemKind::Type(_) => ty::AssociatedKind::Type
hir::ImplItemKind::Const(..) => ty::AssocKind::Const,
hir::ImplItemKind::Method(..) => ty::AssocKind::Method,
hir::ImplItemKind::Existential(..) => ty::AssocKind::Existential,
hir::ImplItemKind::Type(_) => ty::AssocKind::Type
};
let parent = ancestors.defs(tcx, trait_item.ident, kind, trait_def.def_id).nth(1)
@ -1560,7 +1560,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
match impl_item.node {
hir::ImplItemKind::Const(..) => {
// Find associated const definition.
if ty_trait_item.kind == ty::AssociatedKind::Const {
if ty_trait_item.kind == ty::AssocKind::Const {
compare_const_impl(tcx,
&ty_impl_item,
impl_item.span,
@ -1583,7 +1583,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
hir::ImplItemKind::Method(..) => {
let trait_span = tcx.hir().span_if_local(ty_trait_item.def_id);
if ty_trait_item.kind == ty::AssociatedKind::Method {
if ty_trait_item.kind == ty::AssocKind::Method {
compare_impl_method(tcx,
&ty_impl_item,
impl_item.span,
@ -1605,7 +1605,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
hir::ImplItemKind::Existential(..) |
hir::ImplItemKind::Type(_) => {
if ty_trait_item.kind == ty::AssociatedKind::Type {
if ty_trait_item.kind == ty::AssocKind::Type {
if ty_trait_item.defaultness.has_value() {
overridden_associated_type = Some(impl_item);
}
@ -3746,7 +3746,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Res::Def(DefKind::Struct, _)
| Res::Def(DefKind::Union, _)
| Res::Def(DefKind::TyAlias, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocTy, _)
| Res::SelfTy(..) => {
match ty.sty {
ty::Adt(adt, substs) if !adt.is_enum() => {
@ -5279,7 +5279,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
}
Res::Def(DefKind::Method, def_id)
| Res::Def(DefKind::AssociatedConst, def_id) => {
| Res::Def(DefKind::AssocConst, def_id) => {
let container = tcx.associated_item(def_id).container;
debug!("instantiate_value_path: def_id={:?} container={:?}", def_id, container);
match container {

View File

@ -190,12 +190,12 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
};
match item.kind {
ty::AssociatedKind::Const => {
ty::AssocKind::Const => {
let ty = fcx.tcx.type_of(item.def_id);
let ty = fcx.normalize_associated_types_in(span, &ty);
fcx.register_wf_obligation(ty, span, code.clone());
}
ty::AssociatedKind::Method => {
ty::AssocKind::Method => {
reject_shadowing_parameters(fcx.tcx, item.def_id);
let sig = fcx.tcx.fn_sig(item.def_id);
let sig = fcx.normalize_associated_types_in(span, &sig);
@ -204,14 +204,14 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let sig_if_method = sig_if_method.expect("bad signature for method");
check_method_receiver(fcx, sig_if_method, &item, self_ty);
}
ty::AssociatedKind::Type => {
ty::AssocKind::Type => {
if item.defaultness.has_value() {
let ty = fcx.tcx.type_of(item.def_id);
let ty = fcx.normalize_associated_types_in(span, &ty);
fcx.register_wf_obligation(ty, span, code.clone());
}
}
ty::AssociatedKind::Existential => {
ty::AssocKind::Existential => {
// do nothing, existential types check themselves
}
}
@ -748,7 +748,7 @@ fn check_existential_types<'a, 'fcx, 'gcx, 'tcx>(
fn check_method_receiver<'fcx, 'gcx, 'tcx>(fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
method_sig: &hir::MethodSig,
method: &ty::AssociatedItem,
method: &ty::AssocItem,
self_ty: Ty<'tcx>)
{
// check that the method has a valid receiver type, given the type `Self`

View File

@ -111,7 +111,7 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
.map(|item_ref| tcx.hir().local_def_id_from_hir_id(item_ref.id.hir_id))
.filter(|&def_id| {
let item = tcx.associated_item(def_id);
item.kind == ty::AssociatedKind::Type && item.defaultness.has_value()
item.kind == ty::AssocKind::Type && item.defaultness.has_value()
})
.flat_map(|def_id| {
cgp::parameters_for(&tcx.type_of(def_id), true)

View File

@ -8,13 +8,13 @@ pub enum Namespace {
Value,
}
impl From<ty::AssociatedKind> for Namespace {
fn from(a_kind: ty::AssociatedKind) -> Self {
impl From<ty::AssocKind> for Namespace {
fn from(a_kind: ty::AssocKind) -> Self {
match a_kind {
ty::AssociatedKind::Existential |
ty::AssociatedKind::Type => Namespace::Type,
ty::AssociatedKind::Const |
ty::AssociatedKind::Method => Namespace::Value,
ty::AssocKind::Existential |
ty::AssocKind::Type => Namespace::Type,
ty::AssocKind::Const |
ty::AssocKind::Method => Namespace::Value,
}
}
}

View File

@ -428,10 +428,10 @@ impl Item {
self.type_() == ItemType::Variant
}
pub fn is_associated_type(&self) -> bool {
self.type_() == ItemType::AssociatedType
self.type_() == ItemType::AssocType
}
pub fn is_associated_const(&self) -> bool {
self.type_() == ItemType::AssociatedConst
self.type_() == ItemType::AssocConst
}
pub fn is_method(&self) -> bool {
self.type_() == ItemType::Method
@ -560,8 +560,8 @@ pub enum ItemEnum {
MacroItem(Macro),
ProcMacroItem(ProcMacro),
PrimitiveItem(PrimitiveType),
AssociatedConstItem(Type, Option<String>),
AssociatedTypeItem(Vec<GenericBound>, Option<Type>),
AssocConstItem(Type, Option<String>),
AssocTypeItem(Vec<GenericBound>, Option<Type>),
/// An item that has been stripped by a rustdoc pass
StrippedItem(Box<ItemEnum>),
KeywordItem(String),
@ -588,7 +588,7 @@ impl ItemEnum {
pub fn is_associated(&self) -> bool {
match *self {
ItemEnum::TypedefItem(_, _) |
ItemEnum::AssociatedTypeItem(_, _) => true,
ItemEnum::AssocTypeItem(_, _) => true,
_ => false,
}
}
@ -2206,7 +2206,7 @@ impl Clean<Item> for hir::TraitItem {
fn clean(&self, cx: &DocContext<'_>) -> Item {
let inner = match self.node {
hir::TraitItemKind::Const(ref ty, default) => {
AssociatedConstItem(ty.clean(cx),
AssocConstItem(ty.clean(cx),
default.map(|e| print_const_expr(cx, e)))
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
@ -2226,7 +2226,7 @@ impl Clean<Item> for hir::TraitItem {
})
}
hir::TraitItemKind::Type(ref bounds, ref default) => {
AssociatedTypeItem(bounds.clean(cx), default.clean(cx))
AssocTypeItem(bounds.clean(cx), default.clean(cx))
}
};
let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
@ -2247,7 +2247,7 @@ impl Clean<Item> for hir::ImplItem {
fn clean(&self, cx: &DocContext<'_>) -> Item {
let inner = match self.node {
hir::ImplItemKind::Const(ref ty, expr) => {
AssociatedConstItem(ty.clean(cx),
AssocConstItem(ty.clean(cx),
Some(print_const_expr(cx, expr)))
}
hir::ImplItemKind::Method(ref sig, body) => {
@ -2276,19 +2276,19 @@ impl Clean<Item> for hir::ImplItem {
}
}
impl<'tcx> Clean<Item> for ty::AssociatedItem {
impl<'tcx> Clean<Item> for ty::AssocItem {
fn clean(&self, cx: &DocContext<'_>) -> Item {
let inner = match self.kind {
ty::AssociatedKind::Const => {
ty::AssocKind::Const => {
let ty = cx.tcx.type_of(self.def_id);
let default = if self.defaultness.has_value() {
Some(inline::print_inlined_const(cx, self.def_id))
} else {
None
};
AssociatedConstItem(ty.clean(cx), default)
AssocConstItem(ty.clean(cx), default)
}
ty::AssociatedKind::Method => {
ty::AssocKind::Method => {
let generics = (cx.tcx.generics_of(self.def_id),
&cx.tcx.explicit_predicates_of(self.def_id)).clean(cx);
let sig = cx.tcx.fn_sig(self.def_id);
@ -2359,7 +2359,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
})
}
}
ty::AssociatedKind::Type => {
ty::AssocKind::Type => {
let my_name = self.ident.name.clean(cx);
if let ty::TraitContainer(did) = self.container {
@ -2404,7 +2404,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
None
};
AssociatedTypeItem(bounds, ty.clean(cx))
AssocTypeItem(bounds, ty.clean(cx))
} else {
TypedefItem(Typedef {
type_: cx.tcx.type_of(self.def_id).clean(cx),
@ -2415,7 +2415,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
}, true)
}
}
ty::AssociatedKind::Existential => unimplemented!(),
ty::AssocKind::Existential => unimplemented!(),
};
let visibility = match self.container {
@ -4182,7 +4182,7 @@ fn resolve_type(cx: &DocContext<'_>,
}
Res::SelfTy(..)
| Res::Def(DefKind::TyParam, _)
| Res::Def(DefKind::AssociatedTy, _) => true,
| Res::Def(DefKind::AssocTy, _) => true,
_ => false,
};
let did = register_res(&*cx, path.res);

View File

@ -722,7 +722,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
"<a class=\"type\" href=\"{url}#{shortty}.{name}\" \
title=\"type {path}::{name}\">{name}</a>",
url = url,
shortty = ItemType::AssociatedType,
shortty = ItemType::AssocType,
name = name,
path = path.join("::"))?;
}

View File

@ -33,9 +33,9 @@ pub enum ItemType {
Variant = 13,
Macro = 14,
Primitive = 15,
AssociatedType = 16,
AssocType = 16,
Constant = 17,
AssociatedConst = 18,
AssocConst = 18,
Union = 19,
ForeignType = 20,
Keyword = 21,
@ -83,8 +83,8 @@ impl<'a> From<&'a clean::Item> for ItemType {
clean::ForeignStaticItem(..) => ItemType::Static, // no ForeignStatic
clean::MacroItem(..) => ItemType::Macro,
clean::PrimitiveItem(..) => ItemType::Primitive,
clean::AssociatedConstItem(..) => ItemType::AssociatedConst,
clean::AssociatedTypeItem(..) => ItemType::AssociatedType,
clean::AssocConstItem(..) => ItemType::AssocConst,
clean::AssocTypeItem(..) => ItemType::AssocType,
clean::ForeignTypeItem => ItemType::ForeignType,
clean::KeywordItem(..) => ItemType::Keyword,
clean::TraitAliasItem(..) => ItemType::TraitAlias,
@ -141,9 +141,9 @@ impl ItemType {
ItemType::Variant => "variant",
ItemType::Macro => "macro",
ItemType::Primitive => "primitive",
ItemType::AssociatedType => "associatedtype",
ItemType::AssocType => "associatedtype",
ItemType::Constant => "constant",
ItemType::AssociatedConst => "associatedconstant",
ItemType::AssocConst => "associatedconstant",
ItemType::ForeignType => "foreigntype",
ItemType::Keyword => "keyword",
ItemType::Existential => "existential",
@ -162,7 +162,7 @@ impl ItemType {
ItemType::Typedef |
ItemType::Trait |
ItemType::Primitive |
ItemType::AssociatedType |
ItemType::AssocType |
ItemType::Existential |
ItemType::TraitAlias |
ItemType::ForeignType => NameSpace::Type,
@ -177,7 +177,7 @@ impl ItemType {
ItemType::StructField |
ItemType::Variant |
ItemType::Constant |
ItemType::AssociatedConst => NameSpace::Value,
ItemType::AssocConst => NameSpace::Value,
ItemType::Macro |
ItemType::ProcAttribute |

View File

@ -1554,12 +1554,12 @@ impl DocFolder for Cache {
if let Some(ref s) = item.name {
let (parent, is_inherent_impl_item) = match item.inner {
clean::StrippedItem(..) => ((None, None), false),
clean::AssociatedConstItem(..) |
clean::AssocConstItem(..) |
clean::TypedefItem(_, true) if self.parent_is_trait_impl => {
// skip associated items in trait impls
((None, None), false)
}
clean::AssociatedTypeItem(..) |
clean::AssocTypeItem(..) |
clean::TyMethodItem(..) |
clean::StructFieldItem(..) |
clean::VariantItem(..) => {
@ -1567,7 +1567,7 @@ impl DocFolder for Cache {
Some(&self.stack[..self.stack.len() - 1])),
false)
}
clean::MethodItem(..) | clean::AssociatedConstItem(..) => {
clean::MethodItem(..) | clean::AssocConstItem(..) => {
if self.parent_stack.is_empty() {
((None, None), false)
} else {
@ -3366,7 +3366,7 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink<'_>) -> String {
let name = it.name.as_ref().unwrap();
let ty = match it.type_() {
Typedef | AssociatedType => AssociatedType,
Typedef | AssocType => AssocType,
s@_ => s,
};
@ -3511,11 +3511,11 @@ fn render_assoc_item(w: &mut fmt::Formatter<'_>,
clean::MethodItem(ref m) => {
method(w, item, m.header, &m.generics, &m.decl, link, parent)
}
clean::AssociatedConstItem(ref ty, ref default) => {
clean::AssocConstItem(ref ty, ref default) => {
assoc_const(w, item, ty, default.as_ref(), link,
if parent == ItemType::Trait { " " } else { "" })
}
clean::AssociatedTypeItem(ref bounds, ref default) => {
clean::AssocTypeItem(ref bounds, ref default) => {
assoc_type(w, item, bounds, default.as_ref(), link,
if parent == ItemType::Trait { " " } else { "" })
}
@ -4247,14 +4247,14 @@ fn render_impl(w: &mut fmt::Formatter<'_>, cx: &Context, i: &Impl, link: AssocIt
}
}
clean::TypedefItem(ref tydef, _) => {
let id = cx.derive_id(format!("{}.{}", ItemType::AssociatedType, name));
let id = cx.derive_id(format!("{}.{}", ItemType::AssocType, name));
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
write!(w, "<code id='{}'>", ns_id)?;
assoc_type(w, item, &Vec::new(), Some(&tydef.type_), link.anchor(&id), "")?;
write!(w, "</code></h4>")?;
}
clean::AssociatedConstItem(ref ty, ref default) => {
clean::AssocConstItem(ref ty, ref default) => {
let id = cx.derive_id(format!("{}.{}", item_type, name));
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
@ -4268,7 +4268,7 @@ fn render_impl(w: &mut fmt::Formatter<'_>, cx: &Context, i: &Impl, link: AssocIt
}
write!(w, "</h4>")?;
}
clean::AssociatedTypeItem(ref bounds, ref default) => {
clean::AssocTypeItem(ref bounds, ref default) => {
let id = cx.derive_id(format!("{}.{}", item_type, name));
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
@ -4946,8 +4946,8 @@ fn item_ty_to_strs(ty: &ItemType) -> (&'static str, &'static str) {
ItemType::Variant => ("variants", "Variants"),
ItemType::Macro => ("macros", "Macros"),
ItemType::Primitive => ("primitives", "Primitive Types"),
ItemType::AssociatedType => ("associated-types", "Associated Types"),
ItemType::AssociatedConst => ("associated-consts", "Associated Constants"),
ItemType::AssocType => ("associated-types", "Associated Types"),
ItemType::AssocConst => ("associated-consts", "Associated Constants"),
ItemType::ForeignType => ("foreign-types", "Foreign Types"),
ItemType::Keyword => ("keywords", "Keywords"),
ItemType::Existential => ("existentials", "Existentials"),
@ -4974,7 +4974,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter<'_>, _it: &clean::Item,
ItemType::Enum, ItemType::Constant, ItemType::Static, ItemType::Trait,
ItemType::Function, ItemType::Typedef, ItemType::Union, ItemType::Impl,
ItemType::TyMethod, ItemType::Method, ItemType::StructField, ItemType::Variant,
ItemType::AssociatedType, ItemType::AssociatedConst, ItemType::ForeignType] {
ItemType::AssocType, ItemType::AssocConst, ItemType::ForeignType] {
if items.iter().any(|it| !it.is_stripped() && it.type_() == myty) {
let (short, name) = item_ty_to_strs(&myty);
sidebar.push_str(&format!("<li><a href=\"#{id}\">{name}</a></li>",

View File

@ -75,8 +75,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
// In case this is a trait item, skip the
// early return and try looking for the trait.
let value = match result.res {
Res::Def(DefKind::Method, _) | Res::Def(DefKind::AssociatedConst, _) => true,
Res::Def(DefKind::AssociatedTy, _) => false,
Res::Def(DefKind::Method, _) | Res::Def(DefKind::AssocConst, _) => true,
Res::Def(DefKind::AssocTy, _) => false,
Res::Def(DefKind::Variant, _) => return handle_variant(cx, result.res),
// Not a trait item; just return what we found.
_ => return Ok((result.res, None))
@ -120,7 +120,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
return cx.tcx.associated_items(did)
.find(|item| item.ident.name == item_name)
.and_then(|item| match item.kind {
ty::AssociatedKind::Method => Some("method"),
ty::AssocKind::Method => Some("method"),
_ => None,
})
.map(|out| (prim, Some(format!("{}#{}.{}", path, out, item_name))))
@ -143,8 +143,8 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
.find(|item| item.ident.name == item_name);
if let Some(item) = item {
let out = match item.kind {
ty::AssociatedKind::Method if ns == ValueNS => "method",
ty::AssociatedKind::Const if ns == ValueNS => "associatedconstant",
ty::AssocKind::Method if ns == ValueNS => "method",
ty::AssocKind::Const if ns == ValueNS => "associatedconstant",
_ => return Err(())
};
Ok((ty.res, Some(format!("{}.{}", out, item_name))))
@ -181,9 +181,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
.find(|item| item.ident.name == item_name);
if let Some(item) = item {
let kind = match item.kind {
ty::AssociatedKind::Const if ns == ValueNS => "associatedconstant",
ty::AssociatedKind::Type if ns == TypeNS => "associatedtype",
ty::AssociatedKind::Method if ns == ValueNS => {
ty::AssocKind::Const if ns == ValueNS => "associatedconstant",
ty::AssocKind::Type if ns == TypeNS => "associatedtype",
ty::AssocKind::Method if ns == ValueNS => {
if item.defaultness.has_value() {
"method"
} else {

View File

@ -172,7 +172,7 @@ impl<'a> DocFolder for Stripper<'a> {
| clean::ForeignStaticItem(..)
| clean::ConstantItem(..)
| clean::UnionItem(..)
| clean::AssociatedConstItem(..)
| clean::AssocConstItem(..)
| clean::TraitAliasItem(..)
| clean::ForeignTypeItem => {
if i.def_id.is_local() {
@ -214,7 +214,7 @@ impl<'a> DocFolder for Stripper<'a> {
clean::PrimitiveItem(..) => {}
// Associated types are never stripped
clean::AssociatedTypeItem(..) => {}
clean::AssocTypeItem(..) => {}
// Keywords are never stripped
clean::KeywordItem(..) => {}