mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Visit in embargo visitor if trait method has body
This commit is contained in:
parent
7cd466a036
commit
6e8573c520
@ -636,17 +636,45 @@ impl<'tcx> EmbargoVisitor<'tcx> {
|
|||||||
impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
||||||
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
|
||||||
if self.impl_trait_pass
|
if self.impl_trait_pass
|
||||||
&& let hir::ItemKind::OpaqueTy(..) = item.kind
|
&& let hir::ItemKind::OpaqueTy(opaque) = item.kind
|
||||||
{
|
{
|
||||||
// FIXME: This is some serious pessimization intended to workaround deficiencies
|
let should_visit = match opaque.origin {
|
||||||
// in the reachability pass (`middle/reachable.rs`). Types are marked as link-time
|
hir::OpaqueTyOrigin::FnReturn {
|
||||||
// reachable if they are returned via `impl Trait`, even from private functions.
|
parent,
|
||||||
let pub_ev = EffectiveVisibility::from_vis(ty::Visibility::Public);
|
in_trait_or_impl: Some(hir::RpitContext::Trait),
|
||||||
self.reach_through_impl_trait(item.owner_id.def_id, pub_ev)
|
}
|
||||||
.generics()
|
| hir::OpaqueTyOrigin::AsyncFn {
|
||||||
.predicates()
|
parent,
|
||||||
.ty();
|
in_trait_or_impl: Some(hir::RpitContext::Trait),
|
||||||
return;
|
} => match self.tcx.hir_node_by_def_id(parent).expect_trait_item().expect_fn().1 {
|
||||||
|
hir::TraitFn::Required(_) => false,
|
||||||
|
hir::TraitFn::Provided(..) => true,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Always visit RPITs in functions that have definitions,
|
||||||
|
// and all TAITs.
|
||||||
|
hir::OpaqueTyOrigin::FnReturn {
|
||||||
|
in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
|
||||||
|
..
|
||||||
|
}
|
||||||
|
| hir::OpaqueTyOrigin::AsyncFn {
|
||||||
|
in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
|
||||||
|
..
|
||||||
|
}
|
||||||
|
| hir::OpaqueTyOrigin::TyAlias { .. } => true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if should_visit {
|
||||||
|
// 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 pub_ev = EffectiveVisibility::from_vis(ty::Visibility::Public);
|
||||||
|
self.reach_through_impl_trait(item.owner_id.def_id, pub_ev)
|
||||||
|
.generics()
|
||||||
|
.predicates()
|
||||||
|
.ty();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update levels of nested things and mark all items
|
// Update levels of nested things and mark all items
|
||||||
|
Loading…
Reference in New Issue
Block a user