about summary refs log tree commit diff
path: root/src/source_file.rs
diff options
context:
space:
mode:
authorIgor Matuszewski <Xanewok@gmail.com>2019-03-01 19:20:57 +0100
committerIgor Matuszewski <Xanewok@gmail.com>2019-03-04 18:19:30 +0100
commitb3c28dba830fb7c88133a0a402f02a5dff9d0738 (patch)
tree9e9c13fa33180f6b3d9903dac3b88b3b689e452d /src/source_file.rs
parent0437bf7a7d968af885dc05931e4e7d1eaddaadbf (diff)
Expose ModifiedLines and implement parsing data from the string output
This moves `Modified{Chunks,Lines}` from `src/formatting.rs` to
`src/rustfmt_diff.rs` and reexports it in `src/lib.rs`.

With this, a conversion from `Vec<Mismatch>` to `ModifiedLines` was implemented
and now this implements complementary `Display` and `FromStr`, which
simplified the previously used `output_modified` function and which allows to
parse the raw data emitted with `EmitMode::ModifiedLines`.
Diffstat (limited to 'src/source_file.rs')
-rw-r--r--src/source_file.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/source_file.rs b/src/source_file.rs
index 5cbb01dd123..a779c4dfbe2 100644
--- a/src/source_file.rs
+++ b/src/source_file.rs
@@ -6,7 +6,7 @@ use syntax::source_map::SourceMap;
 
 use crate::checkstyle::output_checkstyle_file;
 use crate::config::{Config, EmitMode, FileName, Verbosity};
-use crate::rustfmt_diff::{make_diff, output_modified, print_diff};
+use crate::rustfmt_diff::{make_diff, print_diff, ModifiedLines};
 
 #[cfg(test)]
 use crate::formatting::FileRecord;
@@ -107,7 +107,7 @@ where
         EmitMode::ModifiedLines => {
             let mismatch = make_diff(&original_text, formatted_text, 0);
             let has_diff = !mismatch.is_empty();
-            output_modified(out, mismatch);
+            write!(out, "{}", ModifiedLines::from(mismatch))?;
             return Ok(has_diff);
         }
         EmitMode::Checkstyle => {