about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_typeck/check/mod.rs7
-rw-r--r--src/test/compile-fail/issue-43162.rs1
-rw-r--r--src/test/ui/issue-50576.rs16
-rw-r--r--src/test/ui/issue-50576.stderr22
-rw-r--r--src/test/ui/issue-50581.rs13
-rw-r--r--src/test/ui/issue-50581.stderr9
6 files changed, 66 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 70d299437a6..16695dcef8f 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3764,6 +3764,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                   }
 
                   ctxt.may_break = true;
+
+                  // the type of a `break` is always `!`, since it diverges
+                  tcx.types.never
               } else {
                   // Otherwise, we failed to find the enclosing loop;
                   // this can only happen if the `break` was not
@@ -3784,10 +3787,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                           }
                       }
                   }
+                  // There was an error, make typecheck fail
+                  tcx.types.err
               }
 
-              // the type of a `break` is always `!`, since it diverges
-              tcx.types.never
           }
           hir::ExprAgain(_) => { tcx.types.never }
           hir::ExprRet(ref expr_opt) => {
diff --git a/src/test/compile-fail/issue-43162.rs b/src/test/compile-fail/issue-43162.rs
index 8f4661299e9..b236283f757 100644
--- a/src/test/compile-fail/issue-43162.rs
+++ b/src/test/compile-fail/issue-43162.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 fn foo() -> bool {
+    //~^ ERROR E0308
     break true; //~ ERROR E0268
 }
 
diff --git a/src/test/ui/issue-50576.rs b/src/test/ui/issue-50576.rs
new file mode 100644
index 00000000000..b2032fb226b
--- /dev/null
+++ b/src/test/ui/issue-50576.rs
@@ -0,0 +1,16 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    |bool: [u8; break 'L]| 0;
+    //~^ ERROR [E0426]
+    //~| ERROR [E0268]
+    Vec::<[u8; break]>::new(); //~ ERROR [E0268]
+}
diff --git a/src/test/ui/issue-50576.stderr b/src/test/ui/issue-50576.stderr
new file mode 100644
index 00000000000..e661be21339
--- /dev/null
+++ b/src/test/ui/issue-50576.stderr
@@ -0,0 +1,22 @@
+error[E0426]: use of undeclared label `'L`
+  --> $DIR/issue-50576.rs:12:23
+   |
+LL |     |bool: [u8; break 'L]| 0;
+   |                       ^^ undeclared label `'L`
+
+error[E0268]: `break` outside of loop
+  --> $DIR/issue-50576.rs:12:17
+   |
+LL |     |bool: [u8; break 'L]| 0;
+   |                 ^^^^^^^^ cannot break outside of a loop
+
+error[E0268]: `break` outside of loop
+  --> $DIR/issue-50576.rs:15:16
+   |
+LL |     Vec::<[u8; break]>::new(); //~ ERROR [E0268]
+   |                ^^^^^ cannot break outside of a loop
+
+error: aborting due to 3 previous errors
+
+Some errors occurred: E0268, E0426.
+For more information about an error, try `rustc --explain E0268`.
diff --git a/src/test/ui/issue-50581.rs b/src/test/ui/issue-50581.rs
new file mode 100644
index 00000000000..97b3f81eaf5
--- /dev/null
+++ b/src/test/ui/issue-50581.rs
@@ -0,0 +1,13 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    |_: [u8; break]| (); //~ ERROR [E0268]
+}
diff --git a/src/test/ui/issue-50581.stderr b/src/test/ui/issue-50581.stderr
new file mode 100644
index 00000000000..38a87b1e78a
--- /dev/null
+++ b/src/test/ui/issue-50581.stderr
@@ -0,0 +1,9 @@
+error[E0268]: `break` outside of loop
+  --> $DIR/issue-50581.rs:12:14
+   |
+LL |     |_: [u8; break]| (); //~ ERROR [E0268]
+   |              ^^^^^ cannot break outside of a loop
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0268`.