about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-12-07 00:09:54 +0900
committerGitHub <noreply@github.com>2019-12-07 00:09:54 +0900
commitafd9e95b8b5aee4379a2ae2be680e391a3deca08 (patch)
tree88f6b0a7f0f64937d88d9b5e1e675f4610c7933e
parent2a4f638d245569580d95d4bc25bea1d41c4d1c2f (diff)
parenta8ec6200dffc4780c68ac6726daae277198d149e (diff)
downloadrust-afd9e95b8b5aee4379a2ae2be680e391a3deca08.tar.gz
rust-afd9e95b8b5aee4379a2ae2be680e391a3deca08.zip
Rollup merge of #66959 - GuillaumeGomez:cfg-duplicates, r=eddyb
Remove potential cfgs duplicates

Fixes https://github.com/rust-lang/rust/issues/66921.

Before going any further (the issue seems to be linked to metadata as far as I can tell). Do you think this is the good place to do it or should it be done before?

r? @eddyb
-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 078948cc63b..fb2cce36831 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;
+}