Revert to the old impl Trait behavior for everyone except rustdoc

This commit is contained in:
Joshua Nelson 2020-08-03 21:50:24 -04:00
parent 70697d8be8
commit 0f5be70ea4

View file

@ -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(..)