@@ -402,8 +402,6 @@ struct EmbargoVisitor<'tcx> {
402
402
/// n::p::f()
403
403
/// }
404
404
macro_reachable : FxHashSet < ( LocalModDefId , LocalModDefId ) > ,
405
- /// Preliminary pass for marking all underlying types of `impl Trait`s as reachable.
406
- impl_trait_pass : bool ,
407
405
/// Has something changed in the level map?
408
406
changed : bool ,
409
407
}
@@ -634,20 +632,6 @@ impl<'tcx> EmbargoVisitor<'tcx> {
634
632
}
635
633
636
634
impl < ' tcx > Visitor < ' tcx > for EmbargoVisitor < ' tcx > {
637
- fn visit_opaque_ty ( & mut self , opaque : & ' tcx rustc_hir:: OpaqueTy < ' tcx > ) -> Self :: Result {
638
- if self . impl_trait_pass && !opaque. in_trait {
639
- // FIXME: This is some serious pessimization intended to workaround deficiencies
640
- // in the reachability pass (`middle/reachable.rs`). Types are marked as link-time
641
- // reachable if they are returned via `impl Trait`, even from private functions.
642
- let pub_ev = EffectiveVisibility :: from_vis ( ty:: Visibility :: Public ) ;
643
- self . reach_through_impl_trait ( opaque. def_id , pub_ev) . generics ( ) . predicates ( ) . ty ( ) ;
644
- return ;
645
- }
646
-
647
- // Visit nested items.
648
- intravisit:: walk_opaque_ty ( self , opaque)
649
- }
650
-
651
635
fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
652
636
// Update levels of nested things and mark all items
653
637
// in interfaces of reachable items as reachable.
@@ -1724,19 +1708,34 @@ fn effective_visibilities(tcx: TyCtxt<'_>, (): ()) -> &EffectiveVisibilities {
1724
1708
tcx,
1725
1709
effective_visibilities : tcx. resolutions ( ( ) ) . effective_visibilities . clone ( ) ,
1726
1710
macro_reachable : Default :: default ( ) ,
1727
- // HACK(jynelson): trying to infer the type of `impl Trait` breaks `async-std` (and
1728
- // `pub async fn` in general). Since rustdoc never needs to do codegen and doesn't
1729
- // care about link-time reachability, keep them unreachable (issue #75100).
1730
- impl_trait_pass : !tcx. sess . opts . actually_rustdoc ,
1731
1711
changed : false ,
1732
1712
} ;
1733
1713
1734
1714
visitor. effective_visibilities . check_invariants ( tcx) ;
1735
- if visitor. impl_trait_pass {
1715
+
1716
+ // HACK(jynelson): trying to infer the type of `impl Trait` breaks `async-std` (and
1717
+ // `pub async fn` in general). Since rustdoc never needs to do codegen and doesn't
1718
+ // care about link-time reachability, keep them unreachable (issue #75100).
1719
+ let impl_trait_pass = !tcx. sess . opts . actually_rustdoc ;
1720
+ if impl_trait_pass {
1736
1721
// Underlying types of `impl Trait`s are marked as reachable unconditionally,
1737
1722
// so this pass doesn't need to be a part of the fixed point iteration below.
1738
- tcx. hir ( ) . visit_all_item_likes_in_crate ( & mut visitor) ;
1739
- visitor. impl_trait_pass = false ;
1723
+ let krate = tcx. hir_crate_items ( ( ) ) ;
1724
+ for id in krate. opaques ( ) {
1725
+ let opaque = tcx. hir_node_by_def_id ( id) . expect_opaque_ty ( ) ;
1726
+ if !opaque. in_trait {
1727
+ // FIXME: This is some serious pessimization intended to workaround deficiencies
1728
+ // in the reachability pass (`middle/reachable.rs`). Types are marked as link-time
1729
+ // reachable if they are returned via `impl Trait`, even from private functions.
1730
+ let pub_ev = EffectiveVisibility :: from_vis ( ty:: Visibility :: Public ) ;
1731
+ visitor
1732
+ . reach_through_impl_trait ( opaque. def_id , pub_ev)
1733
+ . generics ( )
1734
+ . predicates ( )
1735
+ . ty ( ) ;
1736
+ }
1737
+ }
1738
+
1740
1739
visitor. changed = false ;
1741
1740
}
1742
1741
0 commit comments