Rename TraitOrImpl to Assoc and trait_or_impl to assoc.

This commit is contained in:
Eduard-Mihai Burtescu 2019-05-29 00:35:14 +03:00
parent 7212685837
commit 120ce12016
2 changed files with 25 additions and 12 deletions

View File

@ -1703,8 +1703,13 @@ fn check(&self, item_id: hir::HirId, required_visibility: ty::Visibility)
}
}
fn check_trait_or_impl_item(&self, hir_id: hir::HirId, assoc_item_kind: AssocItemKind,
defaultness: hir::Defaultness, vis: ty::Visibility) {
fn check_assoc_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 {
@ -1754,8 +1759,12 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
self.check(item.hir_id, item_visibility).generics().predicates();
for trait_item_ref in trait_item_refs {
self.check_trait_or_impl_item(trait_item_ref.id.hir_id, trait_item_ref.kind,
trait_item_ref.defaultness, item_visibility);
self.check_assoc_item(
trait_item_ref.id.hir_id,
trait_item_ref.kind,
trait_item_ref.defaultness,
item_visibility,
);
}
}
hir::ItemKind::TraitAlias(..) => {
@ -1803,8 +1812,12 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
} else {
impl_vis
};
self.check_trait_or_impl_item(impl_item_ref.id.hir_id, impl_item_ref.kind,
impl_item_ref.defaultness, impl_item_vis);
self.check_assoc_item(
impl_item_ref.id.hir_id,
impl_item_ref.kind,
impl_item_ref.defaultness,
impl_item_vis,
);
}
}
}

View File

@ -860,7 +860,7 @@ fn visit_fn(&mut self,
FnKind::ItemFn(_, ref header, ..) =>
(FnItemRibKind, &header.asyncness.node),
FnKind::Method(_, ref sig, _, _) =>
(TraitOrImplItemRibKind, &sig.header.asyncness.node),
(AssocItemRibKind, &sig.header.asyncness.node),
FnKind::Closure(_) =>
// Async closures aren't resolved through `visit_fn`-- they're
// processed separately
@ -1033,7 +1033,7 @@ enum RibKind<'a> {
/// methods or associated types. Allow references to ty params that impl or trait
/// binds. Disallow any other upvars (including other ty params that are
/// upvars).
TraitOrImplItemRibKind,
AssocItemRibKind,
/// We passed through a function definition. Disallow upvars.
/// Permit only those const parameters that are specified in the function's generics.
@ -2612,7 +2612,7 @@ fn resolve_item(&mut self, item: &Item) {
for trait_item in trait_items {
let generic_params = HasGenericParams(&trait_item.generics,
TraitOrImplItemRibKind);
AssocItemRibKind);
this.with_generic_param_rib(generic_params, |this| {
match trait_item.node {
TraitItemKind::Const(ref ty, ref default) => {
@ -2899,7 +2899,7 @@ fn resolve_implementation(&mut self,
// We also need a new scope for the impl item type parameters.
let generic_params = HasGenericParams(&impl_item.generics,
TraitOrImplItemRibKind);
AssocItemRibKind);
this.with_generic_param_rib(generic_params, |this| {
use self::ResolutionError::*;
match impl_item.node {
@ -4074,7 +4074,7 @@ fn adjust_local_res(&mut self,
seen.insert(node_id, depth);
}
}
ItemRibKind | FnItemRibKind | TraitOrImplItemRibKind => {
ItemRibKind | FnItemRibKind | AssocItemRibKind => {
// This was an attempt to access an upvar inside a
// named function item. This is not allowed, so we
// report an error.
@ -4103,7 +4103,7 @@ fn adjust_local_res(&mut self,
Res::Def(DefKind::TyParam, _) | Res::SelfTy(..) => {
for rib in ribs {
match rib.kind {
NormalRibKind | TraitOrImplItemRibKind | ClosureRibKind(..) |
NormalRibKind | AssocItemRibKind | ClosureRibKind(..) |
ModuleRibKind(..) | MacroDefinition(..) | ForwardTyParamBanRibKind |
ConstantItemRibKind | TyParamAsConstParamTy => {
// Nothing to do. Continue.