From 807f29206af573d4a1ac3c870f0ebaf87f73e4c8 Mon Sep 17 00:00:00 2001 From: Chris Emerson Date: Mon, 12 Feb 2018 23:07:46 +0000 Subject: [PATCH] Update after review comments. --- Configurations.md | 2 +- rustfmt-core/src/lib.rs | 14 +++++++------- rustfmt-core/tests/lib.rs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Configurations.md b/Configurations.md index b908120d051d..4390d49d1254 100644 --- a/Configurations.md +++ b/Configurations.md @@ -1915,7 +1915,7 @@ See also: [`match_block_trailing_comma`](#match_block_trailing_comma). What Write Mode to use when none is supplied: Replace, Overwrite, Display, Diff, Coverage - **Default value**: `"Overwrite"` -- **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"`, `"Modified"` +- **Possible values**: `"Checkstyle"`, `"Coverage"`, `"Diff"`, `"Display"`, `"Overwrite"`, `"Plain"`, `"Replace"` - **Stable**: No ## `blank_lines_upper_bound` diff --git a/rustfmt-core/src/lib.rs b/rustfmt-core/src/lib.rs index e53db8a4b464..d94f2a2c12c4 100644 --- a/rustfmt-core/src/lib.rs +++ b/rustfmt-core/src/lib.rs @@ -708,8 +708,8 @@ pub fn format_input( /// and a vector of 0 or more inserted lines. #[derive(Debug, PartialEq, Eq)] pub struct ModifiedChunk { - /// The first affected line before formatting. - pub line_number: u32, + /// The first to be removed from the original text + pub line_number_orig: u32, /// The number of lines which have been replaced pub lines_removed: u32, /// The new lines @@ -756,16 +756,16 @@ pub fn get_modified_lines( .map(|s| s.parse::().unwrap()) .collect(); assert_eq!(values.len(), 3); - let line_number = values[0]; - let num_removed = values[1]; + let line_number_orig = values[0]; + let lines_removed = values[1]; let num_added = values[2]; let mut added_lines = Vec::new(); for _ in 0..num_added { added_lines.push(lines.next().unwrap().unwrap()); } chunks.push(ModifiedChunk { - line_number: line_number, - lines_removed: num_removed, + line_number_orig, + lines_removed, lines: added_lines, }); } @@ -773,7 +773,7 @@ pub fn get_modified_lines( summary: summary, filemap: filemap, report: formatreport, - modified_lines: ModifiedLines { chunks: chunks }, + modified_lines: ModifiedLines { chunks }, }) } diff --git a/rustfmt-core/tests/lib.rs b/rustfmt-core/tests/lib.rs index 6a310d175b19..3a990ebe88c5 100644 --- a/rustfmt-core/tests/lib.rs +++ b/rustfmt-core/tests/lib.rs @@ -153,12 +153,12 @@ fn modified_test() { ModifiedLines { chunks: vec![ ModifiedChunk { - line_number: 4, + line_number_orig: 4, lines_removed: 4, lines: vec!["fn blah() {}".into()], }, ModifiedChunk { - line_number: 9, + line_number_orig: 9, lines_removed: 6, lines: vec!["#[cfg(a, b)]".into(), "fn main() {}".into()], },