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

Merged
merged 1 commit into from Feb 3, 2019

Conversation

Projects
None yet
7 participants
@davidtwco
Copy link
Member

davidtwco commented Jan 26, 2019

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.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 26, 2019

r? @oli-obk

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

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));

This comment has been minimized.

@davidtwco

davidtwco Jan 26, 2019

Author Member

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.

This comment has been minimized.

@petrochenkov

petrochenkov Jan 27, 2019

Contributor

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.

This comment has been minimized.

@petrochenkov

petrochenkov Jan 27, 2019

Contributor

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.

This comment has been minimized.

@davidtwco

davidtwco Jan 27, 2019

Author Member

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.

This comment has been minimized.

@davidtwco

davidtwco Jan 27, 2019

Author Member

I've added a FIXME comment.

@petrochenkov petrochenkov assigned petrochenkov and unassigned oli-obk Jan 26, 2019

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 26, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:30d40a96:start=1548531363945722084,finish=1548531444480627796,duration=80534905712
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[01:00:32]  Documenting std v0.0.0 (/checkout/src/libstd)
[01:00:35] error: This node does not have a stability attribute
[01:00:35]   --> src/libstd/sys/mod.rs:57:9
[01:00:35]    |
[01:00:35] 57 |         pub use self::ext as unix_ext;
[01:00:35] 
[01:00:35] error: Compilation failed, aborting rustdoc
[01:00:35] 
[01:00:35] error: Could not document `std`.
[01:00:35] error: Could not document `std`.
[01:00:35] 
[01:00:35] Caused by:
[01:00:35]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --crate-name std src/libstd/lib.rs --color always --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/doc --cfg 'feature="backtrace"' --cfg 'feature="backtrace-sys"' --cfg 'feature="compiler_builtins"' --cfg 'feature="compiler_builtins_c"' --cfg 'feature="default"' --cfg 'feature="panic-unwind"' --cfg 'feature="panic_unwind"' --markdown-css rust.css --markdown-no-toc --index-page /checkout/src/doc/index.md -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/release/deps --extern alloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/liballoc-5c0fb2594a6da7a1.rmeta --extern backtrace_sys=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libbacktrace_sys-d4d16b3d1fb78dd2.rmeta --extern compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-c0334c1d162a8d9a.rmeta --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-f6a1ccb419e02477.rmeta --extern libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/liblibc-85aa98a45625ace7.rmeta --extern panic_abort=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libpanic_abort-ee56e061e6d4b591.rmeta --extern panic_unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libpanic_unwind-c7188f60685e6988.rmeta --extern rustc_demangle=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_demangle-7769105b259bad48.rmeta --extern rustc_asan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_asan-ad7e52ee7148f2d8.rmeta --extern rustc_lsan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_lsan-28ebfd88aa006258.rmeta --extern rustc_msan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_msan-18e5e2d070cb8138.rmeta --extern rustc_tsan=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/librustc_tsan-1a41b8b20552df59.rmeta --extern unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libunwind-fe0cdf08a0d5baa0.rmeta` (exit code: 1)
[01:00:35] 
[01:00:35] 
[01:00:35] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-Z" "unstable-options" "-p" "std" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "--index-page" "/checkout/src/doc/index.md"
[01:00:35] 
[01:00:35] 
[01:00:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[01:00:35] Build completed unsuccessfully in 0:05:34
[01:00:35] Build completed unsuccessfully in 0:05:34
[01:00:35] Makefile:18: recipe for target 'all' failed
[01:00:35] make: *** [all] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:046eef69
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sat Jan 26 20:38:10 UTC 2019
---
travis_time:end:100815eb:start=1548535092071118367,finish=1548535092076401182,duration=5282815
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0003b088
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$C

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@davidtwco davidtwco force-pushed the davidtwco:issue-57410 branch from ff9a1b7 to e24431f Jan 26, 2019

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 26, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:1015899a:start=1548542952022294535,finish=1548543030269218625,duration=78246924090
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---

[00:03:12] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:12] tidy error: /checkout/src/librustc/middle/privacy.rs:21: unexplained "```ignore" doctest; try one:
[00:03:12] 
[00:03:12] * make the test actually pass, by adding necessary imports and declarations, or
[00:03:12] * use "```text", if the code is not Rust code, or
[00:03:12] * use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
[00:03:12] * use "```should_panic", if the code is expected to fail at run time, or
[00:03:12] * use "```no_run", if the code should type-check but not necessary linkable/runnable, or
[00:03:12] * explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
[00:03:12] 
[00:03:14] some tidy checks failed
[00:03:14] 
[00:03:14] 
[00:03:14] 
[00:03:14] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:14] 
[00:03:14] 
[00:03:14] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:14] Build completed unsuccessfully in 0:00:46
[00:03:14] Build completed unsuccessfully in 0:00:46
[00:03:14] make: *** [tidy] Error 1
[00:03:14] Makefile:68: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:3bec96b9
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Sat Jan 26 22:53:52 UTC 2019
---
travis_time:end:06199a00:start=1548543233630159938,finish=1548543233634719973,duration=4560035
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:151eda36
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:13488200
travis_time:start:13488200
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:09d5050d
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@davidtwco davidtwco force-pushed the davidtwco:issue-57410 branch from e24431f to 4302d92 Jan 26, 2019

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Jan 27, 2019

