about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-05-27 18:16:55 +0000
committerMichael Goulet <michael@errs.io>2023-05-31 16:51:25 +0000
commit0a51ab93cf8a8c11f28cca7a5912a5af23e98a89 (patch)
tree689128ad7dffd5acaca95e56f395ecbe890422b6 /tests
parentad8304a0d5280de30856b39c19df7b306957e878 (diff)
downloadrust-0a51ab93cf8a8c11f28cca7a5912a5af23e98a89.tar.gz
rust-0a51ab93cf8a8c11f28cca7a5912a5af23e98a89.zip
Don't suggest break through nested items
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/loops/dont-suggest-break-thru-item.rs55
-rw-r--r--tests/ui/loops/dont-suggest-break-thru-item.stderr55
2 files changed, 110 insertions, 0 deletions
diff --git a/tests/ui/loops/dont-suggest-break-thru-item.rs b/tests/ui/loops/dont-suggest-break-thru-item.rs
new file mode 100644
index 00000000000..b46ba89e81d
--- /dev/null
+++ b/tests/ui/loops/dont-suggest-break-thru-item.rs
@@ -0,0 +1,55 @@
+// edition:2021
+
+#![feature(inline_const)]
+
+fn closure() {
+    loop {
+        let closure = || {
+            if true {
+                Err(1)
+                //~^ ERROR mismatched types
+            }
+
+            Ok(())
+        };
+    }
+}
+
+fn async_block() {
+    loop {
+        let fut = async {
+            if true {
+                Err(1)
+                //~^ ERROR mismatched types
+            }
+
+            Ok(())
+        };
+    }
+}
+
+fn fn_item() {
+    let _ = loop {
+        fn foo() -> Result<(), ()> {
+            if true {
+                Err(1)
+                //~^ ERROR mismatched types
+            }
+            Err(())
+        }
+    };
+}
+
+fn const_block() {
+    let _ = loop {
+        const {
+            if true {
+                Err(1)
+                //~^ ERROR mismatched types
+            }
+            Err(())
+        };
+    };
+}
+
+fn main() {}
diff --git a/tests/ui/loops/dont-suggest-break-thru-item.stderr b/tests/ui/loops/dont-suggest-break-thru-item.stderr
new file mode 100644
index 00000000000..4fce4715119
--- /dev/null
+++ b/tests/ui/loops/dont-suggest-break-thru-item.stderr
@@ -0,0 +1,55 @@
+error[E0308]: mismatched types
+  --> $DIR/dont-suggest-break-thru-item.rs:9:17
+   |
+LL | /             if true {
+LL | |                 Err(1)
+   | |                 ^^^^^^ expected `()`, found `Result<_, {integer}>`
+LL | |
+LL | |             }
+   | |_____________- expected this to be `()`
+   |
+   = note: expected unit type `()`
+                   found enum `Result<_, {integer}>`
+
+error[E0308]: mismatched types
+  --> $DIR/dont-suggest-break-thru-item.rs:22:17
+   |
+LL | /             if true {
+LL | |                 Err(1)
+   | |                 ^^^^^^ expected `()`, found `Result<_, {integer}>`
+LL | |
+LL | |             }
+   | |_____________- expected this to be `()`
+   |
+   = note: expected unit type `()`
+                   found enum `Result<_, {integer}>`
+
+error[E0308]: mismatched types
+  --> $DIR/dont-suggest-break-thru-item.rs:35:17
+   |
+LL | /             if true {
+LL | |                 Err(1)
+   | |                 ^^^^^^ expected `()`, found `Result<_, {integer}>`
+LL | |
+LL | |             }
+   | |_____________- expected this to be `()`
+   |
+   = note: expected unit type `()`
+                   found enum `Result<_, {integer}>`
+
+error[E0308]: mismatched types
+  --> $DIR/dont-suggest-break-thru-item.rs:47:17
+   |
+LL | /             if true {
+LL | |                 Err(1)
+   | |                 ^^^^^^ expected `()`, found `Result<_, {integer}>`
+LL | |
+LL | |             }
+   | |_____________- expected this to be `()`
+   |
+   = note: expected unit type `()`
+                   found enum `Result<_, {integer}>`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.