Make cfg implicitly imply doc(cfg)

This is only active when the `doc_cfg` feature is active.

The implicit cfg can be overridden via #[doc(cfg(...))], so e.g. to
hide a #[cfg] you can use something like:

```rust
 #[cfg(unix)]
 #[doc(cfg(all()))]
pub struct Unix;
```

(since `all()` is always true, it is never shown in the docs)
This commit is contained in:
Wim Looman 2020-11-03 19:45:16 +01:00 committed by Guillaume Gomez
parent 074f63648b
commit 10cdbd847f
8 changed files with 92 additions and 9 deletions

View file

@ -323,7 +323,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
let import_item = clean::Item {
def_id: import_def_id.into(),
attrs: import_attrs,
cfg: ast_attrs.cfg(cx.sess()),
cfg: ast_attrs.cfg(cx.tcx()),
..myitem.clone()
};