Skip to content

Commit

Permalink
cli: Don't show unchanged rules in set diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Jan 2, 2025
1 parent 58f9d0a commit 816737b
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 786 deletions.
15 changes: 10 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl CliState {
&self,
left: RuleOptions,
right: RuleOptions,
include_unchanged: bool,
) -> Result<String, IncompatibleStyle> {
let style = self.predicate_style;
let a = &Arenas::default();
Expand All @@ -123,8 +124,10 @@ impl CliState {
left = left.dimmed();
right = right.dimmed();
}
out += &side_by_side(&left, &right);
out += "\n";
if has_diff || include_unchanged {
out += &side_by_side(&left, &right);
out += "\n";
}
}
Ok(out)
}
Expand Down Expand Up @@ -171,7 +174,7 @@ impl CliState {
println!("The two rulesets are described by the following sets of rules, with differences highlighted.");
println!("The current ruleset is on the left, and the saved one on the right.");
println!();
let s = self.display_joint_rules(self.options, saved).unwrap();
let s = self.display_joint_rules(self.options, saved, true).unwrap();
print!("{s}");
}
} else {
Expand Down Expand Up @@ -200,7 +203,9 @@ impl CliState {
"The old current ruleset is on the left, and the new current one on the right."
);
println!();
let s = self.display_joint_rules(saved, self.options).unwrap();
let s = self
.display_joint_rules(saved, self.options, false)
.unwrap();
println!("{s}");
display_options_diff(saved, self.options);
} else {
Expand Down Expand Up @@ -256,7 +261,7 @@ impl CliState {
println!("The two rulesets are described by the following sets of rules, with differences highlighted.");
println!("The old ruleset is on the left, and the new one on the right.");
println!();
match self.display_joint_rules(old_options, self.options) {
match self.display_joint_rules(old_options, self.options, false) {
Ok(s) => {
println!("{s}");
display_options_diff(old_options, self.options);
Expand Down
56 changes: 0 additions & 56 deletions tests/snapshots/trace_cli@10939586865865297633.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ Current ruleset was saved
The two rulesets are described by the following sets of rules, with differences highlighted.
The old ruleset is on the left, and the new one on the right.

real, mp0: T0, real, mp1: T1 | real, mp0: T0, real, mp1: T1
----------------------------------- "Constructor" | ----------------------------------- "Constructor"
_, m ⊢ [p0, p1]: [T0, T1] | _, m ⊢ [p0, p1]: [T0, T1]

inh, rop0: &T0, inh, rop1: &T1 |
------------------------------------- "ConstructorRef" |
r, m ⊢ [p0, p1]: &[T0, T1] |
Expand All @@ -34,10 +30,6 @@ The old ruleset is on the left, and the new one on the right.
---------------------------- "ConstructorMultiRef" |
r, m ⊢ [p0, p1]: &mut &mut T |

real, rop: T | real, rop: T
---------------- "Deref" | ---------------- "Deref"
real, m&p: &T | real, m&p: &T

_, rop: T |
------------------------------------- "Deref" |
inh, m&p: &T, T is not a reference |
Expand All @@ -50,10 +42,6 @@ The old ruleset is on the left, and the new one on the right.
-------------------- "Deref" |
inh, m&p: &&mut T |

real, mp: T | real, mp: T
------------------------ "Deref" | ------------------------ "Deref"
real, m&mut p: &mut T | real, m&mut p: &mut T

_, mp: T |
--------------------------------------------- "Deref" |
inh, m&mut p: &mut T, T is not a reference |
Expand Down Expand Up @@ -82,22 +70,6 @@ The old ruleset is on the left, and the new one on the right.
------------------------ "DerefMutWithShared" |
inh, m&p: &mut &mut T |

inh, mx: &T | inh, mx: &T
------------------ "BindingBorrow" | ------------------ "BindingBorrow"
real, mref x: T | real, mref x: T

inh, mx: &mut T | inh, mx: &mut T
---------------------- "BindingBorrow" | ---------------------- "BindingBorrow"
real, mref mut x: T | real, mref mut x: T

|
----------- "Binding" | ----------- "Binding"
r, mx: T | r, mx: T

|
------------------ "Binding" | ------------------ "Binding"
real, mmut x: T | real, mmut x: T

|
------------------ "Binding" |
inh, mmut x: &T |
Expand All @@ -121,10 +93,6 @@ Current and saved rulesets were swapped
The two rulesets are described by the following sets of rules, with differences highlighted.
The old current ruleset is on the left, and the new current one on the right.

real, mp0: T0, real, mp1: T1 | real, mp0: T0, real, mp1: T1
----------------------------------- "Constructor" | ----------------------------------- "Constructor"
_, m ⊢ [p0, p1]: [T0, T1] | _, m ⊢ [p0, p1]: [T0, T1]

| inh, rop0: &T0, inh, rop1: &T1
| ------------------------------------- "ConstructorRef"
| r, m ⊢ [p0, p1]: &[T0, T1]
Expand All @@ -149,10 +117,6 @@ The old current ruleset is on the left, and the new current one on the right.
| ---------------------------- "ConstructorMultiRef"
| r, m ⊢ [p0, p1]: &mut &mut T

real, rop: T | real, rop: T
---------------- "Deref" | ---------------- "Deref"
real, m&p: &T | real, m&p: &T

| _, rop: T
| ------------------------------------- "Deref"
| inh, m&p: &T, T is not a reference
Expand All @@ -165,10 +129,6 @@ The old current ruleset is on the left, and the new current one on the right.
| -------------------- "Deref"
| inh, m&p: &&mut T

real, mp: T | real, mp: T
------------------------ "Deref" | ------------------------ "Deref"
real, m&mut p: &mut T | real, m&mut p: &mut T

| _, mp: T
| --------------------------------------------- "Deref"
| inh, m&mut p: &mut T, T is not a reference
Expand Down Expand Up @@ -197,22 +157,6 @@ The old current ruleset is on the left, and the new current one on the right.
| ------------------------ "DerefMutWithShared"
| inh, m&p: &mut &mut T

inh, mx: &T | inh, mx: &T
------------------ "BindingBorrow" | ------------------ "BindingBorrow"
real, mref x: T | real, mref x: T

inh, mx: &mut T | inh, mx: &mut T
---------------------- "BindingBorrow" | ---------------------- "BindingBorrow"
real, mref mut x: T | real, mref mut x: T

|
----------- "Binding" | ----------- "Binding"
r, mx: T | r, mx: T

|
------------------ "Binding" | ------------------ "Binding"
real, mmut x: T | real, mmut x: T

|
| ------------------ "Binding"
| inh, mmut x: &T
Expand Down
Loading

0 comments on commit 816737b

Please sign in to comment.