-
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
Update visibility of intermediate use items. #57922
Conversation
r? @oli-obk (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_privacy/lib.rs
Outdated
let item = self.tcx.hir().expect_item(item_id.id); | ||
if item.ident != name.ident { continue; } | ||
if let hir::ItemKind::Use(..) = item.node { | ||
self.update(item.id, Some(AccessLevel::Exported)); |
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.
I've only taken this approach to updating the intermediate use statement as I couldn't find a way to go to it directly from the first use statement. If anyone has a better way of getting to this, I'm happy to change it.
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.
Oh man, what a hack.
The import -> import -> import -> real definition
link is lost after resolve.
The real solution is to calculate AccessLevel::Public
and AccessLevel::Exported
levels in resolve, while keeping calculating Reachable
/ReachableFromImplTrait
during the late privacy stage.
It will obviously require changing some infrastructure as well.
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 solution won't work with glob imports (they don't have a name) and also doesn't respect namespaces.
It's an ok approximation, I think we can merge it after adding a couple of FIXMEs describing why it's not entirely correct.
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.
Would you prefer I attempt to do that in this PR or file a separate issue so that this is followed up on?
Clarified by your later message.
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.
I've added a FIXME comment.
This comment has been minimized.
This comment has been minimized.
ff9a1b7
to
e24431f
Compare
This comment has been minimized.
This comment has been minimized.
e24431f
to
4302d92
Compare
4302d92
to
b487a4b
Compare
@bors r+ |
📌 Commit b487a4b1c15bfeb0337b079038498ed1d13e5aa8 has been approved by |
⌛ Testing commit b487a4b1c15bfeb0337b079038498ed1d13e5aa8 with merge c02deb70ed6d7166c91f3aa33831d99cc1c090cd... |
💔 Test failed - status-appveyor |
@bors retry |
This comment has been minimized.
This comment has been minimized.
⌛ Testing commit b487a4b1c15bfeb0337b079038498ed1d13e5aa8 with merge 3d4225349c6db6f369352904a004cd9abeef9609... |
ping from triage @petrochenkov waiting for your review on the latest change. |
@bors r=petrochenkov |
📌 Commit ad22de4 has been approved by |
Update visibility of intermediate use items. Fixes rust-lang#57410 and fixes rust-lang#53925 and fixes rust-lang#47816. Currently, the target of a use statement will be updated with the visibility of the use statement itself (if the use statement was visible). This PR ensures that if the path to the target item is via another use statement then that intermediate use statement will also have the visibility updated like the target. This silences incorrect `unreachable_pub` lints with inactionable suggestions.
Failed in rollup, #57955 (comment) (same reason as before). @bors r- Please test locally or with |
My bad, I had ran tests locally but didn't consider conditional code for other platforms. I'll r+ again when I'm sure it'll be fine. |
ad22de4
to
036819b
Compare
Currently, the target of a use statement will be updated with the visibility of the use statement itself (if the use statement was visible). This commit ensures that if the path to the target item is via another use statement then that intermediate use statement will also have the visibility updated like the target. This silences incorrect `unreachable_pub` lints with inactionable suggestions.
036819b
to
7102339
Compare
I've ran all the tests for this on both Windows and Linux, I think there shouldn't be any issues. |
@bors r+ |
📌 Commit 7102339 has been approved by |
Update visibility of intermediate use items. Fixes #57410 and fixes #53925 and fixes #47816. Currently, the target of a use statement will be updated with the visibility of the use statement itself (if the use statement was visible). This PR ensures that if the path to the target item is via another use statement then that intermediate use statement will also have the visibility updated like the target. This silences incorrect `unreachable_pub` lints with inactionable suggestions.
☀️ Test successful - checks-travis, status-appveyor |
Fixes #57410 and fixes #53925 and fixes #47816.
Currently, the target of a use statement will be updated with
the visibility of the use statement itself (if the use statement was
visible).
This PR ensures that if the path to the target item is via another
use statement then that intermediate use statement will also have the
visibility updated like the target. This silences incorrect
unreachable_pub
lints with inactionable suggestions.