Skip to content

Commit

Permalink
Rollup merge of rust-lang#61294 - eddyb:no-trait-nor-impl, r=varkor
Browse files Browse the repository at this point in the history
Rename `TraitOrImpl` to `Assoc` and `trait_or_impl` to `assoc`.
  • Loading branch information
Centril authored May 29, 2019
2 parents 73530ff + 120ce12 commit 3013c0b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
25 changes: 19 additions & 6 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1703,8 +1703,13 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
}
}

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 {
Expand Down Expand Up @@ -1754,8 +1759,12 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
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(..) => {
Expand Down Expand Up @@ -1803,8 +1812,12 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
} 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,
);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Resolver<'a> {
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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -2612,7 +2612,7 @@ impl<'a> Resolver<'a> {

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) => {
Expand Down Expand Up @@ -2899,7 +2899,7 @@ impl<'a> Resolver<'a> {

// 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 {
Expand Down Expand Up @@ -4074,7 +4074,7 @@ impl<'a> Resolver<'a> {
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.
Expand Down Expand Up @@ -4103,7 +4103,7 @@ impl<'a> Resolver<'a> {
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.
Expand Down

0 comments on commit 3013c0b

Please sign in to comment.