about summary refs log tree commit diff
path: root/tests/ui/sliced_string_as_bytes.stderr
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2025-01-27 20:34:48 +0000
committerGitHub <noreply@github.com>2025-01-27 20:34:48 +0000
commit85bbba69b0d92a314a0751bcbdaa28e800625f61 (patch)
tree10879f5a3c35c7bd4f13992db43d79bab0d077b7 /tests/ui/sliced_string_as_bytes.stderr
parentac805d4a4e5cdafd74bb3457224813329309a644 (diff)
parentbeeb6f7432a2274895dfbe4736be75bc21db827a (diff)
New lint `sliced_string_as_bytes` (#14002)
resurrection of https://github.com/rust-lang/rust-clippy/pull/10984

fixes https://github.com/rust-lang/rust-clippy/issues/10981

changelog: [`sliced_string_as_bytes`]: add new lint
`sliced_string_as_bytes`
Diffstat (limited to 'tests/ui/sliced_string_as_bytes.stderr')
-rw-r--r--tests/ui/sliced_string_as_bytes.stderr23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/sliced_string_as_bytes.stderr b/tests/ui/sliced_string_as_bytes.stderr
new file mode 100644
index 00000000000..1342f4c01a4
--- /dev/null
+++ b/tests/ui/sliced_string_as_bytes.stderr
@@ -0,0 +1,23 @@
+error: calling `as_bytes` after slicing a string
+  --> tests/ui/sliced_string_as_bytes.rs:28:17
+   |
+LL |     let bytes = s[1..5].as_bytes();
+   |                 ^^^^^^^^^^^^^^^^^^ help: try: `&s.as_bytes()[1..5]`
+   |
+   = note: `-D clippy::sliced-string-as-bytes` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(clippy::sliced_string_as_bytes)]`
+
+error: calling `as_bytes` after slicing a string
+  --> tests/ui/sliced_string_as_bytes.rs:29:17
+   |
+LL |     let bytes = string[1..].as_bytes();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&string.as_bytes()[1..]`
+
+error: calling `as_bytes` after slicing a string
+  --> tests/ui/sliced_string_as_bytes.rs:30:17
+   |
+LL |     let bytes = "consectetur adipiscing"[..=5].as_bytes();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&"consectetur adipiscing".as_bytes()[..=5]`
+
+error: aborting due to 3 previous errors
+