Auto merge of #134703 - poliorcetics:ab/push-ovsylkzsoxku, r=GuillaumeGomez
nits: Cleanup of `librustdoc::clean::Cfg::simplify_with` r? `@GuillaumeGomez`
This commit is contained in:
commit
7c002ff9a7
1 changed files with 10 additions and 12 deletions
|
@ -226,32 +226,30 @@ 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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Not for Cfg {
|
||||
type Output = Cfg;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue