include source_order in display_graph output

This commit is contained in:
Douglas Creager 2025-12-15 10:16:40 -05:00
parent 7f4893d200
commit d9429754b9
1 changed files with 22 additions and 14 deletions

View File

@ -1744,7 +1744,13 @@ impl<'db> Node<'db> {
Node::AlwaysTrue => write!(f, "always"),
Node::AlwaysFalse => write!(f, "never"),
Node::Interior(interior) => {
interior.constraint(self.db).display(self.db).fmt(f)?;
write!(
f,
"{} {}/{}",
interior.constraint(self.db).display(self.db),
interior.source_order(self.db),
interior.max_source_order(self.db),
)?;
// Calling display_graph recursively here causes rustc to claim that the
// expect(unused) up above is unfulfilled!
write!(
@ -3797,28 +3803,28 @@ mod tests {
#[test]
fn test_display_graph_output() {
let expected = indoc! {r#"
(T = str)
(T = bool)
(U = str)
(U = bool)
(T = str) 3/4
(T = bool) 4/4
(U = str) 1/2
(U = bool) 2/2
always
always
(U = bool)
(U = bool) 2/2
always
never
(U = str)
(U = bool)
(U = str) 1/2
(U = bool) 2/2
always
always
(U = bool)
(U = bool) 2/2
always
never
(T = bool)
(U = str)
(U = bool)
(T = bool) 4/4
(U = str) 1/2
(U = bool) 2/2
always
always
(U = bool)
(U = bool) 2/2
always
never
never
@ -3834,7 +3840,9 @@ mod tests {
let t_bool = ConstraintSet::range(&db, bool_type, t, bool_type);
let u_str = ConstraintSet::range(&db, str_type, u, str_type);
let u_bool = ConstraintSet::range(&db, bool_type, u, bool_type);
let constraints = (t_str.or(&db, || t_bool)).and(&db, || u_str.or(&db, || u_bool));
// Construct this in a different order than above to make the source_orders more
// interesting.
let constraints = (u_str.or(&db, || u_bool)).and(&db, || t_str.or(&db, || t_bool));
let actual = constraints.node.display_graph(&db, &"").to_string();
assert_eq!(actual, expected);
}