about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2019-12-03 18:07:00 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2019-12-04 11:53:33 +0100
commita8ec6200dffc4780c68ac6726daae277198d149e (patch)
tree8a2c444b106994d0e493b473f09627f3e0653445
parent8f1bbd69e13c9e04a4c2b75612bc0c31af972439 (diff)
downloadrust-a8ec6200dffc4780c68ac6726daae277198d149e.tar.gz
rust-a8ec6200dffc4780c68ac6726daae277198d149e.zip
Remove potential cfgs duplicates
-rw-r--r--src/librustdoc/clean/cfg.rs6
-rw-r--r--src/test/rustdoc/duplicate-cfg.rs15
2 files changed, 21 insertions, 0 deletions
diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs
index 09f4873967e..2ac26c29382 100644
--- a/src/librustdoc/clean/cfg.rs
+++ b/src/librustdoc/clean/cfg.rs
@@ -209,6 +209,9 @@ impl ops::Not for Cfg {
 
 impl ops::BitAndAssign for Cfg {
     fn bitand_assign(&mut self, other: Cfg) {
+        if *self == other {
+            return;
+        }
         match (self, other) {
             (&mut Cfg::False, _) | (_, Cfg::True) => {},
             (s, Cfg::False) => *s = Cfg::False,
@@ -238,6 +241,9 @@ impl ops::BitAnd for Cfg {
 
 impl ops::BitOrAssign for Cfg {
     fn bitor_assign(&mut self, other: Cfg) {
+        if *self == other {
+            return;
+        }
         match (self, other) {
             (&mut Cfg::True, _) | (_, Cfg::False) => {},
             (s, Cfg::True) => *s = Cfg::True,
diff --git a/src/test/rustdoc/duplicate-cfg.rs b/src/test/rustdoc/duplicate-cfg.rs
new file mode 100644
index 00000000000..505d6ee769a
--- /dev/null
+++ b/src/test/rustdoc/duplicate-cfg.rs
@@ -0,0 +1,15 @@
+#![crate_name = "foo"]
+#![feature(doc_cfg)]
+
+// @has 'foo/index.html'
+// @!has '-' '//*[@class="stab portability"]' 'feature="sync" and'
+// @has '-' '//*[@class="stab portability"]' 'feature="sync"'
+#[doc(cfg(feature = "sync"))]
+#[doc(cfg(feature = "sync"))]
+pub struct Foo;
+
+#[doc(cfg(feature = "sync"))]
+pub mod bar {
+    #[doc(cfg(feature = "sync"))]
+    pub struct Bar;
+}