Skip to content

Commit a8de713

Browse files
committed
Improve rendering of crate features via doc(cfg)
1 parent f50f1c8 commit a8de713

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/librustdoc/clean/cfg.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@ impl<'a> fmt::Display for Html<'a> {
413413
return write!(fmt, "target feature <code>{}</code>", feat);
414414
}
415415
}
416+
(sym::feature, Some(feat)) => {
417+
if self.1 {
418+
return write!(fmt, "<code>{}</code>", feat);
419+
} else {
420+
return write!(fmt, "crate feature <code>{}</code>", feat);
421+
}
422+
}
416423
_ => "",
417424
};
418425
if !human_readable.is_empty() {

src/test/rustdoc/duplicate-cfg.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@
44
#![feature(doc_cfg)]
55

66
// @has 'foo/struct.Foo.html'
7-
// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" only.'
7+
// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync only.'
88
#[doc(cfg(feature = "sync"))]
99
#[doc(cfg(feature = "sync"))]
1010
pub struct Foo;
1111

1212
// @has 'foo/bar/struct.Bar.html'
13-
// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" only.'
13+
// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync only.'
1414
#[doc(cfg(feature = "sync"))]
1515
pub mod bar {
1616
#[doc(cfg(feature = "sync"))]
1717
pub struct Bar;
1818
}
1919

2020
// @has 'foo/baz/struct.Baz.html'
21-
// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" only.'
21+
// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync and crate feature send only.'
2222
#[doc(cfg(all(feature = "sync", feature = "send")))]
2323
pub mod baz {
2424
#[doc(cfg(feature = "sync"))]
2525
pub struct Baz;
2626
}
2727

2828
// @has 'foo/qux/struct.Qux.html'
29-
// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" only.'
29+
// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync and crate feature send only.'
3030
#[doc(cfg(feature = "sync"))]
3131
pub mod qux {
3232
#[doc(cfg(all(feature = "sync", feature = "send")))]
3333
pub struct Qux;
3434
}
3535

3636
// @has 'foo/quux/struct.Quux.html'
37-
// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" and foo and bar only.'
37+
// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync and crate feature send and foo and bar only.'
3838
#[doc(cfg(all(feature = "sync", feature = "send", foo)))]
3939
pub mod quux {
4040
#[doc(cfg(all(feature = "send", feature = "sync", bar)))]

0 commit comments

Comments
 (0)