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

rustdoc: don't inline pub use some_crate unless directly asked to #55804

Merged
merged 1 commit into from
Nov 14, 2018

Conversation

QuietMisdreavus
Copy link
Member

cc #52509 (fixes it? i'm not sure about my comment summoning the docs team)

When rustdoc encounters a pub use statement for an item from another crate, it will eagerly inline its contents into your crate. This somewhat clashes with the new paths behavior in Rust 2018, in which crates are implicitly linked and re-exported with pub use instead of pub extern crate. In rust 2015, pub extern crate would only create a single line for its re-export in the docs, so i'm making it do the same with pub use some_crate;.

The exact new behavior is like this: If rustdoc sees a pub use statement, and the item being imported is the root of another crate, it will only inline it if #[doc(inline)] is provided. I made it only avoid crate roots because otherwise it would stop inlining any module, which may or may not be what people want.

@rust-highfive
Copy link
Collaborator

r? @GuillaumeGomez

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 9, 2018
@QuietMisdreavus
Copy link
Member Author

cc @pnkfelix

@QuietMisdreavus QuietMisdreavus added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. beta-nominated Nominated for backporting to the compiler in the beta channel. labels Nov 9, 2018
@QuietMisdreavus
Copy link
Member Author

Beta-nominating to release with the edition.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.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:0284d138:start=1541726249800454155,finish=1541726250841274796,duration=1040820641
$ 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-5.0
---
[00:55:02] .................................................................................................... 100/4999
[00:55:05] .................................................................................................... 200/4999
[00:55:08] ........................................................................ii...................ii..... 300/4999
[00:55:11] ...........................................................................................iii...... 400/4999
[00:55:14] ..iiiiiiii.iii...........................iii...........................................i...........i 500/4999
[00:55:21] .................................................................................................... 700/4999
[00:55:28] .....................................................................i...........i.................. 800/4999
[00:55:31] ........................................................................................iiiii....... 900/4999
[00:55:34] ...........ii.iiii.................................................................................. 1000/4999
---
[00:56:11] .................................................................................................... 2200/4999
[00:56:16] .................................................................................................... 2300/4999
[00:56:20] .................................................................................................... 2400/4999
[00:56:24] .................................................................................................... 2500/4999
[00:56:28] ...................................................................iiiiiiiii........................ 2600/4999
[00:56:35] ...............................ii................................................................... 2800/4999
[00:56:38] .................................................................................................... 2900/4999
[00:56:42] .................................................................................................... 3000/4999
[00:56:45] ..........................i......................................................................... 3100/4999
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:11:32] 
[01:11:32] running 115 tests
[01:11:35] i..ii...iii..iii.....i...i.........i..iii...........i.....i.....ii...i..i.ii..............i...ii..ii 100/115
[01:11:36] .i....iiii.....
[01:11:36] 
[01:11:36]  finished in 3.732
[01:11:36] travis_fold:end:test_codegen

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:11:51] 
[01:11:51] running 118 tests
[01:12:15] .iiiii...i.....i..i...i..i.i..i.i..i.....i..i....i..........iiii.........i.i....i...i.......ii.i.i.i 100/118
[01:12:19] ......iii.i.....ii
[01:12:19] 
[01:12:19]  finished in 28.634
[01:12:19] travis_fold:end:test_debuginfo

