about summary refs log tree commit diff
path: root/tests/ui/never_loop_fixable.stderr
diff options
context:
space:
mode:
authorlapla-cogito <me@lapla.dev>2025-02-12 22:25:58 +0900
committerlapla-cogito <me@lapla.dev>2025-03-10 15:00:57 +0900
commit90dbc5bf94de29304c18d840c8c90f09f2d32cf6 (patch)
tree18d9a491d7b4cc9c95517156cc90601a0cf124d7 /tests/ui/never_loop_fixable.stderr
parent649cef0e81d1c095e9a643cac4998e1ff1910c6d (diff)
downloadrust-90dbc5bf94de29304c18d840c8c90f09f2d32cf6.tar.gz
rust-90dbc5bf94de29304c18d840c8c90f09f2d32cf6.zip
make `never_loop` applicability more flexible
Diffstat (limited to 'tests/ui/never_loop_fixable.stderr')
-rw-r--r--tests/ui/never_loop_fixable.stderr35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/never_loop_fixable.stderr b/tests/ui/never_loop_fixable.stderr
new file mode 100644
index 00000000000..ee02d9a4297
--- /dev/null
+++ b/tests/ui/never_loop_fixable.stderr
@@ -0,0 +1,35 @@
+error: this loop never actually loops
+  --> tests/ui/never_loop_fixable.rs:4:5
+   |
+LL | /     for i in [1, 2, 3].iter() {
+LL | |
+LL | |         return;
+LL | |     }
+   | |_____^
+   |
+   = note: `#[deny(clippy::never_loop)]` on by default
+help: if you need the first element of the iterator, try writing
+   |
+LL -     for i in [1, 2, 3].iter() {
+LL +     if let Some(i) = [1, 2, 3].iter().next() {
+   |
+
+error: this loop never actually loops
+  --> tests/ui/never_loop_fixable.rs:11:5
+   |
+LL | /     for i in [1, 2, 3].iter() {
+LL | |
+LL | |         return;
+LL | |         loop {
+...  |
+LL | |     }
+   | |_____^
+   |
+help: if you need the first element of the iterator, try writing
+   |
+LL -     for i in [1, 2, 3].iter() {
+LL +     if let Some(i) = [1, 2, 3].iter().next() {
+   |
+
+error: aborting due to 2 previous errors
+