-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
privacy: Use common DefId
visiting infrastructure for all privacy visitors
#56878
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,11 +160,6 @@ impl RawHandle { | |
} | ||
} | ||
|
||
pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> { | ||
let mut me = self; | ||
(&mut me).read_to_end(buf) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an unused function newly detected due to improved reachability analysis (which is based on privacy data). |
||
pub fn write(&self, buf: &[u8]) -> io::Result<usize> { | ||
let mut amt = 0; | ||
let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD; | ||
|
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
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 trait `m::PrivNonPrincipal` 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: trait `m::PrivNonPrincipal` 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 trait `PrivNonPrincipal` 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 trait `PrivNonPrincipal` in public interface (error E0445) | ||
--> $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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. The
substs
are missing theSelf
type, which is why thedebug {...}
implementation below does through all of that trouble of creating aTraitRef
.I think the correct fix is moving the code from
debug {...}
todisplay {...}
and changingdebug {...}
to contain justself.print_display(f, cx)
.