---
[01:19:32] 
[01:19:32] running 274 tests
[01:20:55] .......................i............................................................................ 100/274
[01:22:02] ................................i................................................................... 200/274
[01:22:55] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[01:22:55] ............................................F.............................
[01:22:55] 
[01:22:55] ---- [rustdoc] rustdoc/src-links-external.rs stdout ----
[01:22:55] 
[01:22:55] 
[01:22:55] error: htmldocck failed!
[01:22:55] status: exit code: 1
[01:22:55] command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/src-links-external" "/checkout/src/test/rustdoc/src-links-external.rs"
[01:22:55] ------------------------------------------
[01:22:55] 
[01:22:55] ------------------------------------------
[01:22:55] stderr:
[01:22:55] stderr:
[01:22:55] ------------------------------------------
[01:22:55] 20: @has check failed
[01:22:55]  File does not exist 'foo/bar/index.html'
[01:22:55]  // @has foo/bar/index.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#11'
[01:22:55] 23: @has check failed
[01:22:55]  File does not exist 'foo/bar/struct.Foo.html'
[01:22:55]  // @has foo/bar/struct.Foo.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#11'
[01:22:55] Encountered 2 errors
[01:22:55] 
[01:22:55] ------------------------------------------
[01:22:55] 
---
[01:22:55] test result: FAILED. 271 passed; 1 failed; 2 ignored; 0 measured; 0 filtered out
[01:22:55] 
[01:22:55] 
[01:22:55] 
[01:22:55] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--rustdoc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "--src-base" "/checkout/src/test/rustdoc" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:22:55] 
[01:22:55] 
[01:22:55] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:22:55] Build completed unsuccessfully in 0:31:52
[01:22:55] Build completed unsuccessfully in 0:31:52
[01:22:55] make: *** [check] Error 1
[01:22:55] Makefile:58: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:125d3ee5
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Fri Nov  9 02:40:38 UTC 2018

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)

@GuillaumeGomez
Copy link
Member

It broke another test. Otherwise code looks good!

@QuietMisdreavus
Copy link
Member Author

Updated!

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Nov 12, 2018

📌 Commit 401cb6b has been approved by pnkfelix

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 12, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Nov 12, 2018
… r=pnkfelix

rustdoc: don't inline `pub use some_crate` unless directly asked to

cc rust-lang#52509 (fixes it? i'm not sure about my comment summoning the docs team)

When rustdoc encounters a `pub use` statement for an item from another crate, it will eagerly inline its contents into your crate. This somewhat clashes with the new paths behavior in Rust 2018, in which crates are implicitly linked and re-exported with `pub use` instead of `pub extern crate`. In rust 2015, `pub extern crate` would only create a single line for its re-export in the docs, so i'm making it do the same with `pub use some_crate;`.

The exact new behavior is like this: *If rustdoc sees a `pub use` statement, and the item being imported is the root of another crate, it will only inline it if `#[doc(inline)]` is provided.* I made it only avoid crate roots because otherwise it would stop inlining any module, which may or may not be what people want.
kennytm added a commit to kennytm/rust that referenced this pull request Nov 13, 2018
… r=pnkfelix

rustdoc: don't inline `pub use some_crate` unless directly asked to

cc rust-lang#52509 (fixes it? i'm not sure about my comment summoning the docs team)

When rustdoc encounters a `pub use` statement for an item from another crate, it will eagerly inline its contents into your crate. This somewhat clashes with the new paths behavior in Rust 2018, in which crates are implicitly linked and re-exported with `pub use` instead of `pub extern crate`. In rust 2015, `pub extern crate` would only create a single line for its re-export in the docs, so i'm making it do the same with `pub use some_crate;`.

The exact new behavior is like this: *If rustdoc sees a `pub use` statement, and the item being imported is the root of another crate, it will only inline it if `#[doc(inline)]` is provided.* I made it only avoid crate roots because otherwise it would stop inlining any module, which may or may not be what people want.
bors added a commit that referenced this pull request Nov 13, 2018
Rollup of 20 pull requests

