Skip to content

Commit 0f5be70

Browse files
committed
Revert to the old impl Trait behavior for everyone except rustdoc
1 parent 70697d8 commit 0f5be70

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/librustc_privacy/lib.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,20 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
778778
}
779779
// The interface is empty.
780780
hir::ItemKind::GlobalAsm(..) => {}
781-
// assume the type is never reachable - since it's opaque, no one can use it from this interface
782-
hir::ItemKind::OpaqueTy(..) => {}
781+
hir::ItemKind::OpaqueTy(..) => {
782+
// HACK(jynelson): trying to infer the type of `impl trait` breaks `async-std` (and `pub async fn` in general)
783+
// Since rustdoc never need to do codegen and doesn't care about link-time reachability,
784+
// mark this as unreachable.
785+
// See https://github.com/rust-lang/rust/issues/75100
786+
if !self.tcx.sess.opts.actually_rustdoc {
787+
// FIXME: This is some serious pessimization intended to workaround deficiencies
788+
// in the reachability pass (`middle/reachable.rs`). Types are marked as link-time
789+
// reachable if they are returned via `impl Trait`, even from private functions.
790+
let exist_level = cmp::max(item_level, Some(AccessLevel::ReachableFromImplTrait));
791+
self.reach(item.hir_id, exist_level).generics().predicates().ty();
792+
793+
}
794+
}
783795
// Visit everything.
784796
hir::ItemKind::Const(..)
785797
| hir::ItemKind::Static(..)

0 commit comments

Comments
 (0)