Skip to content

Commit d2ee5df

Browse files
Rename cfg_hide into auto_cfg(hide(...)) and cfg_show into auto_cfg(show(...))
1 parent 686c7e9 commit d2ee5df

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

text/000-rustdoc-cfgs-handling.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ This RFC proposes to add the following attributes:
3939

4040
The syntax of this attribute is the same as the syntax of the [`#[cfg()]` attribute][cfg attribute] used for conditional compilation.
4141

42-
* `#![doc(cfg_hide(...))]` / `#[doc(cfg_show(...))]`
42+
* `#![doc(auto_cfg(hide(...)))]` / `#[doc(auto_cfg(show(...)))]`
4343

4444
These attributes suppress or un-suppress the `auto_cfg` behavior for a particular configuration predicate.
4545

46-
For example, `#[doc(cfg_hide(windows))]` could be used in newer versions of the [`windows` crate] to prevent the "this is supported on **windows** only" tag from being shown on every single item.
46+
For example, `#[doc(auto_cfg(hide(windows)))]` could be used in newer versions of the [`windows` crate] to prevent the "this is supported on **windows** only" tag from being shown on every single item.
4747

4848
[cfg attribute]: https://doc.rust-lang.org/reference/conditional-compilation.html
4949
[`windows` crate]: https://docs.rs/windows/latest/windows/
5050

51-
All of these attributes can be added to a module or to the crate root, and they will be inherited by the child items unless another attribute overrides it. This is why "opposite" attributes like `cfg_hide` and `cfg_show` are provided: they allow a child item to override its parent.
51+
All of these attributes can be added to a module or to the crate root, and they will be inherited by the child items unless another attribute overrides it. This is why "opposite" attributes like `auto_cfg(hide(...))` and `auto_cfg(show(...))` are provided: they allow a child item to override its parent.
5252

5353
# Reference-level explanation
5454
[reference-level-explanation]: #reference-level-explanation
@@ -101,7 +101,7 @@ This attribute has the same syntax as conditional compilation, but it only cause
101101

102102
This attribute works on modules and on items.
103103

104-
### `#[doc(cfg_hide(...))]`
104+
### `#[doc(auto_cfg(hide(...)))]`
105105

106106
This attribute is used to prevent some `cfg` to be generated in the visual markers. It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`. So in the previous example:
107107

@@ -113,13 +113,13 @@ pub mod futures {}
113113
It currently displays both `unix` and `feature = "futures-io"` into the documentation, which is not great. To prevent the `unix` cfg to ever be displayed, you can use this attribute at the crate root level:
114114

115115
```rust
116-
#![doc(cfg_hide(unix))]
116+
#![doc(auto_cfg(hide(unix)))]
117117
```
118118

119119
Or directly on a given item/module as it covers any of the item's descendants:
120120

121121
```rust
122-
#[doc(cfg_hide(unix))]
122+
#[doc(auto_cfg(hide(unix)))]
123123
#[cfg(any(unix, feature = "futures-io"))]
124124
pub mod futures {
125125
// `futures` and all its descendants won't display "unix" in their cfgs.
@@ -133,37 +133,37 @@ Rustdoc currently hides `doc` and `doctest` attributes by default and reserves t
133133
The attribute accepts only a list of identifiers or key/value items. So you can write:
134134

135135
```rust
136-
#[doc(cfg_hide(unix, doctest, feature = "something"))]
137-
#[doc(cfg_hide())]
136+
#[doc(auto_cfg(hide(unix, doctest, feature = "something")))]
137+
#[doc(auto_cfg(hide()))]
138138
```
139139

140140
But you cannot write:
141141

142142
```rust
143-
#[doc(cfg_hide(not(unix)))]
143+
#[doc(auto_cfg(hide(not(unix))))]
144144
```
145145

146-
If `cfg_show` and `cfg_hide` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example:
146+
If `cfg_auto(show(...))` and `cfg_auto(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example:
147147

148148
```rust
149-
#[doc(cfg_hide(unix))]
150-
#[doc(cfg_show(unix))] // Error!
149+
#[doc(auto_cfg(hide(unix)))]
150+
#[doc(auto_cfg(show(unix)))] // Error!
151151
pub fn foo() {}
152152
```
153153

154-
### `#[doc(cfg_show(...))]`
154+
### `#[doc(auto_cfg(show(...)))]`
155155

156-
This attribute does the opposite of `#[doc(cfg_hide(...))]`: if you used `#[doc(cfg_hide(...))]` and want to revert its effect on an item and its descendants, you can use `#[doc(cfg_show(...))]`.
156+
This attribute does the opposite of `#[doc(auto_cfg(hide(...)))]`: if you used `#[doc(auto_cfg(hide(...)))]` and want to revert its effect on an item and its descendants, you can use `#[doc(auto_cfg(show(...)))]`.
157157
It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`.
158158

159159
For example:
160160

161161
```rust
162-
#[doc(cfg_hide(unix))]
162+
#[doc(auto_cfg(hide(unix)))]
163163
#[cfg(any(unix, feature = "futures-io"))]
164164
pub mod futures {
165165
// `futures` and all its descendants won't display "unix" in their cfgs.
166-
#[doc(cfg_show(unix))]
166+
#[doc(auto_cfg(show(unix)))]
167167
pub mod child {
168168
// `child` and all its descendants will display "unix" in their cfgs.
169169
}
@@ -173,21 +173,21 @@ pub mod futures {
173173
The attribute accepts only a list of identifiers or key/value items. So you can write:
174174

175175
```rust
176-
#[doc(cfg_show(unix, doctest, feature = "something"))]
177-
#[doc(cfg_show())]
176+
#[doc(auto_cfg(show(unix, doctest, feature = "something")))]
177+
#[doc(auto_cfg(show()))]
178178
```
179179

180180
But you cannot write:
181181

182182
```rust
183-
#[doc(cfg_show(not(unix)))]
183+
#[doc(auto_cfg(show(not(unix))))]
184184
```
185185

186-
If `cfg_show` and `cfg_hide` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example:
186+
If `auto_cfg(show(...))` and `auto_cfg(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example:
187187

188188
```rust
189-
#[doc(cfg_hide(unix))]
190-
#[doc(cfg_show(unix))] // Error!
189+
#[doc(auto_cfg(hide(unix)))]
190+
#[doc(auto_cfg(show(unix)))] // Error!
191191
pub fn foo() {}
192192
```
193193

0 commit comments

Comments
 (0)