diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 0dfb8a52ebabd..c59dce185f4c1 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -226,30 +226,28 @@ impl Cfg { /// `Cfg`. /// /// See `tests::test_simplify_with` for examples. - pub(crate) fn simplify_with(&self, assume: &Cfg) -> Option { + pub(crate) fn simplify_with(&self, assume: &Self) -> Option { if self == assume { - return None; - } - - if let Cfg::All(a) = self { + None + } else if let Cfg::All(a) = self { let mut sub_cfgs: Vec = if let Cfg::All(b) = assume { a.iter().filter(|a| !b.contains(a)).cloned().collect() } else { a.iter().filter(|&a| a != assume).cloned().collect() }; let len = sub_cfgs.len(); - return match len { + match len { 0 => None, 1 => sub_cfgs.pop(), _ => Some(Cfg::All(sub_cfgs)), - }; - } else if let Cfg::All(b) = assume { - if b.contains(self) { - return None; } + } else if let Cfg::All(b) = assume + && b.contains(self) + { + None + } else { + Some(self.clone()) } - - Some(self.clone()) } }