diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 078948cc63bd2633822deaf6dee0814dd8d0546e..fb2cce3683132d720f53cb3d78ceeae8025d55ed 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -209,6 +209,9 @@ fn not(self) -> 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 @@ fn bitand(mut self, other: Cfg) -> 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 0000000000000000000000000000000000000000..505d6ee769ab3040c364f7f6830cac26c405f7ac --- /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; +}