Skip to content

Commit ef35ab9

Browse files
authored
Merge pull request #308 from Alexendoo/diff-missing-lines
Fix missing lines in diff output
2 parents d637120 + 27d7aa3 commit ef35ab9

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Fixed
1313

14+
* missing lines in diff output
15+
1416
### Changed
1517

1618
### Removed

src/diff.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,17 @@ fn row(row: DiffOp<'_, &str>) {
3939
skip(l);
4040
}
4141
Replace(l, r) => {
42-
for (l, r) in l.iter().zip(r) {
43-
print_line_diff(l, r);
42+
if l.len() == r.len() {
43+
for (l, r) in l.iter().zip(r) {
44+
print_line_diff(l, r);
45+
}
46+
} else {
47+
for l in l {
48+
println!("{}{}", "-".red(), l.red());
49+
}
50+
for r in r {
51+
println!("{}{}", "+".green(), r.green());
52+
}
4453
}
4554
}
4655
Insert(r) => {

tests/integrations/basic-fail/Cargo.stdout

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,8 +1229,16 @@ Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/ba
12291229
+ --> tests/actual_tests/bad_pattern.rs:1:5
12301230
|
12311231
-4 | add("42", 3);
1232-
+1 | use basic_fail::add;
12331232
- | --- ^^^^ expected `usize`, found `&str`
1233+
- | |
1234+
- | arguments to this function are incorrect
1235+
- |
1236+
-note: function defined here
1237+
- --> $DIR/tests/integrations/basic-fail/src/lib.rs:LL:CC
1238+
- |
1239+
-1 | pub fn add(left: usize, right: usize) -> usize {
1240+
- | ^^^
1241+
+1 | use basic_fail::add;
12341242
+ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail`
12351243

12361244
-error: aborting due to previous error
@@ -1350,8 +1358,14 @@ Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/fo
13501358
+ --> tests/actual_tests/foomp.rs:1:5
13511359
|
13521360
-4 | add("42", 3);
1353-
+1 | use basic_fail::add;
13541361
- | --- ^^^^ expected `usize`, found `&str`
1362+
- |
1363+
-note: function defined here
1364+
- --> $DIR/tests/integrations/basic/src/lib.rs:LL:CC
1365+
- |
1366+
-1 | pub fn add(left: usize, right: usize) -> usize {
1367+
- | ^^^ some expected text that isn't in the actual message
1368+
+1 | use basic_fail::add;
13551369
+ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail`
13561370

13571371
-error: aborting doo to previous error
@@ -1400,8 +1414,16 @@ Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/fo
14001414
+ --> tests/actual_tests/foomp2.rs:1:5
14011415
|
14021416
-4 | add("42", 3);
1403-
+1 | use basic_fail::add;
14041417
- | --- ^^^^ expected `usize`, found `&str`
1418+
- | |
1419+
- | arguments to this function are incorrect
1420+
- |
1421+
-note: function defined here
1422+
- --> $DIR/tests/integrations/basic-fail/src/lib.rs:LL:CC
1423+
- |
1424+
-1 | pub fn add(left: usize, right: usize) -> usize {
1425+
- | ^^^
1426+
+1 | use basic_fail::add;
14051427
+ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail`
14061428

14071429
-error: aborting due to previous error
@@ -1515,8 +1537,16 @@ Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/ru
15151537
+ --> tests/actual_tests/rustc_ice.rs:5:5
15161538
|
15171539
-8 | add("42", 3);
1518-
+5 | use basic_fail::add;
15191540
- | --- ^^^^ expected `usize`, found `&str`
1541+
- | |
1542+
- | arguments to this function are incorrect
1543+
- |
1544+
-note: function defined here
1545+
- --> $DIR/tests/integrations/basic-fail/src/lib.rs:LL:CC
1546+
- |
1547+
-1 | pub fn add(left: usize, right: usize) -> usize {
1548+
- | ^^^
1549+
+5 | use basic_fail::add;
15201550
+ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail`
15211551

15221552
thread 'rustc' panicked

0 commit comments

Comments
 (0)