diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 81abf3515446..9a869b24b8f6 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1463,6 +1463,12 @@ struct SearchInterfaceForPrivateItemsVisitor<'a, 'tcx: 'a> { impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> { // Check if the type alias contain private types when substituted fn is_public_type_alias(&self, item: &hir::Item, path: &hir::Path) -> bool { + // We substitute type aliases only when determining impl publicity + // FIXME: This will probably change and all type aliases will be substituted, + // requires an amendment to RFC 136. + if !self.is_quiet { + return false + } // Type alias is considered public if the aliased type is // public, even if the type alias itself is private. So, something // like `type A = u8; pub fn f() -> A {...}` doesn't cause an error. diff --git a/src/librustc_trans/back/msvc/registry.rs b/src/librustc_trans/back/msvc/registry.rs index 8f60be3fab3b..44b161a7575c 100644 --- a/src/librustc_trans/back/msvc/registry.rs +++ b/src/librustc_trans/back/msvc/registry.rs @@ -14,7 +14,7 @@ use std::os::windows::prelude::*; use std::ptr; use libc::{c_void, c_long}; -type DWORD = u32; +pub type DWORD = u32; type LPCWSTR = *const u16; type LONG = c_long; type LPDWORD = *mut DWORD; diff --git a/src/test/compile-fail/private-in-public-warn.rs b/src/test/compile-fail/private-in-public-warn.rs index 8128fde4de58..2d1de3ca2823 100644 --- a/src/test/compile-fail/private-in-public-warn.rs +++ b/src/test/compile-fail/private-in-public-warn.rs @@ -175,10 +175,10 @@ mod aliases_pub { impl PrivTr for Priv {} pub fn f1(arg: PrivUseAlias) {} // OK - pub fn f2(arg: PrivAlias) {} // OK pub trait Tr1: PrivUseAliasTr {} // OK - pub trait Tr2: PrivUseAliasTr {} // OK + // This should be OK, if type aliases are substituted + pub trait Tr2: PrivUseAliasTr {} //~ WARN private type in public interface impl PrivAlias { pub fn f(arg: Priv) {} //~ WARN private type in public interface @@ -211,7 +211,6 @@ mod aliases_priv { use self::Priv1 as PrivUseAlias; use self::PrivTr1 as PrivUseAliasTr; type PrivAlias = Priv2; - //~^ WARN private type in public interface trait PrivTr { type AssocAlias = Priv3; } @@ -246,8 +245,6 @@ mod aliases_params { struct Priv; type PrivAliasGeneric = T; type Result = ::std::result::Result; - - pub fn f1(arg: PrivAliasGeneric) {} // OK, not an error } #[rustc_error] diff --git a/src/test/compile-fail/private-in-public.rs b/src/test/compile-fail/private-in-public.rs index 7d4dcfd3145a..be22a2ef6a77 100644 --- a/src/test/compile-fail/private-in-public.rs +++ b/src/test/compile-fail/private-in-public.rs @@ -105,6 +105,8 @@ mod aliases_pub { } impl PrivTr for Priv {} + // This should be OK, if type aliases are substituted + pub fn f2(arg: PrivAlias) {} //~ ERROR private type in public interface // This should be OK, but associated type aliases are not substituted yet pub fn f3(arg: ::AssocAlias) {} //~ ERROR private type in public interface @@ -141,6 +143,8 @@ mod aliases_params { type PrivAliasGeneric = T; type Result = ::std::result::Result; + // This should be OK, if type aliases are substituted + pub fn f1(arg: PrivAliasGeneric) {} //~ ERROR private type in public interface pub fn f2(arg: PrivAliasGeneric) {} //~ ERROR private type in public interface pub fn f3(arg: Result) {} //~ ERROR private type in public interface }