privacy: Mark everything in a header of a reachable impl as reachable

This commit is contained in:
Vadim Petrochenkov 2019-01-05 21:56:49 +03:00
parent 67713f5b7f
commit 9503c56ff7
6 changed files with 36 additions and 9 deletions

View file

@ -552,7 +552,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
// Visit everything except for private impl items.
hir::ItemKind::Impl(.., ref impl_item_refs) => {
if item_level.is_some() {
self.reach(item.id, item_level).generics().predicates();
self.reach(item.id, item_level).generics().predicates().ty().trait_ref();
for impl_item_ref in impl_item_refs {
let impl_item_level = self.get(impl_item_ref.id.node_id);
@ -711,6 +711,13 @@ impl<'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'_, 'a, 'tcx> {
self.visit(self.ev.tcx.type_of(self.item_def_id));
self
}
fn trait_ref(&mut self) -> &mut Self {
if let Some(trait_ref) = self.ev.tcx.impl_trait_ref(self.item_def_id) {
self.visit_trait(trait_ref);
}
self
}
}
impl<'a, 'tcx> DefIdVisitor<'a, 'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'a, 'tcx> {

View file

@ -0,0 +1,10 @@
mod inner {
pub struct PubUnnameable;
impl PubUnnameable {
pub fn pub_method(self) {}
}
}
pub trait PubTraitWithSingleImplementor {}
impl PubTraitWithSingleImplementor for Option<inner::PubUnnameable> {}

View file

@ -0,0 +1,8 @@
// compile-pass
// aux-build:issue-57264-1.rs
extern crate issue_57264_1;
fn main() {
issue_57264_1::Pub::pub_method();
}

View file

@ -0,0 +1,10 @@
// compile-pass
// aux-build:issue-57264-2.rs
extern crate issue_57264_2;
fn infer<T: issue_57264_2::PubTraitWithSingleImplementor>(arg: T) -> T { arg }
fn main() {
infer(None).unwrap().pub_method();
}

View file

@ -1,8 +0,0 @@
// compile-pass
// aux-build:issue-57264.rs
extern crate issue_57264;
fn main() {
issue_57264::Pub::pub_method();
}