Skip to content

Commit 684c0d2

Browse files
committed
needless_range_loop: put .enumerate() into backticks
1 parent 2f32ccf commit 684c0d2

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub(super) fn check<'tcx>(
155155
format!("the loop variable `{}` is used to index `{indexed}`", ident.name),
156156
|diag| {
157157
diag.multipart_suggestion(
158-
"consider using an iterator and enumerate()",
158+
"consider using an iterator and `.enumerate()`",
159159
vec![
160160
(pat.span, format!("({}, <item>)", ident.name)),
161161
(span, format!("{indexed}.{method}().enumerate(){method_1}{method_2}")),

tests/ui/needless_range_loop.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ error: the loop variable `i` is used to index `vec`
5454
LL | for i in 0..vec.len() {
5555
| ^^^^^^^^^^^^
5656
|
57-
help: consider using an iterator and enumerate()
57+
help: consider using an iterator and `.enumerate()`
5858
|
5959
LL - for i in 0..vec.len() {
6060
LL + for (i, <item>) in vec.iter().enumerate() {
@@ -138,7 +138,7 @@ error: the loop variable `i` is used to index `vec`
138138
LL | for i in 5..vec.len() {
139139
| ^^^^^^^^^^^^
140140
|
141-
help: consider using an iterator and enumerate()
141+
help: consider using an iterator and `.enumerate()`
142142
|
143143
LL - for i in 5..vec.len() {
144144
LL + for (i, <item>) in vec.iter().enumerate().skip(5) {
@@ -150,7 +150,7 @@ error: the loop variable `i` is used to index `vec`
150150
LL | for i in 5..10 {
151151
| ^^^^^
152152
|
153-
help: consider using an iterator and enumerate()
153+
help: consider using an iterator and `.enumerate()`
154154
|
155155
LL - for i in 5..10 {
156156
LL + for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
@@ -162,7 +162,7 @@ error: the loop variable `i` is used to index `vec`
162162
LL | for i in 0..vec.len() {
163163
| ^^^^^^^^^^^^
164164
|
165-
help: consider using an iterator and enumerate()
165+
help: consider using an iterator and `.enumerate()`
166166
|
167167
LL - for i in 0..vec.len() {
168168
LL + for (i, <item>) in vec.iter_mut().enumerate() {
@@ -174,7 +174,7 @@ error: the loop variable `i` is used to index `a`
174174
LL | for i in 0..MAX_LEN {
175175
| ^^^^^^^^^^
176176
|
177-
help: consider using an iterator and enumerate()
177+
help: consider using an iterator and `.enumerate()`
178178
|
179179
LL - for i in 0..MAX_LEN {
180180
LL + for (i, <item>) in a.iter().enumerate().take(MAX_LEN) {

0 commit comments

Comments
 (0)