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

Do not supply --crate-version flag to rustdoc if present in RUSTDOCFLAGS #8014

Merged
merged 1 commit into from
Mar 18, 2020

Conversation

aleksator
Copy link
Contributor

Checks for the flag in extra compiler arguments as well

@rust-highfive
Copy link

r? @ehuss

(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 Mar 17, 2020
Comment on lines 647 to 649
fn crate_versions_requested(bcx: &BuildContext<'_, '_>) -> bool {
bcx.config.cli_unstable().crate_versions
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this necessarily needs to be a separate function, I think it would be best just to put the check inline. I can appreciate having the function names clearly express what is being done, but wrapping single expressions like this tends to significantly increase the total lines of code.

fn crate_version_flag_in_rustdocflags(bcx: &BuildContext<'_, '_>, unit: &Unit<'_>) -> bool {
bcx.rustdocflags_args(unit)
.iter()
.any(|flag| flag == RUSTDOC_CRATE_VERSION_FLAG)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these checks will need to be starts_with since you can have something like --crate-version=foo.

Comment on lines 1572 to 1576
let mut doc_html = String::new();
File::open(&doc_file)
.unwrap()
.read_to_string(&mut doc_html)
.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let mut doc_html = String::new();
File::open(&doc_file)
.unwrap()
.read_to_string(&mut doc_html)
.unwrap();
let doc_html = fs::read_to_string(&doc_file).unwrap();

}

#[cargo_test]
fn crate_versions_flag_is_overridden_by_rustdoc_extra_arguments() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is necessary to define a whole separate test. To avoid the repetition, at the bottom of the other test, call p.build_dir().rm_rf(); and then p.cargo("rustdoc …"), and then check the results again (can maybe put the asserts in a closure so they aren't repeated).

Comment on lines 640 to 641
&& !crate_version_flag_in_rustdocflags(bcx, unit)
&& !crate_version_flag_in_extra_args(bcx, unit)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking it might be a little simpler just to check the args of the ProcessBuilder instead of re-fetching the extra args/rustdocflags.

So, move the call to add_crate_versions_if_requested after the args are added to the builder, and call something like this:

rustdoc.get_args().iter().any(|flag| {
    flag.to_str().map_or(false, |s| s.starts_with(RUSTDOC_CRATE_VERSION_FLAG))
})

@aleksator aleksator force-pushed the crate_version_in_rustdocflags branch from 010f77f to 3c11603 Compare March 18, 2020 08:52
@aleksator
Copy link
Contributor Author

Applied the suggestions as separate commits for easier reviewing, will squash after approval

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Thanks! Go ahead and squash! 😄

@aleksator aleksator force-pushed the crate_version_in_rustdocflags branch from 3c11603 to c9e3141 Compare March 18, 2020 18:27
@ehuss
Copy link
Contributor

ehuss commented Mar 18, 2020

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 18, 2020

📌 Commit c9e3141 has been approved by ehuss

@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 Mar 18, 2020
@bors
Copy link
Collaborator

bors commented Mar 18, 2020

⌛ Testing commit c9e3141 with merge 526aacc...

@bors
Copy link
Collaborator

bors commented Mar 18, 2020

☀️ Test successful - checks-azure
Approved by: ehuss
Pushing 526aacc to master...

@bors bors merged commit 526aacc into rust-lang:master Mar 18, 2020
@aleksator aleksator deleted the crate_version_in_rustdocflags branch March 18, 2020 19:41
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 25, 2020
Update cargo.

8 commits in 7019b3ed3d539db7429d10a343b69be8c426b576..8a0d4d9c9abc74fd670353094387d62028b40ae9
2020-03-17 21:02:00 +0000 to 2020-03-24 17:57:04 +0000
- Re-implement proc-macro feature decoupling. (rust-lang/cargo#8028)
- Remove unused transitive dependencies: miniz_oxide, adler32 (rust-lang/cargo#8023)
- Fix bug with -Zfeatures=dev_dep and `check --profile=test`. (rust-lang/cargo#8027)
- Remove Config from CompileOptions. (rust-lang/cargo#8021)
- Add `rustless.org` to documented blocklist. (rust-lang/cargo#7922)
- Print colored warnings when build script panics (rust-lang/cargo#8017)
- Do not supply --crate-version flag to rustdoc if present in RUSTDOCFLAGS (rust-lang/cargo#8014)
- Add proc-macro to index, and new feature resolver. (rust-lang/cargo#8003)
Centril added a commit to Centril/rust that referenced this pull request Mar 26, 2020
Update cargo.

8 commits in 7019b3ed3d539db7429d10a343b69be8c426b576..8a0d4d9c9abc74fd670353094387d62028b40ae9
2020-03-17 21:02:00 +0000 to 2020-03-24 17:57:04 +0000
- Re-implement proc-macro feature decoupling. (rust-lang/cargo#8028)
- Remove unused transitive dependencies: miniz_oxide, adler32 (rust-lang/cargo#8023)
- Fix bug with -Zfeatures=dev_dep and `check --profile=test`. (rust-lang/cargo#8027)
- Remove Config from CompileOptions. (rust-lang/cargo#8021)
- Add `rustless.org` to documented blocklist. (rust-lang/cargo#7922)
- Print colored warnings when build script panics (rust-lang/cargo#8017)
- Do not supply --crate-version flag to rustdoc if present in RUSTDOCFLAGS (rust-lang/cargo#8014)
- Add proc-macro to index, and new feature resolver. (rust-lang/cargo#8003)
@ehuss ehuss added this to the 1.44.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

4 participants