Skip to content

Commit e1118b0

Browse files
committed
Rename slice_as_bytes -> sliced_string_as_bytes
1 parent c955bdb commit e1118b0

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
@@ -6064,7 +6064,7 @@ Released 2018-09-13
60646064
[`size_of_in_element_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#size_of_in_element_count
60656065
[`size_of_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#size_of_ref
60666066
[`skip_while_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#skip_while_next
6067-
[`slice_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#slice_as_bytes
6067+
[`sliced_string_as_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#sliced_string_as_bytes
60686068
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
60696069
[`stable_sort_primitive`]: https://rust-lang.github.io/rust-clippy/master/index.html#stable_sort_primitive
60706070
[`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
@@ -467,7 +467,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
467467
crate::methods::SHOULD_IMPLEMENT_TRAIT_INFO,
468468
crate::methods::SINGLE_CHAR_ADD_STR_INFO,
469469
crate::methods::SKIP_WHILE_NEXT_INFO,
470-
crate::methods::SLICE_AS_BYTES_INFO,
470+
crate::methods::SLICED_STRING_AS_BYTES_INFO,
471471
crate::methods::STABLE_SORT_PRIMITIVE_INFO,
472472
crate::methods::STRING_EXTEND_CHARS_INFO,
473473
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
@@ -101,7 +101,7 @@ mod single_char_add_str;
101101
mod single_char_insert_string;
102102
mod single_char_push_string;
103103
mod skip_while_next;
104-
mod slice_as_bytes;
104+
mod sliced_string_as_bytes;
105105
mod stable_sort_primitive;
106106
mod str_split;
107107
mod str_splitn;
@@ -4362,8 +4362,8 @@ declare_clippy_lint! {
43624362
/// let s = "Lorem ipsum";
43634363
/// &s.as_bytes()[1..5];
43644364
/// ```
4365-
#[clippy::version = "1.72.0"]
4366-
pub SLICE_AS_BYTES,
4365+
#[clippy::version = "1.86.0"]
4366+
pub SLICED_STRING_AS_BYTES,
43674367
pedantic,
43684368
"slicing a string and immediately calling as_bytes is less efficient and can lead to panics"
43694369
}
@@ -4535,7 +4535,7 @@ impl_lint_pass!(Methods => [
45354535
UNNECESSARY_MAP_OR,
45364536
DOUBLE_ENDED_ITERATOR_LAST,
45374537
USELESS_NONZERO_NEW_UNCHECKED,
4538-
SLICE_AS_BYTES,
4538+
SLICED_STRING_AS_BYTES,
45394539
]);
45404540

45414541
/// Extracts a method call name, args, and `Span` of the method name.
@@ -4803,7 +4803,7 @@ impl Methods {
48034803
if let Some(("as_str", recv, [], as_str_span, _)) = method_call(recv) {
48044804
redundant_as_str::check(cx, expr, recv, as_str_span, span);
48054805
}
4806-
slice_as_bytes::check(cx, expr, recv);
4806+
sliced_string_as_bytes::check(cx, expr, recv);
48074807
},
48084808
("as_mut", []) => useless_asref::check(cx, expr, "as_mut", recv),
48094809
("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)