From 377346639b7d80b75de87acebb0652c69ce652d8 Mon Sep 17 00:00:00 2001 From: Michael Tang Date: Wed, 13 Nov 2019 16:21:00 -0800 Subject: [PATCH] Print entire comment line for report_todo/report_fixme (#3912) --- src/formatting.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/formatting.rs b/src/formatting.rs index 86b7cfb7dca..0433542f4eb 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -507,6 +507,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; @@ -515,11 +518,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);