Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 26a7b32

Browse files
committed
Rename slice_as_bytes -> sliced_string_as_bytes
1 parent 9e83183 commit 26a7b32

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6066,7 +6066,7 @@ Released 2018-09-13
60666066
[`size_of_in_element_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#size_of_in_element_count
60676067
[`size_of_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#size_of_ref
60686068
[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
6069-
[`slice_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#slice_as_bytes
6069+
[`sliced_string_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#sliced_string_as_bytes
60706070
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
60716071
[`stable_sort_primitive`]: https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
60726072
[`std_instead_of_alloc`]: https://rust-lang.github.io/rust-clippy/master/index.html#std_instead_of_alloc

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
468468
crate::methods::SHOULD_IMPLEMENT_TRAIT_INFO,
469469
crate::methods::SINGLE_CHAR_ADD_STR_INFO,
470470
crate::methods::SKIP_WHILE_NEXT_INFO,
471-
crate::methods::SLICE_AS_BYTES_INFO,
471+
crate::methods::SLICED_STRING_AS_BYTES_INFO,
472472
crate::methods::STABLE_SORT_PRIMITIVE_INFO,
473473
crate::methods::STRING_EXTEND_CHARS_INFO,
474474
crate::methods::STRING_LIT_CHARS_ANY_INFO,

clippy_lints/src/methods/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ mod single_char_add_str;
102102
mod single_char_insert_string;
103103
mod single_char_push_string;
104104
mod skip_while_next;
105-
mod slice_as_bytes;
105+
mod sliced_string_as_bytes;
106106
mod stable_sort_primitive;
107107
mod str_split;
108108
mod str_splitn;
@@ -4386,8 +4386,8 @@ declare_clippy_lint! {
43864386
/// let s = "Lorem ipsum";
43874387
/// &s.as_bytes()[1..5];
43884388
/// ```
4389-
#[clippy::version = "1.72.0"]
4390-
pub SLICE_AS_BYTES,
4389+
#[clippy::version = "1.86.0"]
4390+
pub SLICED_STRING_AS_BYTES,
43914391
pedantic,
43924392
"slicing a string and immediately calling as_bytes is less efficient and can lead to panics"
43934393
}
@@ -4560,7 +4560,7 @@ impl_lint_pass!(Methods => [
45604560
DOUBLE_ENDED_ITERATOR_LAST,
45614561
USELESS_NONZERO_NEW_UNCHECKED,
45624562
MANUAL_REPEAT_N,
4563-
SLICE_AS_BYTES,
4563+
SLICED_STRING_AS_BYTES,
45644564
]);
45654565

45664566
/// Extracts a method call name, args, and `Span` of the method name.
@@ -4828,7 +4828,7 @@ impl Methods {
48284828
if let Some(("as_str", recv, [], as_str_span, _)) = method_call(recv) {
48294829
redundant_as_str::check(cx, expr, recv, as_str_span, span);
48304830
}
4831-
slice_as_bytes::check(cx, expr, recv);
4831+
sliced_string_as_bytes::check(cx, expr, recv);
48324832
},
48334833
("as_mut", []) => useless_asref::check(cx, expr, "as_mut", recv),
48344834
("as_ptr", []) => manual_c_str_literals::check_as_ptr(cx, expr, recv, &self.msrv),

clippy_lints/src/methods/slice_as_bytes.rs renamed to clippy_lints/src/methods/sliced_string_as_bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_errors::Applicability;
55
use rustc_hir::{Expr, ExprKind, LangItem, is_range_literal};
66
use rustc_lint::LateContext;
77

8-
use super::SLICE_AS_BYTES;
8+
use super::SLICED_STRING_AS_BYTES;
99

1010
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>) {
1111
if let ExprKind::Index(indexed, index, _) = recv.kind
@@ -18,7 +18,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>) {
1818
let range = snippet_with_applicability(cx, index.span, "..", &mut applicability);
1919
span_lint_and_sugg(
2020
cx,
21-
SLICE_AS_BYTES,
21+
SLICED_STRING_AS_BYTES,
2222
expr.span,
2323
"calling `as_bytes` after slicing a string",
2424
"try",

tests/ui/bytes_nth.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(clippy::unnecessary_operation)]
2-
#![allow(clippy::slice_as_bytes)]
2+
#![allow(clippy::sliced_string_as_bytes)]
33
#![warn(clippy::bytes_nth)]
44

55
fn main() {

tests/ui/bytes_nth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(clippy::unnecessary_operation)]
2-
#![allow(clippy::slice_as_bytes)]
2+
#![allow(clippy::sliced_string_as_bytes)]
33
#![warn(clippy::bytes_nth)]
44

55
fn main() {

tests/ui/slice_as_bytes.fixed renamed to tests/ui/sliced_string_as_bytes.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(unused)]
2-
#![warn(clippy::slice_as_bytes)]
2+
#![warn(clippy::sliced_string_as_bytes)]
33

44
use std::ops::{Index, Range};
55

tests/ui/slice_as_bytes.rs renamed to tests/ui/sliced_string_as_bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(unused)]
2-
#![warn(clippy::slice_as_bytes)]
2+
#![warn(clippy::sliced_string_as_bytes)]
33

44
use std::ops::{Index, Range};
55

tests/ui/slice_as_bytes.stderr renamed to tests/ui/sliced_string_as_bytes.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
error: calling `as_bytes` after slicing a string
2-
--> tests/ui/slice_as_bytes.rs:28:17
2+
--> tests/ui/sliced_string_as_bytes.rs:28:17
33
|
44
LL | let bytes = s[1..5].as_bytes();
55
| ^^^^^^^^^^^^^^^^^^ help: try: `&s.as_bytes()[1..5]`
66
|
77
= note: `-D clippy::slice-as-bytes` implied by `-D warnings`
8-
= help: to override `-D warnings` add `#[allow(clippy::slice_as_bytes)]`
8+
= help: to override `-D warnings` add `#[allow(clippy::sliced_string_as_bytes)]`
99

1010
error: calling `as_bytes` after slicing a string
11-
--> tests/ui/slice_as_bytes.rs:29:17
11+
--> tests/ui/sliced_string_as_bytes.rs:29:17
1212
|
1313
LL | let bytes = string[1..].as_bytes();
1414
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&string.as_bytes()[1..]`
1515

1616
error: calling `as_bytes` after slicing a string
17-
--> tests/ui/slice_as_bytes.rs:30:17
17+
--> tests/ui/sliced_string_as_bytes.rs:30:17
1818
|
1919
LL | let bytes = "consectetur adipiscing"[..=5].as_bytes();
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&"consectetur adipiscing".as_bytes()[..=5]`

0 commit comments

Comments
 (0)