Skip to content

Commit 763611b

Browse files
authored
Merge pull request #18 from dtolnay/cfgdoc
Update for stable cfg(doc)
2 parents 305c9b4 + cebfe81 commit 763611b

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

readonly-fields/README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,26 +207,18 @@ field were declared `pub`.
207207

208208
### Third attempt
209209

210-
We can use `#[cfg(rustdoc)]` to distinguish when documentation is being
211-
rendered, though this cfg is currently available on nightly only. The tracking
212-
issue is [rust-lang/rust#43781].
210+
We can use [`#[cfg(doc)]`][cfgdoc] to distinguish when documentation is being
211+
rendered, which is available since Rust 1.41.
213212

214-
[rust-lang/rust#43781]: https://github.com/rust-lang/rust/issues/43781
215-
216-
I ended up using a Cargo config to have rustdoc pass some different cfg.
217-
218-
```toml
219-
[build]
220-
rustdocflags = ["--cfg", "oqueue_docs"]
221-
```
213+
[cfgdoc]: https://doc.rust-lang.org/1.67.0/rustdoc/advanced-features.html#cfgdoc-documenting-platform-specific-or-feature-specific-information
222214

223215
```rust
224216
#[repr(C)]
225217
pub struct Task {
226-
#[cfg(oqueue_docs)]
218+
#[cfg(doc)]
227219
pub index: usize,
228220

229-
#[cfg(not(oqueue_docs))]
221+
#[cfg(not(doc))]
230222
index: usize,
231223

232224
// other private fields
@@ -273,7 +265,7 @@ the behavior as an attribute macro][readonly] is the easy part:
273265

274266
```rust
275267
/// ...
276-
#[readonly::make(doc = oqueue_docs)]
268+
#[readonly::make]
277269
pub struct Task {
278270
/// ...
279271
///

readonly-fields/demo/.cargo/config.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

readonly-fields/demo/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ mod oqueue {
66
#[derive(Default)]
77
#[repr(C)]
88
pub struct Task {
9-
#[cfg(oqueue_docs)]
9+
#[cfg(doc)]
1010
pub index: usize,
1111

12-
#[cfg(not(oqueue_docs))]
12+
#[cfg(not(doc))]
1313
index: usize,
1414

1515
// Other private fields:

0 commit comments

Comments
 (0)