about summary refs log tree commit diff
path: root/src/librustc_error_codes/error_codes
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2020-06-25 15:16:38 +0100
committerDavid Wood <david@davidtw.co>2020-07-02 13:48:32 +0100
commitcb541dc12cdf2ba14a8f5d210ac7a6b1efa69c22 (patch)
treeffa00e1d79b5033bdb8e4aa51a92726e942842a1 /src/librustc_error_codes/error_codes
parentb7856f695d65a8ebc846754f97d15814bcb1c244 (diff)
downloadrust-cb541dc12cdf2ba14a8f5d210ac7a6b1efa69c22.tar.gz
rust-cb541dc12cdf2ba14a8f5d210ac7a6b1efa69c22.zip
resolve: disallow label use through closure/async
This commit modifies resolve to disallow `break`/`continue` to labels
through closures or async blocks. This doesn't make sense and should
have been prohibited anyway.

Signed-off-by: David Wood <david@davidtw.co>
Diffstat (limited to 'src/librustc_error_codes/error_codes')
-rw-r--r--src/librustc_error_codes/error_codes/E0767.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/librustc_error_codes/error_codes/E0767.md b/src/librustc_error_codes/error_codes/E0767.md
new file mode 100644
index 00000000000..679fe7e41e9
--- /dev/null
+++ b/src/librustc_error_codes/error_codes/E0767.md
@@ -0,0 +1,20 @@
+An unreachable label was used.
+
+Erroneous code example:
+
+```compile_fail,E0767
+'a: loop {
+    || {
+        loop { break 'a } // error: use of unreachable label `'a`
+    };
+}
+```
+
+Ensure that the label is within scope. Labels are not reachable through
+functions, closures, async blocks or modules. Example:
+
+```
+'a: loop {
+    break 'a; // ok!
+}
+```