Approximate type aliases as public when determining impl publicity
This commit is contained in:
parent
f8ae31f601
commit
a09246ad34
@ -1128,11 +1128,21 @@ impl<'a, 'tcx: 'a, 'v> Visitor<'v> for SearchInterfaceForPrivateItemsVisitor<'a,
|
||||
def::DefPrimTy(..) | def::DefSelfTy(..) | def::DefTyParam(..) => {
|
||||
// Public
|
||||
}
|
||||
def::DefAssociatedTy(..) if self.is_quiet => {
|
||||
// Conservatively approximate the whole type alias as public without
|
||||
// recursing into its components when determining impl publicity.
|
||||
return
|
||||
}
|
||||
def::DefStruct(def_id) | def::DefTy(def_id, _) |
|
||||
def::DefTrait(def_id) | def::DefAssociatedTy(def_id, _) => {
|
||||
// Non-local means public, local needs to be checked
|
||||
if let Some(node_id) = self.tcx.map.as_local_node_id(def_id) {
|
||||
if let Some(ast_map::NodeItem(ref item)) = self.tcx.map.find(node_id) {
|
||||
if let (&hir::ItemTy(..), true) = (&item.node, self.is_quiet) {
|
||||
// Conservatively approximate the whole type alias as public without
|
||||
// recursing into its components when determining impl publicity.
|
||||
return
|
||||
}
|
||||
if item.vis != hir::Public {
|
||||
if !self.is_quiet {
|
||||
span_err!(self.tcx.sess, ty.span, E0446,
|
||||
|
@ -121,3 +121,22 @@ impl<T: ParamTrait<Private<isize>>> //~ ERROR private type in public interface
|
||||
ParamTrait<T> for Public<i8> {
|
||||
fn foo() -> T { panic!() }
|
||||
}
|
||||
|
||||
type PrivAlias = Public<i8>;
|
||||
|
||||
trait PrivTrait2 {
|
||||
type Alias;
|
||||
}
|
||||
impl PrivTrait2 for Private<isize> {
|
||||
type Alias = Public<u8>;
|
||||
}
|
||||
|
||||
impl PubTrait for PrivAlias {
|
||||
fn bar(&self) -> Private<isize> { panic!() } //~ ERROR private type in public interface
|
||||
fn baz() -> Private<isize> { panic!() } //~ ERROR private type in public interface
|
||||
}
|
||||
|
||||
impl PubTrait for <Private<isize> as PrivTrait2>::Alias {
|
||||
fn bar(&self) -> Private<isize> { panic!() } //~ ERROR private type in public interface
|
||||
fn baz() -> Private<isize> { panic!() } //~ ERROR private type in public interface
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user