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

Exclude "test" from doc_auto_cfg #92856

Merged
merged 4 commits into from
Jan 21, 2022

Conversation

GuillaumeGomez
Copy link
Member

Fixes #91740.

cc @Nemo157 (you were the one suggesting this iirc)
r? @camelid

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 13, 2022
@rust-highfive
Copy link
Collaborator

Some changes occurred in clean/types.rs.

cc @camelid

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 13, 2022
@GuillaumeGomez
Copy link
Member Author

The rendered updated test looks like this:
Screenshot from 2022-01-13 15-53-33

.filter_map(|attr| match Cfg::parse_without(attr.meta_item()?, &[sym::test]) {
Ok(Some(c)) => Some(c),
_ => None,
})
.filter(|cfg| !hidden_cfg.contains(cfg))
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we just add test into the hidden_cfg?

Copy link
Member

Choose a reason for hiding this comment

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

Ah wait, that would need the other change to apply the hiding to sub-expressions rather than the expression as a whole.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, hence why I didn't. ;)

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be good to make that change first, so we don't need the extra code here specifically to handle test?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean putting test in hidden_cfg and then simply pass hidden_cfg to Cfg::parse_without instead of &[sym::test]?

Copy link
Member

Choose a reason for hiding this comment

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

Yep, something like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok!

Copy link
Member Author

Choose a reason for hiding this comment

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

@Nemo157: That won't be possible as is because cfg_hide is to hide explicitly a cfg (any(not(feature = "miri-test-libstd"), test, doctest) for example) whereas this PR is to remove any appearances of test. The goals are completely different.

Copy link
Member

Choose a reason for hiding this comment

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

Not really, test is just a very simple cfg-expression that could be hidden as more complex expressions can. As mentioned on the linked issue we can have cfg_hide hide arbitrary sub-expressions of the overall cfg. So e.g. if test is hidden any(not(test), foo) would simplify to foo, and if both test and feature = "__internal" are hidden then any(test, feature = "__internal") would simplify to nothing at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hum ok... Let me give it another try.

@camelid
Copy link
Member

camelid commented Jan 13, 2022

r? @Nemo157

@GuillaumeGomez
Copy link
Member Author

I rebased on top of master but didn't change anything else otherwise.

@GuillaumeGomez
Copy link
Member Author

@Nemo157 It now removes cfg_hide if they are inside "bigger" cfgs. Is it what you had in mind?

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@Nemo157 Nemo157 left a comment

Choose a reason for hiding this comment

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

Couple of minor things that I think could be simplified, other than that looks great to me.

r=me with those simplified

src/librustdoc/clean/types.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/cfg.rs Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

@bors: r=Nemo157

@bors
Copy link
Contributor

bors commented Jan 20, 2022

📌 Commit b0df765 has been approved by Nemo157

@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 Jan 20, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 21, 2022
…askrgr

Rollup of 17 pull requests

Successful merges:

 - rust-lang#91032 (Introduce drop range tracking to generator interior analysis)
 - rust-lang#92856 (Exclude "test" from doc_auto_cfg)
 - rust-lang#92860 (Fix errors on blanket impls by ignoring the children of generated impls)
 - rust-lang#93038 (Fix star handling in block doc comments)
 - rust-lang#93061 (Only suggest adding `!` to expressions that can be macro invocation)
 - rust-lang#93067 (rustdoc mobile: fix scroll offset when jumping to internal id)
 - rust-lang#93086 (Add tests to ensure that `let_chains` works with `if_let_guard`)
 - rust-lang#93087 (Fix src/test/run-make/raw-dylib-alt-calling-convention)
 - rust-lang#93091 (⬆ chalk to 0.76.0)
 - rust-lang#93094 (src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs`)
 - rust-lang#93098 (Show a more informative panic message when `DefPathHash` does not exist)
 - rust-lang#93099 (rustdoc: auto create output directory when "--output-format json")
 - rust-lang#93102 (Pretty printer algorithm revamp step 3)
 - rust-lang#93104 (Support --bless for pp-exact pretty printer tests)
 - rust-lang#93114 (update comment for `ensure_monomorphic_enough`)
 - rust-lang#93128 (Add script to prevent point releases with same number as existing ones)
 - rust-lang#93136 (Backport the 1.58.1 release notes to master)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 10a7204 into rust-lang:master Jan 21, 2022
@rustbot rustbot added this to the 1.60.0 milestone Jan 21, 2022
@GuillaumeGomez GuillaumeGomez deleted the exclude-test-doc_auto_cfg branch January 21, 2022 17:39
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove cfg(test) from doc_auto_cfg
7 participants