diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index e009d28db68..dfcab83faee 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -200,7 +200,7 @@ impl<'a, 'tcx> Functions { Some(i) => i + 1, None => 0, }; - let end_brace_idx = match code_snippet.find('}') { + let end_brace_idx = match code_snippet.rfind('}') { Some(i) => i, None => code_snippet.len(), }; diff --git a/tests/ui/functions_maxlines.rs b/tests/ui/functions_maxlines.rs index ada35abde99..5e1ee55e010 100644 --- a/tests/ui/functions_maxlines.rs +++ b/tests/ui/functions_maxlines.rs @@ -56,6 +56,7 @@ fn good_lines() { } fn bad_lines() { + println!("Dont get confused by braces: {{}}"); println!("This is bad."); println!("This is bad."); println!("This is bad."); diff --git a/tests/ui/functions_maxlines.stderr b/tests/ui/functions_maxlines.stderr index dfa6a1cf3c5..9b0e7550cc3 100644 --- a/tests/ui/functions_maxlines.stderr +++ b/tests/ui/functions_maxlines.stderr @@ -2,7 +2,7 @@ error: This function has a large number of lines. --> $DIR/functions_maxlines.rs:58:1 | LL | / fn bad_lines() { -LL | | println!("This is bad."); +LL | | println!("Dont get confused by braces: {{}}"); LL | | println!("This is bad."); LL | | println!("This is bad."); ... |