You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cargo reports incorrect compiler-artifact path for rustdoc json #10149
When running a cargo rustdoc --message-format=json -- --output-format=json -Zunstable-options command the path reported for the final compiler-artifact message is wrong.
Steps
> cargo rustdoc --message-format=json -- --output-format=json -Zunstable-options | jq -sr 'last(.[] | select(.reason == "compiler-artifact")) | .executable' Documenting cargo-doc-tree v0.1.0 (/home/nemo157/sources/cargo-doc-tree) Finished dev [unoptimized + debuginfo] target(s) in 0.90s/home/nemo157/.cargo/shared-target/doc/cargo_doc_tree/index.html
> ls /home/nemo157/.cargo/shared-target/doc/cargo_doc_tree/index.html /home/nemo157/.cargo/shared-target/doc/cargo_doc_tree.jsonls: cannot access '/home/nemo157/.cargo/shared-target/doc/cargo_doc_tree/index.html': No such file or directory/home/nemo157/.cargo/shared-target/doc/cargo_doc_tree.json
Including the path in the "executable" field was a mistake. I have posted #10171 to fix that.
As for getting the path when using the JSON output, that is a bit tricky. Cargo doesn't use the flags passed to cargo rustdoc or cargo rustc when computing the potential outputs. Cargo probably won't ever parse those arguments, and rustdoc doesn't have a mechanism to report its outputs.
Perhaps eventually a flag for the output format could be wired directly into cargo rustdoc if the JSON output is ever stabilized.
Cargo probably won't ever parse those arguments, and rustdoc doesn't have a mechanism to report its outputs.
Perhaps eventually a flag for the output format could be wired directly into cargo rustdoc if the JSON output is ever stabilized.
I think it would be simpler to add a way for rustdoc to report its outputs; it shouldn't be too hard to do. What format does rustc use for that, something with --emit presumably?
Primarily through --print=file-names. It runs the command rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro, so that it knows the prefix and suffix of every crate type. Then there is a large amount of code for figuring out for different targets and scenarios the kind of outputs different commands generate.
Activity
Nemo157 commentedon Dec 2, 2021
Hmmm, also relevant, that was in a binary crate, in a library-only crate there is no path given in the final message.
ehuss commentedon Dec 5, 2021
Including the path in the "executable" field was a mistake. I have posted #10171 to fix that.
As for getting the path when using the JSON output, that is a bit tricky. Cargo doesn't use the flags passed to
cargo rustdocorcargo rustcwhen computing the potential outputs. Cargo probably won't ever parse those arguments, and rustdoc doesn't have a mechanism to report its outputs.Perhaps eventually a flag for the output format could be wired directly into
cargo rustdocif the JSON output is ever stabilized.jyn514 commentedon Dec 6, 2021
I think it would be simpler to add a way for rustdoc to report its outputs; it shouldn't be too hard to do. What format does rustc use for that, something with
--emitpresumably?ehuss commentedon Dec 6, 2021
Primarily through
--print=file-names. It runs the commandrustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro, so that it knows the prefix and suffix of every crate type. Then there is a large amount of code for figuring out for different targets and scenarios the kind of outputs different commands generate.Compared to rustdoc which is really basic:
cargo/src/cargo/core/compiler/context/compilation_files.rs
Lines 399 to 409 in 263b169
Cargo needs to know the outputs before it runs
rustc. rustdoc is a bit different, and I'm not sure how it could work to report the outputs.Auto merge of #10171 - ehuss:no-executable-doc, r=alexcrichton