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