about summary refs log tree commit diff
path: root/tests/ui/never_loop.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.stderr
parent649cef0e81d1c095e9a643cac4998e1ff1910c6d (diff)
downloadrust-90dbc5bf94de29304c18d840c8c90f09f2d32cf6.tar.gz
rust-90dbc5bf94de29304c18d840c8c90f09f2d32cf6.zip
make `never_loop` applicability more flexible
Diffstat (limited to 'tests/ui/never_loop.stderr')
-rw-r--r--tests/ui/never_loop.stderr70
1 files changed, 69 insertions, 1 deletions
diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr
index f6d6d109542..bc9a7ec48b4 100644
--- a/tests/ui/never_loop.stderr
+++ b/tests/ui/never_loop.stderr
@@ -164,5 +164,73 @@ LL | |         unimplemented!("not yet");
 LL | |     }
    | |_____^
 
-error: aborting due to 16 previous errors
+error: this loop never actually loops
+  --> tests/ui/never_loop.rs:426:5
+   |
+LL | /     for v in 0..10 {
+LL | |
+LL | |         break;
+LL | |         println!("{v}");
+LL | |     }
+   | |_____^
+   |
+help: if you need the first element of the iterator, try writing
+   |
+LL -     for v in 0..10 {
+LL +     if let Some(v) = (0..10).next() {
+   |
+
+error: this loop never actually loops
+  --> tests/ui/never_loop.rs:434:5
+   |
+LL | /     'outer: for v in 0..10 {
+LL | |
+LL | |         loop {
+...  |
+LL | |         return;
+LL | |     }
+   | |_____^
+   |
+help: if you need the first element of the iterator, try writing
+   |
+LL -     'outer: for v in 0..10 {
+LL +     if let Some(v) = (0..10).next() {
+   |
+
+error: this loop never actually loops
+  --> tests/ui/never_loop.rs:436:9
+   |
+LL | /         loop {
+LL | |
+LL | |             break 'outer;
+LL | |         }
+   | |_________^
+
+error: this loop never actually loops
+  --> tests/ui/never_loop.rs:443:5
+   |
+LL | /     for v in 0..10 {
+LL | |
+LL | |         'inner: loop {
+...  |
+LL | |         return;
+LL | |     }
+   | |_____^
+   |
+help: if you need the first element of the iterator, try writing
+   |
+LL -     for v in 0..10 {
+LL +     if let Some(v) = (0..10).next() {
+   |
+
+error: this loop never actually loops
+  --> tests/ui/never_loop.rs:445:9
+   |
+LL | /         'inner: loop {
+LL | |
+LL | |             break 'inner;
+LL | |         }
+   | |_________^
+
+error: aborting due to 21 previous errors