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

Crater should read the same metadata as docs.rs for doc runs #532

Closed
jyn514 opened this issue Aug 3, 2020 · 9 comments · Fixed by #543
Closed

Crater should read the same metadata as docs.rs for doc runs #532

jyn514 opened this issue Aug 3, 2020 · 9 comments · Fixed by #543

Comments

@jyn514
Copy link
Member

jyn514 commented Aug 3, 2020

There was a regression in rust-lang/rust#73566 not caught because crater didn't pass the same --feature docs as docs.rs. It would be great if crater added those features so we could catch regressions early instead of after they land.

rust-lang/rust#73566 (comment)

@jyn514
Copy link
Member Author

jyn514 commented Aug 3, 2020

To be clear - the feature request is to read [package.metadata.docs.rs], not to pass --feature docs for every crate.

@jyn514
Copy link
Member Author

jyn514 commented Aug 6, 2020

It wouldn't be too hard to separate this out of https://github.com/rust-lang/docs.rs/blob/master/src/docbuilder/metadata.rs as a library. Not sure where it should live though - maybe under rust-lang/crates-build-metadata to match https://github.com/rust-lang/crates-build-env?

@pietroalbini
Copy link
Member

pietroalbini commented Aug 9, 2020

I'd simply create a docsrs-metadata crate inside the https://github.com/rust-lang/docs.rs repository and publish it on crates.io. A minimal API for that crate could be:

pub struct Metadata {
    // Private fields
}

impl Metadata {
    pub fn discover_from_crate_root(root: &Path) -> Result<Self, Error> {}
   	pub fn parse(manifest: &str) -> Result<Self, Error> {}
    pub fn cargo_args(&self) -> Vec<String> {
        // --features, --no-default-features, --all-features
        // *NOT* --target
    }
    pub fn environment_variables(&self) -> Vec<(String, String)> {
        // RUSTFLAGS, RUSTDOCFLAGS, DOCS_RS=1
    }
    pub fn default_target(&self) -> &str {}
    pub fn additional_targets(&self) -> Vec<&str> {}
}

Crater would then depend on the crate, and take into account everything but the targets.

@jyn514
Copy link
Member Author

jyn514 commented Aug 9, 2020

Looks great! I think additional_targets should return HashSet and environment_variables should return Vec<(String, String)> so you can use set_env or something like that.

@jyn514
Copy link
Member Author

jyn514 commented Aug 9, 2020

Why wouldn't crater read the default target? e.g. winapi is an empty crate when compiled for Linux.

@pietroalbini
Copy link
Member

Because try builds don't have additional targets unless you mess with the CI config.

@jyn514
Copy link
Member Author

jyn514 commented Aug 23, 2020

Docs.rs needs to have owned strings for cargo_args() because it concatenates the features together. But then it can't return Vec<&str>. It can either return Vec<String> or Vec<Cow<str>>. The first copies, the second is annoying to work with. Which would you prefer?

@jyn514
Copy link
Member Author

jyn514 commented Aug 23, 2020

environment_variables is also painful to work with because you have to look for RUSTDOCFLAGS yourself if you want to modify it. I think I'll change it to return a struct instead.

@jyn514
Copy link
Member Author

jyn514 commented Aug 23, 2020

Oh hold on, I can just make the rustdocflags and rustflags arguments public instead. I like that better. No, that forces you to clone the metadata to add arguments.

bors added a commit that referenced this issue Oct 16, 2020
[WIP] Read docs.rs metadata when running rustdoc

Closes #532

<details><summary>Outdated errors</summary>

I'm having trouble running the test suite, so I haven't yet added a test. My idea was to have a crate that only builds successfully when you read the metadata, but I'm not sure if that would work with the way the test suite is set up.

Current errors:
```
$ cargo test minicrater -- single_thread_small --ignored --test-threads 1
[2020-09-05T02:02:04Z INFO  rustwide::cmd] running `Command { std: "/home/joshua/src/rust/crater/work/cargo-home/bin/cargo" "+stable" "install" "lazy_static", kill_on_drop: false }`
[2020-09-05T02:02:04Z INFO  rustwide::cmd] [stderr]     Updating crates.io index
[2020-09-05T02:02:04Z INFO  rustwide::cmd] [stderr] error: specified package `lazy_static v1.4.0` has no binaries
[2020-09-05T02:02:04Z ERROR crater::utils] Permission denied (os error 13)
[2020-09-05T02:02:04Z ERROR crater::utils] note: run with `RUST_BACKTRACE=1` to display a backtrace.
[2020-09-05T02:02:04Z INFO  crater] command failed
', /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/assert_cmd-0.10.1/src/assert.rs:154:13
```

</details>

Before merging, I need to publish the `docsrs-metadata` package to crates.io so crater doesn't depend on a git version.

r? `@pietroalbini` help
bors added a commit that referenced this issue Oct 19, 2020
[WIP] Read docs.rs metadata when running rustdoc

Closes #532

<details><summary>Outdated errors</summary>

I'm having trouble running the test suite, so I haven't yet added a test. My idea was to have a crate that only builds successfully when you read the metadata, but I'm not sure if that would work with the way the test suite is set up.

Current errors:
```
$ cargo test minicrater -- single_thread_small --ignored --test-threads 1
[2020-09-05T02:02:04Z INFO  rustwide::cmd] running `Command { std: "/home/joshua/src/rust/crater/work/cargo-home/bin/cargo" "+stable" "install" "lazy_static", kill_on_drop: false }`
[2020-09-05T02:02:04Z INFO  rustwide::cmd] [stderr]     Updating crates.io index
[2020-09-05T02:02:04Z INFO  rustwide::cmd] [stderr] error: specified package `lazy_static v1.4.0` has no binaries
[2020-09-05T02:02:04Z ERROR crater::utils] Permission denied (os error 13)
[2020-09-05T02:02:04Z ERROR crater::utils] note: run with `RUST_BACKTRACE=1` to display a backtrace.
[2020-09-05T02:02:04Z INFO  crater] command failed
', /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/assert_cmd-0.10.1/src/assert.rs:154:13
```

</details>

Before merging, I need to publish the `docsrs-metadata` package to crates.io so crater doesn't depend on a git version.

r? `@pietroalbini` help
bors added a commit that referenced this issue Apr 24, 2022
Add a mode for reading docs.rs metadata when running rustdoc

Closes #532

Before merging, I need to publish the `docsrs-metadata` package to crates.io so crater doesn't depend on a git version.
@bors bors closed this as completed in 4500cef Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants