From 05a5a1128fc5da178f9b7bd0ab499258652dfc49 Mon Sep 17 00:00:00 2001
From: Tor Hovland <tor.hovland@bekk.no>
Date: Sat, 24 Apr 2021 19:00:24 +0200
Subject: [PATCH] More tests.

---
 src/test/ui/loops/loop-no-implicit-break.rs   | 26 +++++++++++++--
 .../ui/loops/loop-no-implicit-break.stderr    | 32 ++++++++++++++++---
 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`.