mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-09-21 07:01:54 +00:00
Change explicit_counter_loop's message to reflect original variable name
This commit is contained in:
parent
c7d4445086
commit
bd6c2df066
2 changed files with 8 additions and 6 deletions
|
@ -777,7 +777,7 @@ fn check_for_loop<'a, 'tcx>(
|
||||||
check_for_loop_range(cx, pat, arg, body, expr);
|
check_for_loop_range(cx, pat, arg, body, expr);
|
||||||
check_for_loop_reverse_range(cx, arg, expr);
|
check_for_loop_reverse_range(cx, arg, expr);
|
||||||
check_for_loop_arg(cx, pat, arg, expr);
|
check_for_loop_arg(cx, pat, arg, expr);
|
||||||
check_for_loop_explicit_counter(cx, arg, body, expr);
|
check_for_loop_explicit_counter(cx, pat, arg, body, expr);
|
||||||
check_for_loop_over_map_kv(cx, pat, arg, body, expr);
|
check_for_loop_over_map_kv(cx, pat, arg, body, expr);
|
||||||
check_for_mut_range_bound(cx, arg, body);
|
check_for_mut_range_bound(cx, arg, body);
|
||||||
detect_manual_memcpy(cx, pat, arg, body, expr);
|
detect_manual_memcpy(cx, pat, arg, body, expr);
|
||||||
|
@ -1453,6 +1453,7 @@ fn check_arg_type(cx: &LateContext<'_, '_>, pat: &Pat, arg: &Expr) {
|
||||||
|
|
||||||
fn check_for_loop_explicit_counter<'a, 'tcx>(
|
fn check_for_loop_explicit_counter<'a, 'tcx>(
|
||||||
cx: &LateContext<'a, 'tcx>,
|
cx: &LateContext<'a, 'tcx>,
|
||||||
|
pat: &'tcx Pat,
|
||||||
arg: &'tcx Expr,
|
arg: &'tcx Expr,
|
||||||
body: &'tcx Expr,
|
body: &'tcx Expr,
|
||||||
expr: &'tcx Expr,
|
expr: &'tcx Expr,
|
||||||
|
@ -1495,8 +1496,9 @@ fn check_for_loop_explicit_counter<'a, 'tcx>(
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!(
|
&format!(
|
||||||
"the variable `{0}` is used as a loop counter. Consider using `for ({0}, \
|
"the variable `{0}` is used as a loop counter. Consider using `for ({0}, \
|
||||||
item) in {1}.enumerate()` or similar iterators",
|
{1}) in {2}.enumerate()` or similar iterators",
|
||||||
name,
|
name,
|
||||||
|
snippet(cx, pat.span, "_"),
|
||||||
snippet(cx, arg.span, "_")
|
snippet(cx, arg.span, "_")
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
|
error: the variable `_index` is used as a loop counter. Consider using `for (_index, _v) in &vec.enumerate()` or similar iterators
|
||||||
--> $DIR/explicit_counter_loop.rs:6:15
|
--> $DIR/explicit_counter_loop.rs:6:15
|
||||||
|
|
|
|
||||||
LL | for _v in &vec {
|
LL | for _v in &vec {
|
||||||
|
@ -6,19 +6,19 @@ LL | for _v in &vec {
|
||||||
|
|
|
|
||||||
= note: `-D clippy::explicit-counter-loop` implied by `-D warnings`
|
= note: `-D clippy::explicit-counter-loop` implied by `-D warnings`
|
||||||
|
|
||||||
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
|
error: the variable `_index` is used as a loop counter. Consider using `for (_index, _v) in &vec.enumerate()` or similar iterators
|
||||||
--> $DIR/explicit_counter_loop.rs:12:15
|
--> $DIR/explicit_counter_loop.rs:12:15
|
||||||
|
|
|
|
||||||
LL | for _v in &vec {
|
LL | for _v in &vec {
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators
|
error: the variable `count` is used as a loop counter. Consider using `for (count, ch) in text.chars().enumerate()` or similar iterators
|
||||||
--> $DIR/explicit_counter_loop.rs:51:19
|
--> $DIR/explicit_counter_loop.rs:51:19
|
||||||
|
|
|
|
||||||
LL | for ch in text.chars() {
|
LL | for ch in text.chars() {
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators
|
error: the variable `count` is used as a loop counter. Consider using `for (count, ch) in text.chars().enumerate()` or similar iterators
|
||||||
--> $DIR/explicit_counter_loop.rs:62:19
|
--> $DIR/explicit_counter_loop.rs:62:19
|
||||||
|
|
|
|
||||||
LL | for ch in text.chars() {
|
LL | for ch in text.chars() {
|
||||||
|
|
Loading…
Reference in a new issue