From 3a9269d9c7a4b43a37fb297935b998cc6de833c3 Mon Sep 17 00:00:00 2001 From: Michael Tang Date: Thu, 7 Nov 2019 18:28:22 -0800 Subject: [PATCH] Print entire comment line for report_todo/report_fixme --- src/formatting.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/formatting.rs b/src/formatting.rs index e3001559840..a60ba2dd56a 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -491,6 +491,9 @@ impl<'a> FormatLines<'a> { // Iterate over the chars in the file map. fn iterate(&mut self, text: &mut String) { + // List of TODO or FIXME issues on the current line + let mut issues_on_line = Vec::new(); + for (kind, c) in CharClasses::new(text.chars()) { if c == '\r' { continue; @@ -499,11 +502,17 @@ impl<'a> FormatLines<'a> { if self.allow_issue_seek && self.format_line { // Add warnings for bad todos/ fixmes if let Some(issue) = self.issue_seeker.inspect(c) { - self.push_err(ErrorKind::BadIssue(issue), false, false); + issues_on_line.push(issue); } } if c == '\n' { + // Accumulate TODO or FIXME issues for the rest of the line so the resulting error + // messages contain the entire comment line + for issue in issues_on_line.drain(..) { + self.push_err(ErrorKind::BadIssue(issue), false, false); + } + self.new_line(kind); } else { self.char(c, kind);