diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2020-08-03 21:50:24 -0400 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2020-08-03 21:58:32 -0400 |
| commit | 0f5be70ea4c3ec4544cdeb80e3138832e15815f9 (patch) | |
| tree | e58f64d418e28a189d71fd60edff29fa5be2ed3a | |
| parent | 70697d8be87635d294f29c9c7a2a31b8ed08e49c (diff) | |
| download | rust-0f5be70ea4c3ec4544cdeb80e3138832e15815f9.tar.gz rust-0f5be70ea4c3ec4544cdeb80e3138832e15815f9.zip | |
Revert to the old `impl Trait` behavior for everyone except rustdoc
| -rw-r--r-- | src/librustc_privacy/lib.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 797b2d35e9d..48d846dfefd 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(..) |
