-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make cfg imply doc(cfg) #89596
Merged
Merged
Make cfg imply doc(cfg) #89596
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
10cdbd8
Make cfg implicitly imply doc(cfg)
Nemo157 18fdd81
Allow adding a set of cfg's to hide from being implicitly doc(cfg)'d
Nemo157 0031ce3
Suppress some cfg from being shown in the stdlib docs
Nemo157 e36a370
Add test case for `doc_cfg_hide` feature gate
jyn514 56e5f61
Add `cfg_hide` to the list of known attributes
jyn514 8fac41a
Clean up code a bit:
GuillaumeGomez 09c7688
Simplify AttributesExt::cfg function and remove error emissions since…
GuillaumeGomez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![feature(doc_cfg)] | ||
|
||
#[doc(cfg(), cfg(foo, bar))] | ||
//~^ ERROR | ||
//~^^ ERROR | ||
#[doc(cfg(foo), cfg(bar))] // ok! | ||
#[doc(cfg())] //~ ERROR | ||
#[doc(cfg(foo, bar))] //~ ERROR | ||
pub fn foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error: `cfg` predicate is not specified | ||
--> $DIR/doc-cfg.rs:3:7 | ||
| | ||
LL | #[doc(cfg(), cfg(foo, bar))] | ||
| ^^^^^ | ||
|
||
error: multiple `cfg` predicates are specified | ||
--> $DIR/doc-cfg.rs:3:23 | ||
| | ||
LL | #[doc(cfg(), cfg(foo, bar))] | ||
| ^^^ | ||
|
||
error: `cfg` predicate is not specified | ||
--> $DIR/doc-cfg.rs:7:7 | ||
| | ||
LL | #[doc(cfg())] | ||
| ^^^^^ | ||
|
||
error: multiple `cfg` predicates are specified | ||
--> $DIR/doc-cfg.rs:8:16 | ||
| | ||
LL | #[doc(cfg(foo, bar))] | ||
| ^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![doc(cfg_hide(test))] | ||
//~^ ERROR `#[doc(cfg_hide)]` is experimental | ||
|
||
#[cfg(not(test))] | ||
pub fn public_fn() {} | ||
#[cfg(test)] | ||
pub fn internal_use_only() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0658]: `#[doc(cfg_hide)]` is experimental | ||
--> $DIR/feature-gate-doc_cfg_hide.rs:1:1 | ||
| | ||
LL | #![doc(cfg_hide(test))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #43781 <https://github.com/rust-lang/rust/issues/43781> for more information | ||
= help: add `#![feature(doc_cfg_hide)]` to the crate attributes to enable | ||
|
||
error: Compilation failed, aborting rustdoc | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be ignored, right, because you use single()? That doesn't seem right, either they should be ANDed or it should give a hard error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is valid and is supposed to work. I added it to ensure that rustdoc was happy with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to put it into a
rustdoc
test though. I'll do that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually already have a test for this: https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/doc-cfg.rs#L100