Skip to content

Commit

Permalink
Revert to the old impl Trait behavior for everyone except rustdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Aug 4, 2020
1 parent 70697d8 commit 0f5be70
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..)
Expand Down

0 comments on commit 0f5be70

Please sign in to comment.