Skip to content

Commit

Permalink
Auto merge of rust-lang#134703 - poliorcetics:ab/push-ovsylkzsoxku, r…
Browse files Browse the repository at this point in the history
…=GuillaumeGomez

nits: Cleanup of `librustdoc::clean::Cfg::simplify_with`

r? `@GuillaumeGomez`
  • Loading branch information
bors committed Dec 25, 2024
2 parents 97a56fb + 8cf09c7 commit 7c002ff
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,30 +226,28 @@ impl Cfg {
/// `Cfg`.
///
/// See `tests::test_simplify_with` for examples.
pub(crate) fn simplify_with(&self, assume: &Cfg) -> Option<Cfg> {
pub(crate) fn simplify_with(&self, assume: &Self) -> Option<Self> {
if self == assume {
return None;
}

if let Cfg::All(a) = self {
None
} else if let Cfg::All(a) = self {
let mut sub_cfgs: Vec<Cfg> = 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())
}
}

Expand Down

0 comments on commit 7c002ff

Please sign in to comment.