Skip to content

Commit 816737b

Browse files
committed
cli: Don't show unchanged rules in set diff
1 parent 58f9d0a commit 816737b

15 files changed

+72
-786
lines changed

src/cli.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ impl CliState {
103103
&self,
104104
left: RuleOptions,
105105
right: RuleOptions,
106+
include_unchanged: bool,
106107
) -> Result<String, IncompatibleStyle> {
107108
let style = self.predicate_style;
108109
let a = &Arenas::default();
@@ -123,8 +124,10 @@ impl CliState {
123124
left = left.dimmed();
124125
right = right.dimmed();
125126
}
126-
out += &side_by_side(&left, &right);
127-
out += "\n";
127+
if has_diff || include_unchanged {
128+
out += &side_by_side(&left, &right);
129+
out += "\n";
130+
}
128131
}
129132
Ok(out)
130133
}
@@ -171,7 +174,7 @@ impl CliState {
171174
println!("The two rulesets are described by the following sets of rules, with differences highlighted.");
172175
println!("The current ruleset is on the left, and the saved one on the right.");
173176
println!();
174-
let s = self.display_joint_rules(self.options, saved).unwrap();
177+
let s = self.display_joint_rules(self.options, saved, true).unwrap();
175178
print!("{s}");
176179
}
177180
} else {
@@ -200,7 +203,9 @@ impl CliState {
200203
"The old current ruleset is on the left, and the new current one on the right."
201204
);
202205
println!();
203-
let s = self.display_joint_rules(saved, self.options).unwrap();
206+
let s = self
207+
.display_joint_rules(saved, self.options, false)
208+
.unwrap();
204209
println!("{s}");
205210
display_options_diff(saved, self.options);
206211
} else {
@@ -256,7 +261,7 @@ impl CliState {
256261
println!("The two rulesets are described by the following sets of rules, with differences highlighted.");
257262
println!("The old ruleset is on the left, and the new one on the right.");
258263
println!();
259-
match self.display_joint_rules(old_options, self.options) {
264+
match self.display_joint_rules(old_options, self.options, false) {
260265
Ok(s) => {
261266
println!("{s}");
262267
display_options_diff(old_options, self.options);

tests/snapshots/[email protected]

-56
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ Current ruleset was saved
66
The two rulesets are described by the following sets of rules, with differences highlighted.
77
The old ruleset is on the left, and the new one on the right.
88

9-
real, mp0: T0, real, mp1: T1 | real, mp0: T0, real, mp1: T1
10-
----------------------------------- "Constructor" | ----------------------------------- "Constructor"
11-
_, m ⊢ [p0, p1]: [T0, T1] | _, m ⊢ [p0, p1]: [T0, T1]
12-
139
inh, rop0: &T0, inh, rop1: &T1 |
1410
------------------------------------- "ConstructorRef" |
1511
r, m ⊢ [p0, p1]: &[T0, T1] |
@@ -34,10 +30,6 @@ The old ruleset is on the left, and the new one on the right.
3430
---------------------------- "ConstructorMultiRef" |
3531
r, m ⊢ [p0, p1]: &mut &mut T |
3632

37-
real, rop: T | real, rop: T
38-
---------------- "Deref" | ---------------- "Deref"
39-
real, m&p: &T | real, m&p: &T
40-
4133
_, rop: T |
4234
------------------------------------- "Deref" |
4335
inh, m&p: &T, T is not a reference |
@@ -50,10 +42,6 @@ The old ruleset is on the left, and the new one on the right.
5042
-------------------- "Deref" |
5143
inh, m&p: &&mut T |
5244

53-
real, mp: T | real, mp: T
54-
------------------------ "Deref" | ------------------------ "Deref"
55-
real, m&mut p: &mut T | real, m&mut p: &mut T
56-
5745
_, mp: T |
5846
--------------------------------------------- "Deref" |
5947
inh, m&mut p: &mut T, T is not a reference |
@@ -82,22 +70,6 @@ The old ruleset is on the left, and the new one on the right.
8270
------------------------ "DerefMutWithShared" |
8371
inh, m&p: &mut &mut T |
8472

85-
inh, mx: &T | inh, mx: &T
86-
------------------ "BindingBorrow" | ------------------ "BindingBorrow"
87-
real, mref x: T | real, mref x: T
88-
89-
inh, mx: &mut T | inh, mx: &mut T
90-
---------------------- "BindingBorrow" | ---------------------- "BindingBorrow"
91-
real, mref mut x: T | real, mref mut x: T
92-
93-
|
94-
----------- "Binding" | ----------- "Binding"
95-
r, mx: T | r, mx: T
96-
97-
|
98-
------------------ "Binding" | ------------------ "Binding"
99-
real, mmut x: T | real, mmut x: T
100-
10173
|
10274
------------------ "Binding" |
10375
inh, mmut x: &T |
@@ -121,10 +93,6 @@ Current and saved rulesets were swapped
12193
The two rulesets are described by the following sets of rules, with differences highlighted.
12294
The old current ruleset is on the left, and the new current one on the right.
12395

124-
real, mp0: T0, real, mp1: T1 | real, mp0: T0, real, mp1: T1
125-
----------------------------------- "Constructor" | ----------------------------------- "Constructor"
126-
_, m ⊢ [p0, p1]: [T0, T1] | _, m ⊢ [p0, p1]: [T0, T1]
127-
12896
| inh, rop0: &T0, inh, rop1: &T1
12997
| ------------------------------------- "ConstructorRef"
13098
| r, m ⊢ [p0, p1]: &[T0, T1]
@@ -149,10 +117,6 @@ The old current ruleset is on the left, and the new current one on the right.
149117
| ---------------------------- "ConstructorMultiRef"
150118
| r, m ⊢ [p0, p1]: &mut &mut T
151119

152-
real, rop: T | real, rop: T
153-
---------------- "Deref" | ---------------- "Deref"
154-
real, m&p: &T | real, m&p: &T
155-
156120
| _, rop: T
157121
| ------------------------------------- "Deref"
158122
| inh, m&p: &T, T is not a reference
@@ -165,10 +129,6 @@ The old current ruleset is on the left, and the new current one on the right.
165129
| -------------------- "Deref"
166130
| inh, m&p: &&mut T
167131

168-
real, mp: T | real, mp: T
169-
------------------------ "Deref" | ------------------------ "Deref"
170-
real, m&mut p: &mut T | real, m&mut p: &mut T
171-
172132
| _, mp: T
173133
| --------------------------------------------- "Deref"
174134
| inh, m&mut p: &mut T, T is not a reference
@@ -197,22 +157,6 @@ The old current ruleset is on the left, and the new current one on the right.
197157
| ------------------------ "DerefMutWithShared"
198158
| inh, m&p: &mut &mut T
199159

200-
inh, mx: &T | inh, mx: &T
201-
------------------ "BindingBorrow" | ------------------ "BindingBorrow"
202-
real, mref x: T | real, mref x: T
203-
204-
inh, mx: &mut T | inh, mx: &mut T
205-
---------------------- "BindingBorrow" | ---------------------- "BindingBorrow"
206-
real, mref mut x: T | real, mref mut x: T
207-
208-
|
209-
----------- "Binding" | ----------- "Binding"
210-
r, mx: T | r, mx: T
211-
212-
|
213-
------------------ "Binding" | ------------------ "Binding"
214-
real, mmut x: T | real, mmut x: T
215-
216160
|
217161
| ------------------ "Binding"
218162
| inh, mmut x: &T

0 commit comments

Comments
 (0)