diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 797b2d35e9d5..48d846dfefd2 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -778,8 +778,20 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> { } // The interface is empty. hir::ItemKind::GlobalAsm(..) => {} - // assume the type is never reachable - since it's opaque, no one can use it from this interface - hir::ItemKind::OpaqueTy(..) => {} + hir::ItemKind::OpaqueTy(..) => { + // HACK(jynelson): trying to infer the type of `impl trait` breaks `async-std` (and `pub async fn` in general) + // Since rustdoc never need to do codegen and doesn't care about link-time reachability, + // mark this as unreachable. + // See https://github.com/rust-lang/rust/issues/75100 + if !self.tcx.sess.opts.actually_rustdoc { + // FIXME: This is some serious pessimization intended to workaround deficiencies + // in the reachability pass (`middle/reachable.rs`). Types are marked as link-time + // reachable if they are returned via `impl Trait`, even from private functions. + let exist_level = cmp::max(item_level, Some(AccessLevel::ReachableFromImplTrait)); + self.reach(item.hir_id, exist_level).generics().predicates().ty(); + + } + } // Visit everything. hir::ItemKind::Const(..) | hir::ItemKind::Static(..)