@@ -409,8 +409,8 @@ impl VisibilityLike for ty::Visibility {
409
409
}
410
410
}
411
411
412
- impl VisibilityLike for Option < EffectiveVisibility > {
413
- const MAX : Self = Some ( EffectiveVisibility :: from_vis ( ty:: Visibility :: Public ) ) ;
412
+ impl VisibilityLike for EffectiveVisibility {
413
+ const MAX : Self = EffectiveVisibility :: from_vis ( ty:: Visibility :: Public ) ;
414
414
// Type inference is very smart sometimes.
415
415
// It can make an impl reachable even some components of its type or trait are unreachable.
416
416
// E.g. methods of `impl ReachableTrait<UnreachableTy> for ReachableTy<UnreachableTy> { ... }`
@@ -422,13 +422,14 @@ impl VisibilityLike for Option<EffectiveVisibility> {
422
422
// (which require reaching the `DefId`s in them).
423
423
const SHALLOW : bool = true ;
424
424
fn new_min ( find : & FindMin < ' _ , ' _ , Self > , def_id : LocalDefId ) -> Self {
425
- if let Some ( min) = find. min {
426
- return find
427
- . effective_visibilities
428
- . effective_vis ( def_id)
429
- . map ( |eff_vis| min. min ( * eff_vis, find. tcx ) ) ;
430
- }
431
- None
425
+ let effective_vis =
426
+ find. effective_visibilities . effective_vis ( def_id) . cloned ( ) . unwrap_or_else ( || {
427
+ let private_vis =
428
+ ty:: Visibility :: Restricted ( find. tcx . parent_module_from_def_id ( def_id) ) ;
429
+ EffectiveVisibility :: from_vis ( private_vis)
430
+ } ) ;
431
+
432
+ effective_vis. min ( find. min , find. tcx )
432
433
}
433
434
}
434
435
@@ -766,28 +767,23 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
766
767
}
767
768
}
768
769
hir:: ItemKind :: Impl ( ref impl_) => {
769
- if let Some ( item_ev) = Option :: < EffectiveVisibility > :: of_impl (
770
+ let item_ev = EffectiveVisibility :: of_impl (
770
771
item. owner_id . def_id ,
771
772
self . tcx ,
772
773
& self . effective_visibilities ,
773
- ) {
774
- self . update_eff_vis ( item. owner_id . def_id , item_ev, None , Level :: Direct ) ;
774
+ ) ;
775
+ self . update_eff_vis ( item. owner_id . def_id , item_ev, None , Level :: Direct ) ;
775
776
776
- self . reach ( item. owner_id . def_id , item_ev)
777
- . generics ( )
778
- . predicates ( )
779
- . ty ( )
780
- . trait_ref ( ) ;
777
+ self . reach ( item. owner_id . def_id , item_ev) . generics ( ) . predicates ( ) . ty ( ) . trait_ref ( ) ;
781
778
782
- for impl_item_ref in impl_. items {
783
- let def_id = impl_item_ref. id . owner_id . def_id ;
784
- let nominal_vis =
785
- impl_. of_trait . is_none ( ) . then ( || self . tcx . local_visibility ( def_id) ) ;
786
- self . update_eff_vis ( def_id, item_ev, nominal_vis, Level :: Direct ) ;
779
+ for impl_item_ref in impl_. items {
780
+ let def_id = impl_item_ref. id . owner_id . def_id ;
781
+ let nominal_vis =
782
+ impl_. of_trait . is_none ( ) . then ( || self . tcx . local_visibility ( def_id) ) ;
783
+ self . update_eff_vis ( def_id, item_ev, nominal_vis, Level :: Direct ) ;
787
784
788
- if let Some ( impl_item_ev) = self . get ( def_id) {
789
- self . reach ( def_id, impl_item_ev) . generics ( ) . predicates ( ) . ty ( ) ;
790
- }
785
+ if let Some ( impl_item_ev) = self . get ( def_id) {
786
+ self . reach ( def_id, impl_item_ev) . generics ( ) . predicates ( ) . ty ( ) ;
791
787
}
792
788
}
793
789
}
0 commit comments