about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWim Looman <git@nemo157.com>2020-08-09 13:25:18 +0200
committerWim Looman <git@nemo157.com>2020-08-09 14:19:09 +0200
commita8de713e26cb0f8e8ae4a7ecb0bf8a413b539926 (patch)
treeb8b494fcf6bd9e21cdc88791ed9688f8843589c9
parentf50f1c8e17a34ccaa0263c637e9686492b79477f (diff)
downloadrust-a8de713e26cb0f8e8ae4a7ecb0bf8a413b539926.tar.gz
rust-a8de713e26cb0f8e8ae4a7ecb0bf8a413b539926.zip
Improve rendering of crate features via doc(cfg)
-rw-r--r--src/librustdoc/clean/cfg.rs7
-rw-r--r--src/test/rustdoc/duplicate-cfg.rs10
2 files changed, 12 insertions, 5 deletions
diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs
index 53979d27052..20da28d1c5b 100644
--- a/src/librustdoc/clean/cfg.rs
+++ b/src/librustdoc/clean/cfg.rs
@@ -413,6 +413,13 @@ impl<'a> fmt::Display for Html<'a> {
                             return write!(fmt, "target feature <code>{}</code>", feat);
                         }
                     }
+                    (sym::feature, Some(feat)) => {
+                        if self.1 {
+                            return write!(fmt, "<code>{}</code>", feat);
+                        } else {
+                            return write!(fmt, "crate feature <code>{}</code>", feat);
+                        }
+                    }
                     _ => "",
                 };
                 if !human_readable.is_empty() {
diff --git a/src/test/rustdoc/duplicate-cfg.rs b/src/test/rustdoc/duplicate-cfg.rs
index 9ccc5d7882e..f6d4e9968a3 100644
--- a/src/test/rustdoc/duplicate-cfg.rs
+++ b/src/test/rustdoc/duplicate-cfg.rs
@@ -4,13 +4,13 @@
 #![feature(doc_cfg)]
 
 // @has 'foo/struct.Foo.html'
-// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" only.'
+// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync only.'
 #[doc(cfg(feature = "sync"))]
 #[doc(cfg(feature = "sync"))]
 pub struct Foo;
 
 // @has 'foo/bar/struct.Bar.html'
-// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" only.'
+// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync only.'
 #[doc(cfg(feature = "sync"))]
 pub mod bar {
     #[doc(cfg(feature = "sync"))]
@@ -18,7 +18,7 @@ pub mod bar {
 }
 
 // @has 'foo/baz/struct.Baz.html'
-// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" only.'
+// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync and crate feature send only.'
 #[doc(cfg(all(feature = "sync", feature = "send")))]
 pub mod baz {
     #[doc(cfg(feature = "sync"))]
@@ -26,7 +26,7 @@ pub mod baz {
 }
 
 // @has 'foo/qux/struct.Qux.html'
-// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" only.'
+// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync and crate feature send only.'
 #[doc(cfg(feature = "sync"))]
 pub mod qux {
     #[doc(cfg(all(feature = "sync", feature = "send")))]
@@ -34,7 +34,7 @@ pub mod qux {
 }
 
 // @has 'foo/quux/struct.Quux.html'
-// @has '-' '//*[@class="stab portability"]' 'This is supported on feature="sync" and feature="send" and foo and bar only.'
+// @has '-' '//*[@class="stab portability"]' 'This is supported on crate feature sync and crate feature send and foo and bar only.'
 #[doc(cfg(all(feature = "sync", feature = "send", foo)))]
 pub mod quux {
     #[doc(cfg(all(feature = "send", feature = "sync", bar)))]