X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Fformatting.rs;h=f6daab0f487758e62c9c80bb6cf9dfca9a9f7840;hb=0437bf7a7d968af885dc05931e4e7d1eaddaadbf;hp=38440802ef2eaa9591947ad923897fc5f7f0b14d;hpb=51af19547313cc129dcccbe728ab2b9de439405f;p=rust.git diff --git a/src/formatting.rs b/src/formatting.rs index 38440802ef2..f6daab0f487 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -181,8 +181,12 @@ fn format_file( self.report .add_non_formatted_ranges(visitor.skipped_range.clone()); - self.handler - .handle_formatted_file(path, visitor.buffer.to_owned(), &mut self.report) + self.handler.handle_formatted_file( + self.parse_session.source_map(), + path, + visitor.buffer.to_owned(), + &mut self.report, + ) } } @@ -190,6 +194,7 @@ fn format_file( trait FormatHandler { fn handle_formatted_file( &mut self, + source_map: &SourceMap, path: FileName, result: String, report: &mut FormatReport, @@ -200,13 +205,14 @@ impl<'b, T: Write + 'b> FormatHandler for Session<'b, T> { // Called for each formatted file. fn handle_formatted_file( &mut self, + source_map: &SourceMap, path: FileName, result: String, report: &mut FormatReport, ) -> Result<(), ErrorKind> { if let Some(ref mut out) = self.out { - match source_file::write_file(&result, &path, out, &self.config) { - Ok(b) if b => report.add_diff(), + match source_file::write_file(Some(source_map), &path, &result, out, &self.config) { + Ok(has_diff) if has_diff => report.add_diff(), Err(e) => { // Create a new error with path_str to help users see which files failed let err_msg = format!("{}: {}", path, e); @@ -299,7 +305,7 @@ pub(crate) fn format_len(&self) -> (usize, usize) { pub(crate) type FormatErrorMap = HashMap>; -#[derive(Default, Debug)] +#[derive(Default, Debug, PartialEq)] pub(crate) struct ReportedErrors { // Encountered e.g., an IO error. pub(crate) has_operational_errors: bool,