Successful merges:

 - #55136 (Remove short doc where it starts with a codeblock)
 - #55711 (Format BtreeMap::range_mut example)
 - #55722 (impl_stable_hash_for: support enums and tuple structs with generic parameters)
 - #55754 (Avoid converting bytes to UTF-8 strings to print, just pass bytes to stdout/err)
 - #55804 (rustdoc: don't inline `pub use some_crate` unless directly asked to)
 - #55805 (Move `static_assert!` into librustc_data_structures)
 - #55837 (Make PhantomData #[structural_match])
 - #55840 (Fix TLS errors when downloading stage0)
 - #55843 (add FromIterator<A> to Box<[A]>)
 - #55858 (Small fixes on code blocks in rustdoc)
 - #55863 (Fix a typo in std::panic)
 - #55870 (Fix typos.)
 - #55874 (string: Add documentation for `From` impls)
 - #55879 (save-analysis: Don't panic for macro-generated use globs)
 - #55882 (Reference count `crate_inherent_impls`s return value.)
 - #55888 (miri: for uniformity, also move memory_deallocated to AllocationExtra)
 - #55889 (global allocators: add a few comments)
 - #55896 (Document optimizations enabled by FusedIterator)
 - #55905 (Change `Lit::short_name` to `Lit::literal_name`.)
 - #55908 (Fix their/there grammar nit)
@bors bors merged commit 401cb6b into rust-lang:master Nov 14, 2018
@pietroalbini
Copy link
Member

Ping @rust-lang/rustdoc, you need to decide if you want to backport this to the beta branch!

@QuietMisdreavus
Copy link
Member Author

My relevant statement on the linked issue:

The bug, as it stands today, is benign and has a small workaround, namely adding #[doc(no_inline)] to the re-export. I'm okay if #55804 is not backported, if we're okay with advertising that fix for one version.

Backporting this is not critical, but the change is small and fairly localized (most of the diff in this PR is adding tests). I'm not sure of the methodology used to determine other backports for this release, but this PR is small and saves a docs papercut that i can see arising in Rust-2018 code.

Let's try a proper poll again - this didn't work the last time i tried, but here goes...

@rfcbot poll

@pietroalbini
Copy link
Member

And it didn't work :(

@nikomatsakis
Copy link
Contributor

My two cents is that we might as well backport it.

@steveklabnik
Copy link
Member

I'm fine with it too.

@GuillaumeGomez
Copy link
Member

Same for me.

@QuietMisdreavus QuietMisdreavus added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Nov 16, 2018
@QuietMisdreavus
Copy link
Member Author

Cool, based on that discussion, i'll add the label. Thanks, y'all! ❤️

@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 19, 2018
@alexcrichton alexcrichton added this to the Rust 2018 Release milestone Nov 19, 2018
@nikomatsakis nikomatsakis mentioned this pull request Nov 20, 2018
20 tasks
bors added a commit that referenced this pull request Nov 20, 2018
beta backport rollup

Backports of some beta-approved PRs

- [x] #55385: NLL: cast causes failure to promote to static
- [x] #56043: remove "approx env bounds" if we already know from trait
- [x] #56003: do not propagate inferred bounds on trait objects if they involve `Self`
- [x] #55852: Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint
- [x] #55804: rustdoc: don't inline `pub use some_crate` unless directly asked to
- [x] #56059: Increase `Duration` approximate equal threshold to 1us
- [x]  Keep resolved defs in path prefixes and emit them in save-analysis #54145
- [x]  Adjust Ids of path segments in visibility modifiers #55487
- [x]  save-analysis: bug fix and optimisation. #55521
- [x]   save-analysis: be even more aggressive about ignorning macro-generated defs #55936
- [x]  save-analysis: fallback to using path id #56060
- [x]  save-analysis: Don't panic for macro-generated use globs #55879
- [x]  Add temporary renames to manifests for rustfmt/clippy #56081
- [x] Revert #51601 #56049
- [x]  Fix stability hole with `static _` #55983
- [x] #56077
- [x] Fix Rustdoc ICE when checking blanket impls #55258
- [x]  Updated RELEASES.md for 1.31.0 #55678
- [x] ~~#56061~~ #56111
- [x]  Stabilize `extern_crate_item_prelude` #56032

Still running tests locally, and I plan to backport @nrc's other PRs too

(cc @petrochenkov -- thanks for the advice)
@QuietMisdreavus QuietMisdreavus deleted the eager-crate-inline branch December 5, 2018 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants