Skip to content

Commit d5d2189

Browse files
committed
rename lint to char_indices_as_byte_indices
1 parent 32cf884 commit d5d2189

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5516,8 +5516,8 @@ Released 2018-09-13
55165516
[`cast_slice_different_sizes`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_different_sizes
55175517
[`cast_slice_from_raw_parts`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts
55185518
[`cfg_not_test`]: https://rust-lang.github.io/rust-clippy/master/index.html#cfg_not_test
5519+
[`char_indices_as_byte_indices`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_indices_as_byte_indices
55195520
[`char_lit_as_u8`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_lit_as_u8
5520-
[`chars_enumerate_for_byte_indices`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_enumerate_for_byte_indices
55215521
[`chars_last_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
55225522
[`chars_next_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
55235523
[`checked_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
287287
crate::literal_representation::UNREADABLE_LITERAL_INFO,
288288
crate::literal_representation::UNUSUAL_BYTE_GROUPINGS_INFO,
289289
crate::literal_string_with_formatting_args::LITERAL_STRING_WITH_FORMATTING_ARGS_INFO,
290-
crate::loops::CHARS_ENUMERATE_FOR_BYTE_INDICES_INFO,
290+
crate::loops::CHAR_INDICES_AS_BYTE_INDICES_INFO,
291291
crate::loops::EMPTY_LOOP_INFO,
292292
crate::loops::EXPLICIT_COUNTER_LOOP_INFO,
293293
crate::loops::EXPLICIT_INTO_ITER_LOOP_INFO,

clippy_lints/src/loops/chars_enumerate_for_byte_indices.rs renamed to clippy_lints/src/loops/char_indices_as_byte_indices.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_lint::LateContext;
1010
use rustc_middle::ty::Ty;
1111
use rustc_span::{Span, sym};
1212

13-
use super::CHARS_ENUMERATE_FOR_BYTE_INDICES;
13+
use super::CHAR_INDICES_AS_BYTE_INDICES;
1414

1515
// The list of `str` methods we want to lint that have a `usize` argument representing a byte index.
1616
// Note: `String` also has methods that work with byte indices,
@@ -101,7 +101,7 @@ fn check_index_usage<'tcx>(
101101

102102
span_lint_hir_and_then(
103103
cx,
104-
CHARS_ENUMERATE_FOR_BYTE_INDICES,
104+
CHAR_INDICES_AS_BYTE_INDICES,
105105
expr.hir_id,
106106
expr.span,
107107
message,

clippy_lints/src/loops/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mod chars_enumerate_for_byte_indices;
1+
mod char_indices_as_byte_indices;
22
mod empty_loop;
33
mod explicit_counter_loop;
44
mod explicit_into_iter_loop;
@@ -779,7 +779,7 @@ declare_clippy_lint! {
779779
/// }
780780
/// ```
781781
#[clippy::version = "1.83.0"]
782-
pub CHARS_ENUMERATE_FOR_BYTE_INDICES,
782+
pub CHAR_INDICES_AS_BYTE_INDICES,
783783
correctness,
784784
"using the character position yielded by `.chars().enumerate()` in a context where a byte index is expected"
785785
}
@@ -821,7 +821,7 @@ impl_lint_pass!(Loops => [
821821
UNUSED_ENUMERATE_INDEX,
822822
INFINITE_LOOP,
823823
MANUAL_SLICE_FILL,
824-
CHARS_ENUMERATE_FOR_BYTE_INDICES,
824+
CHAR_INDICES_AS_BYTE_INDICES,
825825
]);
826826

827827
impl<'tcx> LateLintPass<'tcx> for Loops {
@@ -905,7 +905,7 @@ impl Loops {
905905
manual_flatten::check(cx, pat, arg, body, span, self.msrv);
906906
manual_find::check(cx, pat, arg, body, span, expr);
907907
unused_enumerate_index::check(cx, pat, arg, body);
908-
chars_enumerate_for_byte_indices::check(cx, pat, arg, body);
908+
char_indices_as_byte_indices::check(cx, pat, arg, body);
909909
}
910910

911911
fn check_for_loop_arg(&self, cx: &LateContext<'_>, _: &Pat<'_>, arg: &Expr<'_>) {

tests/ui/chars_enumerate_for_byte_indices.fixed renamed to tests/ui/char_indices_as_byte_indices.fixed

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(round_char_boundary)]
2-
#![warn(clippy::chars_enumerate_for_byte_indices)]
2+
#![warn(clippy::char_indices_as_byte_indices)]
33

44
trait StrExt {
55
fn use_index(&self, _: usize);
@@ -11,32 +11,32 @@ impl StrExt for str {
1111
fn bad(prim: &str, string: String) {
1212
for (idx, _) in prim.char_indices() {
1313
let _ = prim[..idx];
14-
//~^ chars_enumerate_for_byte_indices
14+
//~^ char_indices_as_byte_indices
1515
prim.split_at(idx);
16-
//~^ chars_enumerate_for_byte_indices
16+
//~^ char_indices_as_byte_indices
1717

1818
// This won't panic, but it can still return a wrong substring
1919
let _ = prim[..prim.floor_char_boundary(idx)];
20-
//~^ chars_enumerate_for_byte_indices
20+
//~^ char_indices_as_byte_indices
2121

2222
// can't use #[expect] here because the .fixed file will still have the attribute and create an
2323
// unfulfilled expectation, but make sure lint level attributes work on the use expression:
24-
#[allow(clippy::chars_enumerate_for_byte_indices)]
24+
#[allow(clippy::char_indices_as_byte_indices)]
2525
let _ = prim[..idx];
2626
}
2727

2828
for c in prim.char_indices() {
2929
let _ = prim[..c.0];
30-
//~^ chars_enumerate_for_byte_indices
30+
//~^ char_indices_as_byte_indices
3131
prim.split_at(c.0);
32-
//~^ chars_enumerate_for_byte_indices
32+
//~^ char_indices_as_byte_indices
3333
}
3434

3535
for (idx, _) in string.char_indices() {
3636
let _ = string[..idx];
37-
//~^ chars_enumerate_for_byte_indices
37+
//~^ char_indices_as_byte_indices
3838
string.split_at(idx);
39-
//~^ chars_enumerate_for_byte_indices
39+
//~^ char_indices_as_byte_indices
4040
}
4141
}
4242

tests/ui/chars_enumerate_for_byte_indices.rs renamed to tests/ui/char_indices_as_byte_indices.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(round_char_boundary)]
2-
#![warn(clippy::chars_enumerate_for_byte_indices)]
2+
#![warn(clippy::char_indices_as_byte_indices)]
33

44
trait StrExt {
55
fn use_index(&self, _: usize);
@@ -11,32 +11,32 @@ impl StrExt for str {
1111
fn bad(prim: &str, string: String) {
1212
for (idx, _) in prim.chars().enumerate() {
1313
let _ = prim[..idx];
14-
//~^ chars_enumerate_for_byte_indices
14+
//~^ char_indices_as_byte_indices
1515
prim.split_at(idx);
16-
//~^ chars_enumerate_for_byte_indices
16+
//~^ char_indices_as_byte_indices
1717

1818
// This won't panic, but it can still return a wrong substring
1919
let _ = prim[..prim.floor_char_boundary(idx)];
20-
//~^ chars_enumerate_for_byte_indices
20+
//~^ char_indices_as_byte_indices
2121

2222
// can't use #[expect] here because the .fixed file will still have the attribute and create an
2323
// unfulfilled expectation, but make sure lint level attributes work on the use expression:
24-
#[allow(clippy::chars_enumerate_for_byte_indices)]
24+
#[allow(clippy::char_indices_as_byte_indices)]
2525
let _ = prim[..idx];
2626
}
2727

2828
for c in prim.chars().enumerate() {
2929
let _ = prim[..c.0];
30-
//~^ chars_enumerate_for_byte_indices
30+
//~^ char_indices_as_byte_indices
3131
prim.split_at(c.0);
32-
//~^ chars_enumerate_for_byte_indices
32+
//~^ char_indices_as_byte_indices
3333
}
3434

3535
for (idx, _) in string.chars().enumerate() {
3636
let _ = string[..idx];
37-
//~^ chars_enumerate_for_byte_indices
37+
//~^ char_indices_as_byte_indices
3838
string.split_at(idx);
39-
//~^ chars_enumerate_for_byte_indices
39+
//~^ char_indices_as_byte_indices
4040
}
4141
}
4242

tests/ui/chars_enumerate_for_byte_indices.stderr renamed to tests/ui/char_indices_as_byte_indices.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: indexing into a string with a character position where a byte index is expected
2-
--> tests/ui/chars_enumerate_for_byte_indices.rs:13:24
2+
--> tests/ui/char_indices_as_byte_indices.rs:13:24
33
|
44
LL | let _ = prim[..idx];
55
| ^^^
66
|
77
= note: a character can take up more than one byte, so they are not interchangeable
88
note: position comes from the enumerate iterator
9-
--> tests/ui/chars_enumerate_for_byte_indices.rs:12:10
9+
--> tests/ui/char_indices_as_byte_indices.rs:12:10
1010
|
1111
LL | for (idx, _) in prim.chars().enumerate() {
1212
| ^^^ ^^^^^^^^^^^
13-
= note: `-D clippy::chars-enumerate-for-byte-indices` implied by `-D warnings`
14-
= help: to override `-D warnings` add `#[allow(clippy::chars_enumerate_for_byte_indices)]`
13+
= note: `-D clippy::char-indices-as-byte-indices` implied by `-D warnings`
14+
= help: to override `-D warnings` add `#[allow(clippy::char_indices_as_byte_indices)]`
1515
help: consider using `.char_indices()` instead
1616
|
1717
LL | for (idx, _) in prim.char_indices() {
1818
| ~~~~~~~~~~~~~~
1919

2020
error: passing a character position to a method that expects a byte index
21-
--> tests/ui/chars_enumerate_for_byte_indices.rs:15:23
21+
--> tests/ui/char_indices_as_byte_indices.rs:15:23
2222
|
2323
LL | prim.split_at(idx);
2424
| ^^^
2525
|
2626
= note: a character can take up more than one byte, so they are not interchangeable
2727
note: position comes from the enumerate iterator
28-
--> tests/ui/chars_enumerate_for_byte_indices.rs:12:10
28+
--> tests/ui/char_indices_as_byte_indices.rs:12:10
2929
|
3030
LL | for (idx, _) in prim.chars().enumerate() {
3131
| ^^^ ^^^^^^^^^^^
@@ -35,14 +35,14 @@ LL | for (idx, _) in prim.char_indices() {
3535
| ~~~~~~~~~~~~~~
3636

3737
error: passing a character position to a method that expects a byte index
38-
--> tests/ui/chars_enumerate_for_byte_indices.rs:19:49
38+
--> tests/ui/char_indices_as_byte_indices.rs:19:49
3939
|
4040
LL | let _ = prim[..prim.floor_char_boundary(idx)];
4141
| ^^^
4242
|
4343
= note: a character can take up more than one byte, so they are not interchangeable
4444
note: position comes from the enumerate iterator
45-
--> tests/ui/chars_enumerate_for_byte_indices.rs:12:10
45+
--> tests/ui/char_indices_as_byte_indices.rs:12:10
4646
|
4747
LL | for (idx, _) in prim.chars().enumerate() {
4848
| ^^^ ^^^^^^^^^^^
@@ -52,14 +52,14 @@ LL | for (idx, _) in prim.char_indices() {
5252
| ~~~~~~~~~~~~~~
5353

5454
error: indexing into a string with a character position where a byte index is expected
55-
--> tests/ui/chars_enumerate_for_byte_indices.rs:29:24
55+
--> tests/ui/char_indices_as_byte_indices.rs:29:24
5656
|
5757
LL | let _ = prim[..c.0];
5858
| ^^^
5959
|
6060
= note: a character can take up more than one byte, so they are not interchangeable
6161
note: position comes from the enumerate iterator
62-
--> tests/ui/chars_enumerate_for_byte_indices.rs:28:9
62+
--> tests/ui/char_indices_as_byte_indices.rs:28:9
6363
|
6464
LL | for c in prim.chars().enumerate() {
6565
| ^ ^^^^^^^^^^^
@@ -69,14 +69,14 @@ LL | for c in prim.char_indices() {
6969
| ~~~~~~~~~~~~~~
7070

7171
error: passing a character position to a method that expects a byte index
72-
--> tests/ui/chars_enumerate_for_byte_indices.rs:31:23
72+
--> tests/ui/char_indices_as_byte_indices.rs:31:23
7373
|
7474
LL | prim.split_at(c.0);
7575
| ^^^
7676
|
7777
= note: a character can take up more than one byte, so they are not interchangeable
7878
note: position comes from the enumerate iterator
79-
--> tests/ui/chars_enumerate_for_byte_indices.rs:28:9
79+
--> tests/ui/char_indices_as_byte_indices.rs:28:9
8080
|
8181
LL | for c in prim.chars().enumerate() {
8282
| ^ ^^^^^^^^^^^
@@ -86,14 +86,14 @@ LL | for c in prim.char_indices() {
8686
| ~~~~~~~~~~~~~~
8787

8888
error: indexing into a string with a character position where a byte index is expected
89-
--> tests/ui/chars_enumerate_for_byte_indices.rs:36:26
89+
--> tests/ui/char_indices_as_byte_indices.rs:36:26
9090
|
9191
LL | let _ = string[..idx];
9292
| ^^^
9393
|
9494
= note: a character can take up more than one byte, so they are not interchangeable
9595
note: position comes from the enumerate iterator
96-
--> tests/ui/chars_enumerate_for_byte_indices.rs:35:10
96+
--> tests/ui/char_indices_as_byte_indices.rs:35:10
9797
|
9898
LL | for (idx, _) in string.chars().enumerate() {
9999
| ^^^ ^^^^^^^^^^^
@@ -103,14 +103,14 @@ LL | for (idx, _) in string.char_indices() {
103103
| ~~~~~~~~~~~~~~
104104

105105
error: passing a character position to a method that expects a byte index
106-
--> tests/ui/chars_enumerate_for_byte_indices.rs:38:25
106+
--> tests/ui/char_indices_as_byte_indices.rs:38:25
107107
|
108108
LL | string.split_at(idx);
109109
| ^^^
110110
|
111111
= note: a character can take up more than one byte, so they are not interchangeable
112112
note: position comes from the enumerate iterator
113-
--> tests/ui/chars_enumerate_for_byte_indices.rs:35:10
113+
--> tests/ui/char_indices_as_byte_indices.rs:35:10
114114
|
115115
LL | for (idx, _) in string.chars().enumerate() {
116116
| ^^^ ^^^^^^^^^^^

0 commit comments

Comments
 (0)