Skip to content

Commit e90f9da

Browse files
committed
Fix tests after merging with master.
1 parent c3af004 commit e90f9da

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

src/filemap.rs

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ where
168168
}
169169
}
170170
WriteMode::Modified => {
171+
let filename = filename_to_path();
171172
if let Ok((ori, fmt)) = source_and_formatted_text(text, filename, config) {
172173
let mismatch = make_diff(&ori, &fmt, 0);
173174
let has_diff = !mismatch.is_empty();

src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ pub struct ModifiedLines {
712712
pub chunks: Vec<ModifiedChunk>,
713713
}
714714

715-
716715
/// Format a file and return a `ModifiedLines` data structure describing
717716
/// the changed ranges of lines.
718717
pub fn get_modified_lines(

src/rustfmt_diff.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,18 @@ where
184184
W: Write,
185185
{
186186
for mismatch in diff {
187-
let (num_removed, num_added) = mismatch.lines.iter().fold(
188-
(0, 0),
189-
|(rem, add), line| match *line {
187+
let (num_removed, num_added) = mismatch.lines.iter().fold((0, 0), |(rem, add), line| {
188+
match *line {
190189
DiffLine::Context(_) => panic!("No Context expected"),
191190
DiffLine::Expected(_) => (rem, add + 1),
192191
DiffLine::Resulting(_) => (rem + 1, add),
193-
},
194-
);
192+
}
193+
});
195194
// Write a header with enough information to separate the modified lines.
196195
writeln!(
197196
out,
198197
"{} {} {}",
199-
mismatch.line_number_orig,
200-
num_removed,
201-
num_added
198+
mismatch.line_number_orig, num_removed, num_added
202199
).unwrap();
203200

204201
for line in mismatch.lines {
@@ -297,6 +294,7 @@ mod test {
297294
vec![
298295
Mismatch {
299296
line_number: 5,
297+
line_number_orig: 5,
300298
lines: vec![Context("five".to_owned()), Expected("".to_owned())],
301299
},
302300
]

tests/system.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ fn modified_test() {
159159
lines: vec!["fn blah() {}".into()],
160160
},
161161
ModifiedChunk {
162-
line_number: 10,
163-
lines_removed: 5,
162+
line_number: 9,
163+
lines_removed: 6,
164164
lines: vec!["#[cfg(a, b)]".into(), "fn main() {}".into()],
165165
},
166166
],

0 commit comments

Comments
 (0)