Skip to content
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

rustc_privacy: Fix bugs in SanePrivacyVisitor #29726

Merged
merged 2 commits into from Nov 11, 2015

Conversation

petrochenkov
Copy link
Contributor

  • Check privacy sanity in all blocks, not only function bodies
  • Check all fields, not only named
  • Check all impl items, not only methods
  • Check default impls
  • Move the sanity check in the beginning of privacy checking, so others could rely on it

Technically it's a [breaking-change], but I expect no breakage because, well, it's sane privacy visitor, if code is broken it must be insane by definition!

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@petrochenkov
Copy link
Contributor Author

I'm not actually sure if the part of SanePrivacyVisitor ensuring that there's no pub things in blocks is useful.
AFAIK, rustdoc wraps code snippets in main function, so you can't demonstrate publicity in these snippets, unless you turn off their compilation.
Maybe this restriction should be removed (or turned into warning)? cc @steveklabnik

hir::ItemTrait(..) | hir::ItemDefaultImpl(..) |
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemStruct(..) |
hir::ItemFn(..) | hir::ItemMod(..) | hir::ItemTy(..) |
hir::ItemExternCrate(_) | hir::ItemUse(_) => {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like to always have exhaustive matches wherever possible, e.g. it's easy to skim over this list and say "ah yeah pub is allowed on each of these". Perhaps this part could stay?

@alexcrichton
Copy link
Member

Looks good to me! (just a minor nit)

Scheduling a crater run just to double check

@alexcrichton alexcrichton added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Nov 10, 2015
@alexcrichton
Copy link
Member

Crater reports one regression, but I believe it's spurious, so otherwise this should be good to go.

@alexcrichton alexcrichton removed the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Nov 10, 2015
@petrochenkov
Copy link
Contributor Author

Updated with exhaustive matching.

@alexcrichton
Copy link
Member

@bors: r+ 41ccd44

@alexcrichton alexcrichton added the relnotes Marks issues that should be documented in the release notes of the next release. label Nov 10, 2015
@bors
Copy link
Contributor

bors commented Nov 11, 2015

⌛ Testing commit 41ccd44 with merge ad3bd1b...

bors added a commit that referenced this pull request Nov 11, 2015
- Check privacy sanity in all blocks, not only function bodies
- Check all fields, not only named
- Check all impl items, not only methods
- Check default impls
- Move the sanity check in the beginning of privacy checking, so others could rely on it

Technically it's a [breaking-change], but I expect no breakage because, well, it's *sane* privacy visitor, if code is broken it must be insane by definition!
@bors bors merged commit 41ccd44 into rust-lang:master Nov 11, 2015
@petrochenkov petrochenkov deleted the privsan branch November 22, 2015 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants