about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTor Hovland <tor.hovland@bekk.no>2021-04-24 19:00:24 +0200
committerTor Hovland <tor.hovland@bekk.no>2021-04-24 19:00:24 +0200
commit05a5a1128fc5da178f9b7bd0ab499258652dfc49 (patch)
tree8f4e30ba5f79da8eea15168eb39787a099deb54e
parent8bc81a0e4d9d5edc72af0cffe31a78a0bd2156f2 (diff)
downloadrust-05a5a1128fc5da178f9b7bd0ab499258652dfc49.tar.gz
rust-05a5a1128fc5da178f9b7bd0ab499258652dfc49.zip
More tests.
-rw-r--r--src/test/ui/loops/loop-no-implicit-break.rs26
-rw-r--r--src/test/ui/loops/loop-no-implicit-break.stderr32
2 files changed, 51 insertions, 7 deletions
diff --git a/src/test/ui/loops/loop-no-implicit-break.rs b/src/test/ui/loops/loop-no-implicit-break.rs
index 0c57baf1439..fc3b3c4a30f 100644
--- a/src/test/ui/loops/loop-no-implicit-break.rs
+++ b/src/test/ui/loops/loop-no-implicit-break.rs
@@ -1,5 +1,27 @@
 fn main() {
-    let x: i8 = loop {
-        10 //~ ERROR mismatched types
+    let a: i8 = loop {
+        1 //~ ERROR mismatched types
     };
+
+    let b: i8 = loop {
+        break 1;
+    };
+}
+
+fn foo() -> i8 {
+    let a: i8 = loop {
+        1 //~ ERROR mismatched types
+    };
+
+    let b: i8 = loop {
+        break 1;
+    };
+
+    loop {
+        1 //~ ERROR mismatched types
+    }
+
+    loop {
+        return 1;
+    }
 }
diff --git a/src/test/ui/loops/loop-no-implicit-break.stderr b/src/test/ui/loops/loop-no-implicit-break.stderr
index 99767b78d35..cde6bbe512b 100644
--- a/src/test/ui/loops/loop-no-implicit-break.stderr
+++ b/src/test/ui/loops/loop-no-implicit-break.stderr
@@ -1,14 +1,36 @@
 error[E0308]: mismatched types
   --> $DIR/loop-no-implicit-break.rs:3:9
    |
-LL |         10
-   |         ^^ expected `()`, found integer
+LL |         1
+   |         ^ expected `()`, found integer
    |
 help: you might have meant to break the loop with this value
    |
-LL |         break 10;
-   |         ^^^^^   ^
+LL |         break 1;
+   |         ^^^^^  ^
 
-error: aborting due to previous error
+error[E0308]: mismatched types
+  --> $DIR/loop-no-implicit-break.rs:13:9
+   |
+LL |         1
+   |         ^ expected `()`, found integer
+   |
+help: you might have meant to break the loop with this value
+   |
+LL |         break 1;
+   |         ^^^^^  ^
+
+error[E0308]: mismatched types
+  --> $DIR/loop-no-implicit-break.rs:21:9
+   |
+LL |         1
+   |         ^ expected `()`, found integer
+   |
+help: you might have meant to return this value
+   |
+LL |         return 1;
+   |         ^^^^^^  ^
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0308`.