Skip to content

rustdoc: remove def_ctor hack. #60137

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

Merged
merged 2 commits into from
May 1, 2019
Merged

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Apr 20, 2019

No longer necessary since we have describe_def.

Turns out def_ctor was used in conjunction with abusing tcx.type_of(def_id) working on both type definitions and impls (specifically, of builtin types), but also reimplementing a lot of the logic that Clean already provides on Ty / ty::TraitRef.

The first commit now does the minimal refactor to keep it working, while the second commit contains the rest of the refactor I started (parts of which I'm not sure we need to keep).

@rust-highfive
Copy link
Contributor

r? @steveklabnik

(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 Apr 20, 2019
@eddyb
Copy link
Member Author

eddyb commented Apr 20, 2019

r? @petrochenkov

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 20, 2019

📌 Commit 5111735ddb9b3f06fdba0139e20340755408432c has been approved by petrochenkov

@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 Apr 20, 2019
@rust-highfive
Copy link
Contributor

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:0a3d1850:start=1555776723440280871,finish=1555776812281563059,duration=88841282188
$ 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
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[01:01:08]     Checking core v0.0.0 (/checkout/src/libcore)
[01:01:39]     Checking rustc-std-workspace-core v1.0.0 (/checkout/src/tools/rustc-std-workspace-core)
[01:01:39]     Checking compiler_builtins v0.1.10
[01:01:40]  Documenting alloc v0.0.0 (/checkout/src/liballoc)
[01:01:43] error: internal compiler error: src/librustc/hir/def.rs:287: attempted .def_id() on invalid def: Err
[01:01:43] thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:636:9
[01:01:43] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:01:44] error: aborting due to previous error
[01:01:44] 
[01:01:44] 
[01:01:44] 
[01:01:44] error: Unrecognized option: 'markdown-css'
[01:01:44] 
[01:01:44] error: Could not document `alloc`.
[01:01:44] 
[01:01:44] Caused by:
[01:01:44]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --edition=2018 --crate-name alloc src/liballoc/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 --markdown-css rust.css --markdown-no-toc --generate-redirect-pages --resource-suffix 1.36.0 --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 compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-c48a38dddb046cd4.rmeta --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-72f00ef37db6d7ed.rmeta` (exit code: 1)
[01:01:44] 
[01:01:44] 
[01:01:44] 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" "alloc" "--" "--markdown-css" "rust.css" "--markdown-no-toc" "--generate-redirect-pages" "--resource-suffix" "1.36.0" "--index-page" "/checkout/src/doc/index.md"
[01:01:44] 
[01:01:44] 
[01:01:44] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[01:01:44] Build completed unsuccessfully in 0:07:40

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)

@eddyb
Copy link
Member Author

eddyb commented Apr 20, 2019

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 20, 2019
@eddyb eddyb force-pushed the rustdoc-rm-def-ctor-hax branch from 5111735 to 1c5b11e Compare April 23, 2019 08:24
@rust-highfive
Copy link
Contributor

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:0e2d1d9f:start=1556008525833818943,finish=1556008662798800767,duration=136964981824
$ 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
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
travis_time:start:test_assembly
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:17:55] 
[01:17:55] running 9 tests
[01:17:55] iiiiiiiii
[01:17:55] 
[01:17:55]  finished in 0.147
[01:17:55] travis_fold:end:test_assembly

---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:18:11] 
[01:18:11] running 121 tests
[01:18:35] .iiiii...i.....i..i...i..i.i.i..i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i. 100/121
[01:18:39] i.i......iii.i.....ii
[01:18:39] 
[01:18:39]  finished in 28.447
[01:18:39] travis_fold:end:test_debuginfo

---
travis_time:start:test_rustdoc
Check compiletest suite=rustdoc mode=rustdoc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:22:54] 
[01:22:54] running 304 tests
[01:24:15] ..........F.................i....................................................................... 100/304
[01:25:23] ...........................................i.........................F.............................. 200/304
[01:26:36] ......................................................................F............................. 300/304
[01:26:38] failures:
[01:26:38] 
[01:26:38] ---- [rustdoc] rustdoc/blanket-reexport-item.rs stdout ----
[01:26:38] 
[01:26:38] 
[01:26:38] error: htmldocck failed!
[01:26:38] status: exit code: 1
[01:26:38] command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/blanket-reexport-item" "/checkout/src/test/rustdoc/blanket-reexport-item.rs"
[01:26:38] ------------------------------------------
[01:26:38] 
[01:26:38] ------------------------------------------
[01:26:38] stderr:
[01:26:38] stderr:
[01:26:38] ------------------------------------------
[01:26:38] 3: @has check failed
[01:26:38]  `XPATH PATTERN` did not match
[01:26:38]  // @has foo/struct.S.html '//h3[@id="impl-Into"]//code' 'impl<T, U> Into for T'
[01:26:38] Encountered 1 errors
[01:26:38] 
[01:26:38] ------------------------------------------
[01:26:38] 
[01:26:38] 
[01:26:38] 
[01:26:38] ---- [rustdoc] rustdoc/issue-34473.rs stdout ----
[01:26:38] 
[01:26:38] error: htmldocck failed!
[01:26:38] status: exit code: 1
[01:26:38] command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/issue-34473" "/checkout/src/test/rustdoc/issue-34473.rs"
[01:26:38] ------------------------------------------
[01:26:38] 
[01:26:38] ------------------------------------------
[01:26:38] stderr:
[01:26:38] stderr:
[01:26:38] ------------------------------------------
[01:26:38] 10: @!has check failed
[01:26:38]  `PATTERN` did not match
[01:26:38]  // @!has - SomeTypeWithLongName
[01:26:38] Encountered 1 errors
[01:26:38] 
[01:26:38] ------------------------------------------
[01:26:38] 
[01:26:38] 
[01:26:38] 
[01:26:38] ---- [rustdoc] rustdoc/synthetic_auto/complex.rs stdout ----
[01:26:38] 
[01:26:38] error: htmldocck failed!
[01:26:38] status: exit code: 1
[01:26:38] command: "/usr/bin/python2.7" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/rustdoc/synthetic_auto/complex" "/checkout/src/test/rustdoc/synthetic_auto/complex.rs"
[01:26:38] ------------------------------------------
[01:26:38] 
[01:26:38] ------------------------------------------
[01:26:38] stderr:
[01:26:38] stderr:
[01:26:38] ------------------------------------------
[01:26:38] 23: @has check failed
[01:26:38]  `XPATH PATTERN` did not match
[01:26:38]  // @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'a, T, K: ?Sized> Send for NotOuter<'a, T, K> where K: for<'b> Fn((&'b bool, &'a u8)) -> &'b i8, T: MyTrait<'a>, <T as MyTrait<'a>>::MyItem: Copy, 'a: 'static"
[01:26:38] Encountered 1 errors
[01:26:38] 
[01:26:38] ------------------------------------------
[01:26:38] 
---
[01:26:38] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:517:22
[01:26:38] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:26:38] 
[01:26:38] 
[01:26:38] 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-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--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" "6.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:26:38] 
[01:26:38] 
[01:26:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:26:38] Build completed unsuccessfully in 0:20:44
[01:26:38] Build completed unsuccessfully in 0:20:44
[01:26:38] make: *** [check] Error 1
[01:26:38] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:00260b01
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Apr 23 10:04:30 UTC 2019

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)

let auto_impls = get_auto_traits_with_def_id(cx, def_id);
let blanket_impls = get_blanket_impls_with_def_id(cx, def_id);
let mut renderinfo = cx.renderinfo.borrow_mut();
// FIXME(eddyb) is this `doc(hidden)` check needed?
Copy link
Contributor

@petrochenkov petrochenkov Apr 23, 2019

Choose a reason for hiding this comment

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

Well, looks like yes in theory, but not in practice because none of the "primitive" impls is actually hidden.

Copy link
Contributor

Choose a reason for hiding this comment

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

} else {
self.impls.extend(get_auto_traits_with_def_id(self.cx, i.def_id));
self.impls.extend(get_blanket_impls_with_def_id(self.cx, i.def_id));
// FIXME(eddyb) is this `doc(hidden)` check needed?
Copy link
Contributor

Choose a reason for hiding this comment

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

My guess would be "not needed" or "needed only as optimization", if an item is hidden its impls won't be shown either way.

@petrochenkov
Copy link
Contributor

Everything looks like a reasonable simplification, but the tests are failing.

@bors
Copy link
Collaborator

bors commented Apr 28, 2019

☔ The latest upstream changes (presumably #60317) made this pull request unmergeable. Please resolve the merge conflicts.

@eddyb eddyb force-pushed the rustdoc-rm-def-ctor-hax branch from 1c5b11e to be9f43e Compare April 30, 2019 10:11
@eddyb
Copy link
Member Author

eddyb commented Apr 30, 2019

@petrochenkov I just fixed the tests (the output is now more in line with cross-crate impls in general).

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented May 1, 2019

📌 Commit be9f43e has been approved by petrochenkov

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 1, 2019
@bors
Copy link
Collaborator

bors commented May 1, 2019

⌛ Testing commit be9f43e with merge 6cc24f2...

bors added a commit that referenced this pull request May 1, 2019
rustdoc: remove def_ctor hack.

~~No longer necessary since we have `describe_def`.~~

Turns out `def_ctor` was used in conjunction with abusing `tcx.type_of(def_id)` working on both type definitions and `impl`s (specifically, of builtin types), but also reimplementing a lot of the logic that `Clean` already provides on `Ty` / `ty::TraitRef`.

The first commit now does the minimal refactor to keep it working, while the second commit contains the rest of the refactor I started (parts of which I'm not sure we need to keep).
@bors
Copy link
Collaborator

bors commented May 1, 2019

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 1, 2019
@bors bors merged commit be9f43e into rust-lang:master May 1, 2019
@eddyb eddyb deleted the rustdoc-rm-def-ctor-hax branch May 1, 2019 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants