-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
privacy: Use common
DefId
visiting infra for all privacy visitors
- Loading branch information
1 parent
6efaef6
commit 8b1c424
Showing
17 changed files
with
565 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Patterns and expressions are not interface parts and don't produce private-in-public errors. | ||
|
||
// compile-pass | ||
|
||
struct Priv1(usize); | ||
struct Priv2; | ||
|
||
pub struct Pub(Priv2); | ||
|
||
pub fn public_expr(_: [u8; Priv1(0).0]) {} // OK | ||
pub fn public_pat(Pub(Priv2): Pub) {} // OK | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(optin_builtin_traits)] | ||
|
||
#[allow(private_in_public)] | ||
mod m { | ||
pub trait PubPrincipal {} | ||
auto trait PrivNonPrincipal {} | ||
pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} } | ||
} | ||
|
||
fn main() { | ||
m::leak_dyn_nonprincipal(); | ||
//~^ ERROR type `(dyn m::PubPrincipal + m::PrivNonPrincipal + 'static)` is private | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: type `(dyn m::PubPrincipal + m::PrivNonPrincipal + 'static)` is private | ||
--> $DIR/private-in-public-non-principal-2.rs:11:5 | ||
| | ||
LL | m::leak_dyn_nonprincipal(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![feature(optin_builtin_traits)] | ||
|
||
pub trait PubPrincipal {} | ||
auto trait PrivNonPrincipal {} | ||
|
||
pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} } | ||
//~^ WARN private type `(dyn PubPrincipal + PrivNonPrincipal + 'static)` in public interface | ||
//~| WARN this was previously accepted | ||
|
||
#[deny(missing_docs)] | ||
fn container() { | ||
impl dyn PubPrincipal { | ||
pub fn check_doc_lint() {} //~ ERROR missing documentation for a method | ||
} | ||
impl dyn PubPrincipal + PrivNonPrincipal { | ||
pub fn check_doc_lint() {} // OK, no missing doc lint | ||
} | ||
} | ||
|
||
fn main() {} |
24 changes: 24 additions & 0 deletions
24
src/test/ui/privacy/private-in-public-non-principal.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
warning: private type `(dyn PubPrincipal + PrivNonPrincipal + 'static)` in public interface (error E0446) | ||
--> $DIR/private-in-public-non-principal.rs:6:1 | ||
| | ||
LL | pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: #[warn(private_in_public)] on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537> | ||
|
||
error: missing documentation for a method | ||
--> $DIR/private-in-public-non-principal.rs:13:9 | ||
| | ||
LL | pub fn check_doc_lint() {} //~ ERROR missing documentation for a method | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/private-in-public-non-principal.rs:10:8 | ||
| | ||
LL | #[deny(missing_docs)] | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters