mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Fix -Zdump-mir-dataflow by implementing DebugWithContext for ChunkedBitSet
This commit is contained in:
parent
cdfdb99c9e
commit
0e7d54c9e7
@ -93,8 +93,48 @@ where
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt_diff(&set_in_self, &cleared_in_self, ctxt, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T, C> DebugWithContext<C> for ChunkedBitSet<T>
|
||||||
|
where
|
||||||
|
T: Idx + DebugWithContext<C>,
|
||||||
|
{
|
||||||
|
fn fmt_with(&self, ctxt: &C, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_set().entries(self.iter().map(|i| DebugWithAdapter { this: i, ctxt })).finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fmt_diff_with(&self, old: &Self, ctxt: &C, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let size = self.domain_size();
|
||||||
|
assert_eq!(size, old.domain_size());
|
||||||
|
|
||||||
|
let mut set_in_self = HybridBitSet::new_empty(size);
|
||||||
|
let mut cleared_in_self = HybridBitSet::new_empty(size);
|
||||||
|
|
||||||
|
for i in (0..size).map(T::new) {
|
||||||
|
match (self.contains(i), old.contains(i)) {
|
||||||
|
(true, false) => set_in_self.insert(i),
|
||||||
|
(false, true) => cleared_in_self.insert(i),
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt_diff(&set_in_self, &cleared_in_self, ctxt, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fmt_diff<T, C>(
|
||||||
|
inserted: &HybridBitSet<T>,
|
||||||
|
removed: &HybridBitSet<T>,
|
||||||
|
ctxt: &C,
|
||||||
|
f: &mut fmt::Formatter<'_>,
|
||||||
|
) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Idx + DebugWithContext<C>,
|
||||||
|
{
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for idx in set_in_self.iter() {
|
for idx in inserted.iter() {
|
||||||
let delim = if first {
|
let delim = if first {
|
||||||
"\u{001f}+"
|
"\u{001f}+"
|
||||||
} else if f.alternate() {
|
} else if f.alternate() {
|
||||||
@ -110,12 +150,12 @@ where
|
|||||||
|
|
||||||
if !f.alternate() {
|
if !f.alternate() {
|
||||||
first = true;
|
first = true;
|
||||||
if !set_in_self.is_empty() && !cleared_in_self.is_empty() {
|
if !inserted.is_empty() && !removed.is_empty() {
|
||||||
write!(f, "\t")?;
|
write!(f, "\t")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx in cleared_in_self.iter() {
|
for idx in removed.iter() {
|
||||||
let delim = if first {
|
let delim = if first {
|
||||||
"\u{001f}-"
|
"\u{001f}-"
|
||||||
} else if f.alternate() {
|
} else if f.alternate() {
|
||||||
@ -130,20 +170,6 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T, C> DebugWithContext<C> for ChunkedBitSet<T>
|
|
||||||
where
|
|
||||||
T: Idx + DebugWithContext<C>,
|
|
||||||
{
|
|
||||||
fn fmt_with(&self, _ctxt: &C, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
unimplemented!("implement when/if needed");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fmt_diff_with(&self, _old: &Self, _ctxt: &C, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
unimplemented!("implement when/if needed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, C> DebugWithContext<C> for &'_ T
|
impl<T, C> DebugWithContext<C> for &'_ T
|
||||||
|
Loading…
Reference in New Issue
Block a user