Skip to content

Commit 3cecdc9

Browse files
committed
Auto merge of rust-lang#6009 - Ryan1729:show-line_count-and-max_lines-in-too_many_lines-lint-message, r=phansch
Show line count and max lines in too_many_lines lint message This PR adds the current amount of lines and the current maximum number of lines in the message for the `too_many_lines` lint, in a similar way as the `too_many_arguments` lint currently does. changelog: show the line count and the maximum lines in the message for the `too_many_lines` lint.
2 parents f253dd0 + 9e7ce9d commit 3cecdc9

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

clippy_lints/src/functions.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ impl<'tcx> Functions {
374374
}
375375

376376
if line_count > self.max_lines {
377-
span_lint(cx, TOO_MANY_LINES, span, "this function has a large number of lines")
377+
span_lint(
378+
cx,
379+
TOO_MANY_LINES,
380+
span,
381+
&format!("this function has too many lines ({}/{})", line_count, self.max_lines),
382+
)
378383
}
379384
}
380385

tests/ui-toml/functions_maxlines/test.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: this function has a large number of lines
1+
error: this function has too many lines (2/1)
22
--> $DIR/test.rs:18:1
33
|
44
LL | / fn too_many_lines() {
@@ -9,7 +9,7 @@ LL | | }
99
|
1010
= note: `-D clippy::too-many-lines` implied by `-D warnings`
1111

12-
error: this function has a large number of lines
12+
error: this function has too many lines (2/1)
1313
--> $DIR/test.rs:38:1
1414
|
1515
LL | / fn comment_before_code() {

tests/ui/functions_maxlines.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: this function has a large number of lines
1+
error: this function has too many lines (102/100)
22
--> $DIR/functions_maxlines.rs:58:1
33
|
44
LL | / fn bad_lines() {

0 commit comments

Comments
 (0)