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
Merged

Conversation

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Nov 9, 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!

@rust-highfive
Copy link
Collaborator

@rust-highfive rust-highfive commented Nov 9, 2015

r? @alexcrichton

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

@petrochenkov
Copy link
Contributor Author

@petrochenkov petrochenkov commented Nov 9, 2015

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(_) => {}

This comment has been minimized.

@alexcrichton

alexcrichton Nov 10, 2015
Member

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

@alexcrichton alexcrichton commented Nov 10, 2015

Looks good to me! (just a minor nit)

Scheduling a crater run just to double check

@alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Nov 10, 2015

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

@petrochenkov
Copy link
Contributor Author

@petrochenkov petrochenkov commented Nov 10, 2015

Updated with exhaustive matching.

@alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Nov 10, 2015

@bors
Copy link
Contributor

@bors 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
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@petrochenkov petrochenkov deleted the petrochenkov:privsan branch Nov 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants