Stream: rustdoc

Topic: Cannot run custom fork of rustdoc built out-of-tree


view this post on Zulip Robin Moussu (Nov 28 2020 at 10:44):

I took librustdoc as a base, modified run_global_ctxt() to call my custom analysis.

When I run it on a single file, it works perfectly:

cargo run -- somefile.rs

However, if I try to run with cargo-doc, I get:

RUST_BACKTRACE=1 RUSTDOC=target/release/cargo-callgraph cargo doc
warning: output filename collision.
The lib target `crossbeam-utils` in package `crossbeam-utils v0.7.2` has the same output filename as the lib target `crossbeam-utils` in package `crossbeam-utils v0.6.6`.
Colliding filename is: /home/robin/dev/cargo-callgraph/target/doc/crossbeam_utils/index.html
The targets should have unique names.
This is a known bug where multiple crates with the same name use
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
 Documenting crossbeam-queue v0.1.2
error: could not document `crossbeam-queue`

Caused by:
  could not execute process `/home/robin/dev/cargo-callgraph/target/release/cargo-callgraph --crate-type lib --crate-name crossbeam_queue /home/robin/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-queue-0.1.2/src/lib.rs --cap-lints allow -o /home/robin/dev/cargo-callgraph/target/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/home/robin/dev/cargo-callgraph/target/debug/deps --extern crossbeam_utils=/home/robin/dev/cargo-callgraph/target/debug/deps/libcrossbeam_utils-dc839f467baf84df.rmeta --crate-version 0.1.2` (never executed)

Caused by:
  No such file or directory (os error 2)

I don't know how to what is the cause of the error, (cargo --verbose doc didn't help).

view this post on Zulip GuillaumeGomez (Nov 28 2020 at 12:16):

There is a way by using rustup to set where rustdoc binary is, then you use cargo +local or something along the line. Let me find it again

view this post on Zulip GuillaumeGomez (Nov 28 2020 at 12:27):

@Robin Moussu like this: rustup toolchain link local /path/to/build/$TARGET/stage1

view this post on Zulip GuillaumeGomez (Nov 28 2020 at 12:27):

then you can use cargo +local doc

view this post on Zulip Joshua Nelson (Nov 28 2020 at 12:27):

@Robin Moussu that looks like you forgot to run cargo build after a change

view this post on Zulip Joshua Nelson (Nov 28 2020 at 12:27):

@GuillaumeGomez that won't help here because the binary isn't called 'rustdoc'

view this post on Zulip GuillaumeGomez (Nov 28 2020 at 12:28):

that's what I always used to test things until now, so maybe I just didn't understand the problem XD

view this post on Zulip Joshua Nelson (Nov 28 2020 at 12:28):

Yes, what happened is Robin forked the rustdoc project and is using it to generate callgraphs, not documentation

view this post on Zulip GuillaumeGomez (Nov 28 2020 at 12:28):

Oh I see

view this post on Zulip Joshua Nelson (Nov 28 2020 at 12:29):

So he also changed the name, so cargo can't find it anymore, but he still wants to have the info from dependencies, so instead he's tricking cargo into thinking the fork is still rustdoc

view this post on Zulip Robin Moussu (Nov 28 2020 at 14:51):

It's exactly that. However I did not forgot to cargo build.

view this post on Zulip Joshua Nelson (Nov 28 2020 at 14:52):

if you run /home/robin/dev/cargo-callgraph/target/release/cargo-callgraph --help does that work?

view this post on Zulip Joshua Nelson (Nov 28 2020 at 14:56):

@Robin Moussu ^

view this post on Zulip Robin Moussu (Nov 28 2020 at 15:02):

:face_palm: I did not use the right command from my history… I only build the debug version, and though that I asked the debug version with cargo doc

view this post on Zulip Joshua Nelson (Nov 28 2020 at 15:04):

personally I use a run.sh for things like this, where literally all it does is cargo build && <the run command>

view this post on Zulip Joshua Nelson (Nov 28 2020 at 15:04):

for when cargo run isn't smart enough for what I want to do

view this post on Zulip Joshua Nelson (Nov 28 2020 at 15:04):

(deleted)

view this post on Zulip Robin Moussu (Nov 28 2020 at 15:07):

^^

view this post on Zulip Robin Moussu (Nov 28 2020 at 15:07):

anyway, this means that the original bug I had still exists :sad:

https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Issue.20with.20.60rustc_middle.3A.3Amir_built().60


Last updated: Oct 11 2021 at 22:34 UTC