Skip to content

Commit 3c01f64

Browse files
committed
fix: optimize per suggestion
1 parent 700c4ee commit 3c01f64

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clippy_lints/src/format_args.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@ impl<'tcx> FormatArgsExpr<'_, 'tcx> {
337337
fn check_trailing_comma(&self) {
338338
let span = self.macro_call.span;
339339
if let Some(src) = span.get_source_text(self.cx)
340-
&& !src.contains('\n')
341340
&& let Some(src) = src.strip_suffix([')', ']', '}'])
342-
&& let src = src.trim_end_matches(|c: char| c.is_whitespace())
341+
&& let src = src.trim_end_matches(|c: char| c.is_whitespace() && c != '\n')
343342
&& let Some(src) = src.strip_suffix(',')
343+
&& let src = src.trim_end_matches(|c: char| c.is_whitespace() && c != '\n')
344+
&& !src.ends_with('\n')
344345
{
345-
let src = src.trim_end_matches(|c: char| c.is_whitespace());
346346
span_lint_and_sugg(
347347
self.cx,
348348
UNNECESSARY_TRAILING_COMMA,

0 commit comments

Comments
 (0)