about summary refs log tree commit diff
diff options
context:
space:
mode:
authory21 <30553356+y21@users.noreply.github.com>2024-12-03 04:33:01 +0100
committery21 <30553356+y21@users.noreply.github.com>2025-03-30 13:40:03 +0200
commitd5d2189c715bba5b12585c52ac8e30ac52c484f9 (patch)
tree17a8cbe286376db807e1ab041049210eb411a743
parent32cf88450bd1d97a1ec1cfcb67c04173ea92db3c (diff)
downloadrust-d5d2189c715bba5b12585c52ac8e30ac52c484f9.tar.gz
rust-d5d2189c715bba5b12585c52ac8e30ac52c484f9.zip
rename lint to `char_indices_as_byte_indices`
-rw-r--r--CHANGELOG.md2
-rw-r--r--clippy_lints/src/declared_lints.rs2
-rw-r--r--clippy_lints/src/loops/char_indices_as_byte_indices.rs (renamed from clippy_lints/src/loops/chars_enumerate_for_byte_indices.rs)4
-rw-r--r--clippy_lints/src/loops/mod.rs8
-rw-r--r--tests/ui/char_indices_as_byte_indices.fixed (renamed from tests/ui/chars_enumerate_for_byte_indices.fixed)18
-rw-r--r--tests/ui/char_indices_as_byte_indices.rs (renamed from tests/ui/chars_enumerate_for_byte_indices.rs)18
-rw-r--r--tests/ui/char_indices_as_byte_indices.stderr (renamed from tests/ui/chars_enumerate_for_byte_indices.stderr)32
7 files changed, 42 insertions, 42 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68387498c0d..ee16c442c0f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5516,8 +5516,8 @@ Released 2018-09-13
 [`cast_slice_different_sizes`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_different_sizes
 [`cast_slice_from_raw_parts`]: https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts
 [`cfg_not_test`]: https://rust-lang.github.io/rust-clippy/master/index.html#cfg_not_test
+[`char_indices_as_byte_indices`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_indices_as_byte_indices
 [`char_lit_as_u8`]: https://rust-lang.github.io/rust-clippy/master/index.html#char_lit_as_u8
-[`chars_enumerate_for_byte_indices`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_enumerate_for_byte_indices
 [`chars_last_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_last_cmp
 [`chars_next_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#chars_next_cmp
 [`checked_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs
index cd3f40a003d..7ee898ec75a 100644
--- a/clippy_lints/src/declared_lints.rs
+++ b/clippy_lints/src/declared_lints.rs
@@ -287,7 +287,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
     crate::literal_representation::UNREADABLE_LITERAL_INFO,
     crate::literal_representation::UNUSUAL_BYTE_GROUPINGS_INFO,
     crate::literal_string_with_formatting_args::LITERAL_STRING_WITH_FORMATTING_ARGS_INFO,
-    crate::loops::CHARS_ENUMERATE_FOR_BYTE_INDICES_INFO,
+    crate::loops::CHAR_INDICES_AS_BYTE_INDICES_INFO,
     crate::loops::EMPTY_LOOP_INFO,
     crate::loops::EXPLICIT_COUNTER_LOOP_INFO,
     crate::loops::EXPLICIT_INTO_ITER_LOOP_INFO,
diff --git a/clippy_lints/src/loops/chars_enumerate_for_byte_indices.rs b/clippy_lints/src/loops/char_indices_as_byte_indices.rs
index 40274311d78..90e6f71e41a 100644
--- a/clippy_lints/src/loops/chars_enumerate_for_byte_indices.rs
+++ b/clippy_lints/src/loops/char_indices_as_byte_indices.rs
@@ -10,7 +10,7 @@ use rustc_lint::LateContext;
 use rustc_middle::ty::Ty;
 use rustc_span::{Span, sym};
 
-use super::CHARS_ENUMERATE_FOR_BYTE_INDICES;
+use super::CHAR_INDICES_AS_BYTE_INDICES;
 
 // The list of `str` methods we want to lint that have a `usize` argument representing a byte index.
 // Note: `String` also has methods that work with byte indices,
@@ -101,7 +101,7 @@ fn check_index_usage<'tcx>(
 
     span_lint_hir_and_then(
         cx,
-        CHARS_ENUMERATE_FOR_BYTE_INDICES,
+        CHAR_INDICES_AS_BYTE_INDICES,
         expr.hir_id,
         expr.span,
         message,
diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs
index 9a3fd147fb5..2b66827e82e 100644
--- a/clippy_lints/src/loops/mod.rs
+++ b/clippy_lints/src/loops/mod.rs
@@ -1,4 +1,4 @@
-mod chars_enumerate_for_byte_indices;
+mod char_indices_as_byte_indices;
 mod empty_loop;
 mod explicit_counter_loop;
 mod explicit_into_iter_loop;
@@ -779,7 +779,7 @@ declare_clippy_lint! {
     /// }
     /// ```
     #[clippy::version = "1.83.0"]
-    pub CHARS_ENUMERATE_FOR_BYTE_INDICES,
+    pub CHAR_INDICES_AS_BYTE_INDICES,
     correctness,
     "using the character position yielded by `.chars().enumerate()` in a context where a byte index is expected"
 }
@@ -821,7 +821,7 @@ impl_lint_pass!(Loops => [
     UNUSED_ENUMERATE_INDEX,
     INFINITE_LOOP,
     MANUAL_SLICE_FILL,
-    CHARS_ENUMERATE_FOR_BYTE_INDICES,
+    CHAR_INDICES_AS_BYTE_INDICES,
 ]);
 
 impl<'tcx> LateLintPass<'tcx> for Loops {
@@ -905,7 +905,7 @@ impl Loops {
         manual_flatten::check(cx, pat, arg, body, span, self.msrv);
         manual_find::check(cx, pat, arg, body, span, expr);
         unused_enumerate_index::check(cx, pat, arg, body);
-        chars_enumerate_for_byte_indices::check(cx, pat, arg, body);
+        char_indices_as_byte_indices::check(cx, pat, arg, body);
     }
 
     fn check_for_loop_arg(&self, cx: &LateContext<'_>, _: &Pat<'_>, arg: &Expr<'_>) {
diff --git a/tests/ui/chars_enumerate_for_byte_indices.fixed b/tests/ui/char_indices_as_byte_indices.fixed
index 7a4f87fa2d4..a7c6bcd2681 100644
--- a/tests/ui/chars_enumerate_for_byte_indices.fixed
+++ b/tests/ui/char_indices_as_byte_indices.fixed
@@ -1,5 +1,5 @@
 #![feature(round_char_boundary)]
-#![warn(clippy::chars_enumerate_for_byte_indices)]
+#![warn(clippy::char_indices_as_byte_indices)]
 
 trait StrExt {
     fn use_index(&self, _: usize);
@@ -11,32 +11,32 @@ impl StrExt for str {
 fn bad(prim: &str, string: String) {
     for (idx, _) in prim.char_indices() {
         let _ = prim[..idx];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
         prim.split_at(idx);
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
 
         // This won't panic, but it can still return a wrong substring
         let _ = prim[..prim.floor_char_boundary(idx)];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
 
         // can't use #[expect] here because the .fixed file will still have the attribute and create an
         // unfulfilled expectation, but make sure lint level attributes work on the use expression:
-        #[allow(clippy::chars_enumerate_for_byte_indices)]
+        #[allow(clippy::char_indices_as_byte_indices)]
         let _ = prim[..idx];
     }
 
     for c in prim.char_indices() {
         let _ = prim[..c.0];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
         prim.split_at(c.0);
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
     }
 
     for (idx, _) in string.char_indices() {
         let _ = string[..idx];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
         string.split_at(idx);
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
     }
 }
 
diff --git a/tests/ui/chars_enumerate_for_byte_indices.rs b/tests/ui/char_indices_as_byte_indices.rs
index 1e8f555846a..bb0f5df19bc 100644
--- a/tests/ui/chars_enumerate_for_byte_indices.rs
+++ b/tests/ui/char_indices_as_byte_indices.rs
@@ -1,5 +1,5 @@
 #![feature(round_char_boundary)]
-#![warn(clippy::chars_enumerate_for_byte_indices)]
+#![warn(clippy::char_indices_as_byte_indices)]
 
 trait StrExt {
     fn use_index(&self, _: usize);
@@ -11,32 +11,32 @@ impl StrExt for str {
 fn bad(prim: &str, string: String) {
     for (idx, _) in prim.chars().enumerate() {
         let _ = prim[..idx];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
         prim.split_at(idx);
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
 
         // This won't panic, but it can still return a wrong substring
         let _ = prim[..prim.floor_char_boundary(idx)];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
 
         // can't use #[expect] here because the .fixed file will still have the attribute and create an
         // unfulfilled expectation, but make sure lint level attributes work on the use expression:
-        #[allow(clippy::chars_enumerate_for_byte_indices)]
+        #[allow(clippy::char_indices_as_byte_indices)]
         let _ = prim[..idx];
     }
 
     for c in prim.chars().enumerate() {
         let _ = prim[..c.0];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
         prim.split_at(c.0);
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
     }
 
     for (idx, _) in string.chars().enumerate() {
         let _ = string[..idx];
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
         string.split_at(idx);
-        //~^ chars_enumerate_for_byte_indices
+        //~^ char_indices_as_byte_indices
     }
 }
 
diff --git a/tests/ui/chars_enumerate_for_byte_indices.stderr b/tests/ui/char_indices_as_byte_indices.stderr
index 0159eb0387b..a3c84578392 100644
--- a/tests/ui/chars_enumerate_for_byte_indices.stderr
+++ b/tests/ui/char_indices_as_byte_indices.stderr
@@ -1,31 +1,31 @@
 error: indexing into a string with a character position where a byte index is expected
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:13:24
+  --> tests/ui/char_indices_as_byte_indices.rs:13:24
    |
 LL |         let _ = prim[..idx];
    |                        ^^^
    |
    = note: a character can take up more than one byte, so they are not interchangeable
 note: position comes from the enumerate iterator
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:12:10
+  --> tests/ui/char_indices_as_byte_indices.rs:12:10
    |
 LL |     for (idx, _) in prim.chars().enumerate() {
    |          ^^^                     ^^^^^^^^^^^
-   = note: `-D clippy::chars-enumerate-for-byte-indices` implied by `-D warnings`
-   = help: to override `-D warnings` add `#[allow(clippy::chars_enumerate_for_byte_indices)]`
+   = note: `-D clippy::char-indices-as-byte-indices` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(clippy::char_indices_as_byte_indices)]`
 help: consider using `.char_indices()` instead
    |
 LL |     for (idx, _) in prim.char_indices() {
    |                          ~~~~~~~~~~~~~~
 
 error: passing a character position to a method that expects a byte index
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:15:23
+  --> tests/ui/char_indices_as_byte_indices.rs:15:23
    |
 LL |         prim.split_at(idx);
    |                       ^^^
    |
    = note: a character can take up more than one byte, so they are not interchangeable
 note: position comes from the enumerate iterator
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:12:10
+  --> tests/ui/char_indices_as_byte_indices.rs:12:10
    |
 LL |     for (idx, _) in prim.chars().enumerate() {
    |          ^^^                     ^^^^^^^^^^^
@@ -35,14 +35,14 @@ LL |     for (idx, _) in prim.char_indices() {
    |                          ~~~~~~~~~~~~~~
 
 error: passing a character position to a method that expects a byte index
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:19:49
+  --> tests/ui/char_indices_as_byte_indices.rs:19:49
    |
 LL |         let _ = prim[..prim.floor_char_boundary(idx)];
    |                                                 ^^^
    |
    = note: a character can take up more than one byte, so they are not interchangeable
 note: position comes from the enumerate iterator
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:12:10
+  --> tests/ui/char_indices_as_byte_indices.rs:12:10
    |
 LL |     for (idx, _) in prim.chars().enumerate() {
    |          ^^^                     ^^^^^^^^^^^
@@ -52,14 +52,14 @@ LL |     for (idx, _) in prim.char_indices() {
    |                          ~~~~~~~~~~~~~~
 
 error: indexing into a string with a character position where a byte index is expected
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:29:24
+  --> tests/ui/char_indices_as_byte_indices.rs:29:24
    |
 LL |         let _ = prim[..c.0];
    |                        ^^^
    |
    = note: a character can take up more than one byte, so they are not interchangeable
 note: position comes from the enumerate iterator
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:28:9
+  --> tests/ui/char_indices_as_byte_indices.rs:28:9
    |
 LL |     for c in prim.chars().enumerate() {
    |         ^                 ^^^^^^^^^^^
@@ -69,14 +69,14 @@ LL |     for c in prim.char_indices() {
    |                   ~~~~~~~~~~~~~~
 
 error: passing a character position to a method that expects a byte index
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:31:23
+  --> tests/ui/char_indices_as_byte_indices.rs:31:23
    |
 LL |         prim.split_at(c.0);
    |                       ^^^
    |
    = note: a character can take up more than one byte, so they are not interchangeable
 note: position comes from the enumerate iterator
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:28:9
+  --> tests/ui/char_indices_as_byte_indices.rs:28:9
    |
 LL |     for c in prim.chars().enumerate() {
    |         ^                 ^^^^^^^^^^^
@@ -86,14 +86,14 @@ LL |     for c in prim.char_indices() {
    |                   ~~~~~~~~~~~~~~
 
 error: indexing into a string with a character position where a byte index is expected
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:36:26
+  --> tests/ui/char_indices_as_byte_indices.rs:36:26
    |
 LL |         let _ = string[..idx];
    |                          ^^^
    |
    = note: a character can take up more than one byte, so they are not interchangeable
 note: position comes from the enumerate iterator
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:35:10
+  --> tests/ui/char_indices_as_byte_indices.rs:35:10
    |
 LL |     for (idx, _) in string.chars().enumerate() {
    |          ^^^                       ^^^^^^^^^^^
@@ -103,14 +103,14 @@ LL |     for (idx, _) in string.char_indices() {
    |                            ~~~~~~~~~~~~~~
 
 error: passing a character position to a method that expects a byte index
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:38:25
+  --> tests/ui/char_indices_as_byte_indices.rs:38:25
    |
 LL |         string.split_at(idx);
    |                         ^^^
    |
    = note: a character can take up more than one byte, so they are not interchangeable
 note: position comes from the enumerate iterator
-  --> tests/ui/chars_enumerate_for_byte_indices.rs:35:10
+  --> tests/ui/char_indices_as_byte_indices.rs:35:10
    |
 LL |     for (idx, _) in string.chars().enumerate() {
    |          ^^^                       ^^^^^^^^^^^