Stream: rustdoc

Topic: cargo doc for std in rust-src component


view this post on Zulip lzutao (Jan 14 2021 at 15:54):

What should I do to make cargo doc successfully run on std of rust-src component of rustup ?
I've had these errors so far:

    Checking rustc-std-workspace-alloc v1.0.0
 Documenting rustc-std-workspace-alloc v1.0.0
error[E0433]: failed to resolve: could not find `prelude` in `core`

error[E0432]: unresolved import `core::ops`
 --> /home/lzutao/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.39/src/float/mod.rs:1:5
  |
1 | use core::ops;
  |     ^^^^^^^^^ no `ops` in the root

error[E0432]: unresolved import `core::ops`
 --> /home/lzutao/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.39/src/int/mod.rs:1:5
  |
1 | use core::ops;
  |     ^^^^^^^^^ no `ops` in the root

error[E0432]: unresolved import `core::intrinsics`
 --> /home/lzutao/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.39/src/mem/mod.rs:8:11
  |
8 | use core::intrinsics::{atomic_load_unordered, atomic_store_unordered, exact_div};
  |           ^^^^^^^^^^ could not find `intrinsics` in `core`

view this post on Zulip Joshua Nelson (Jan 14 2021 at 15:55):

@lzutao I would be suprised if you can get that to work

view this post on Zulip lzutao (Jan 14 2021 at 15:56):

to be more clear: I cd to std in rust-src:

cd /home/lzutao/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std

view this post on Zulip Joshua Nelson (Jan 14 2021 at 15:56):

use x.py doc instead, or use the distributed rust-docs

view this post on Zulip Joshua Nelson (Jan 14 2021 at 15:56):

it may work from library/test but no guarantee

view this post on Zulip lzutao (Jan 14 2021 at 16:03):

./x.py doc sure will works. However I intend to run the script on CI.
./x.py seems really heavy weight. As everytime the CI needs to clone every submodules of rust, including llvm.
That is really time consuming.

There is https://github.com/rust-lang/rust/blob/7bb163095d8c751787f1449f3f3c245077f484e3/src/bootstrap/doc.rs#L408, but I don't understand the code yet.

view this post on Zulip Joshua Nelson (Jan 14 2021 at 16:04):

did you try from library/test?

view this post on Zulip Joshua Nelson (Jan 14 2021 at 16:04):

why are you running this on CI?

view this post on Zulip Joshua Nelson (Jan 14 2021 at 16:09):

@lzutao ^

view this post on Zulip lzutao (Jan 14 2021 at 16:16):

No, I have not run in test yet.

What I want to do is generating std internal doc for personal use. Three is a similar project stddr.rs ( I may not remember correctly), but I find their site is slow to access in my location.

view this post on Zulip lzutao (Jan 14 2021 at 16:17):

Maybe because they use server of Google cloud located far from my area.

view this post on Zulip Joshua Nelson (Jan 14 2021 at 16:19):

why do you specifically want to generate it? it's available from the rust-docs component

view this post on Zulip lzutao (Jan 14 2021 at 16:22):

To browse whever functions in std do Internally. Rust-docs component only covers public API.

view this post on Zulip Joshua Nelson (Jan 14 2021 at 16:22):

ah ok, that makes sense

view this post on Zulip Joshua Nelson (Jan 14 2021 at 16:22):

try library/test, I think it will work

view this post on Zulip lzutao (Jan 14 2021 at 16:22):

Thanks, I will try tomorrow.

view this post on Zulip lzutao (Jan 15 2021 at 00:52):

cargo doc failed on library/test.
I am wondering how -Z build-std flag of cargo works. Can we do the same to make cargo doc works on std ?


Last updated: Oct 21 2021 at 20:21 UTC