Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Dec 19, 2023
1 parent 3a539c0 commit 48e311f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 0 additions & 9 deletions compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,15 +1765,6 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {

pub fn provide(providers: &mut Providers) {
*providers = Providers {
visibility: |tcx, def_id| {
// Unique types created for closures participate in type privacy checking.
// They have visibilities inherited from the module they are defined in.
// FIXME: Consider evaluating visibilities for closures eagerly, like for all
// other nodes. However, unlike for others, for closures it may cause a perf
// regression, because closure visibilities are not commonly queried.
assert_eq!(tcx.def_kind(def_id), DefKind::Closure);
ty::Visibility::Restricted(tcx.parent_module_from_def_id(def_id).to_def_id())
},
effective_visibilities,
check_private_in_public,
check_mod_privacy,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,10 @@ impl<'tcx> Resolver<'_, 'tcx> {

let feed = self.tcx.feed_local_def_id(def_id);
feed.def_kind(def_kind);
if def_kind == DefKind::Closure {
let parent_mod = self.tcx.parent_module_from_def_id(def_id).to_def_id();
feed.visibility(ty::Visibility::Restricted(parent_mod));
}

// Create the definition.
if expn_id != ExpnId::root() {
Expand Down

0 comments on commit 48e311f

Please sign in to comment.