@davidtwco davidtwco force-pushed the davidtwco:issue-57410 branch from 4302d92 to b487a4b Jan 27, 2019

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Jan 27, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 27, 2019

📌 Commit b487a4b has been approved by petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 28, 2019

⌛️ Testing commit b487a4b with merge c02deb7...

bors added a commit that referenced this pull request Jan 28, 2019

Auto merge of #57922 - davidtwco:issue-57410, r=petrochenkov
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.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 28, 2019

💔 Test failed - status-appveyor

@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Jan 28, 2019

@bors retry

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 28, 2019

Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
Checking out files: 100% (17881/17881), done.
travis_time:end:004ec82f:start=1548636379445144000,finish=1548636388968137000,duration=9522993000
$ cd rust-lang/rust
$ git checkout -qf c02deb70ed6d7166c91f3aa33831d99cc1c090cd
fatal: reference is not a tree: c02deb70ed6d7166c91f3aa33831d99cc1c090cd
The command "git checkout -qf c02deb70ed6d7166c91f3aa33831d99cc1c090cd" failed and exited with 128 during .
Your build has been stopped.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 28, 2019

⌛️ Testing commit b487a4b with merge 3d42253...

@Dylan-DPC

This comment has been minimized.

Copy link
Member

Dylan-DPC commented Jan 28, 2019

ping from triage @petrochenkov waiting for your review on the latest change.

@davidtwco

This comment has been minimized.

Copy link
Member Author

davidtwco commented Jan 28, 2019

@bors r=petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 28, 2019

📌 Commit ad22de4 has been approved by petrochenkov

Centril added a commit to Centril/rust that referenced this pull request Jan 28, 2019

Rollup merge of rust-lang#57922 - davidtwco:issue-57410, r=petrochenkov
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.

bors added a commit that referenced this pull request Jan 28, 2019

Auto merge of #57955 - Centril:rollup, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #57833 (Print a slightly clearer message when failing to launch a thread)
 - #57859 (Fix invalid background color)
 - #57904 (add typo suggestion to unknown attribute error)
 - #57915 (Pretty print `$crate` as `crate` or `crate_name` in more cases)
 - #57922 (Update visibility of intermediate use items.)

Failed merges:

r? @ghost
@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Jan 28, 2019

Failed in rollup, #57955 (comment) (same reason as before).

@bors r-

Please test locally or with try that this builds.

@davidtwco

This comment has been minimized.

Copy link
Member Author

davidtwco commented Jan 28, 2019

Please test locally or with try that this builds.

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.

@davidtwco davidtwco force-pushed the davidtwco:issue-57410 branch from ad22de4 to 036819b Feb 2, 2019

Update visibility of intermediate use items.
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.

@davidtwco davidtwco force-pushed the davidtwco:issue-57410 branch from 036819b to 7102339 Feb 2, 2019

@davidtwco

This comment has been minimized.

Copy link
Member Author

davidtwco commented Feb 2, 2019

I've ran all the tests for this on both Windows and Linux, I think there shouldn't be any issues.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Feb 3, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 3, 2019

📌 Commit 7102339 has been approved by petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 3, 2019

⌛️ Testing commit 7102339 with merge 42b8c77...

bors added a commit that referenced this pull request Feb 3, 2019

Auto merge of #57922 - davidtwco:issue-57410, r=petrochenkov
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.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 3, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: petrochenkov
Pushing 42b8c77 to master...

@bors bors merged commit 7102339 into rust-lang:master Feb 3, 2019

1 check passed

homu Test successful
Details

@davidtwco davidtwco deleted the davidtwco:issue-57410 branch Feb 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment