about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-07 09:41:12 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-10 08:35:23 +0100
commit65b7ba5129bf1f32be78379255c921c08126c97f (patch)
tree529952e9eb3241498c453980c8b73967ea13d7fa
parent83be689b947d391360a965660cba0f3baf1c062e (diff)
downloadrust-65b7ba5129bf1f32be78379255c921c08126c97f.tar.gz
rust-65b7ba5129bf1f32be78379255c921c08126c97f.zip
parser: add note for `'label expr`.
-rw-r--r--src/librustc_parse/parser/expr.rs1
-rw-r--r--src/test/ui/parser/labeled-no-colon-expr.stderr12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index bab6a58296d..826213ba450 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -1121,6 +1121,7 @@ impl<'a> Parser<'a> {
                 ": ".to_string(),
                 Applicability::MachineApplicable,
             )
+            .note("labels are used before loops and blocks, allowing e.g., `break 'label` to them")
             .emit();
     }
 
diff --git a/src/test/ui/parser/labeled-no-colon-expr.stderr b/src/test/ui/parser/labeled-no-colon-expr.stderr
index a69532555d4..4f5e8f78aa0 100644
--- a/src/test/ui/parser/labeled-no-colon-expr.stderr
+++ b/src/test/ui/parser/labeled-no-colon-expr.stderr
@@ -6,6 +6,8 @@ LL |     'l0 while false {}
    |     |  |
    |     |  help: add `:` after the label
    |     the label
+   |
+   = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
 
 error: labeled expression must be followed by `:`
   --> $DIR/labeled-no-colon-expr.rs:5:5
@@ -15,6 +17,8 @@ LL |     'l1 for _ in 0..1 {}
    |     |  |
    |     |  help: add `:` after the label
    |     the label
+   |
+   = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
 
 error: labeled expression must be followed by `:`
   --> $DIR/labeled-no-colon-expr.rs:6:5
@@ -24,6 +28,8 @@ LL |     'l2 loop {}
    |     |  |
    |     |  help: add `:` after the label
    |     the label
+   |
+   = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
 
 error: labeled expression must be followed by `:`
   --> $DIR/labeled-no-colon-expr.rs:7:5
@@ -33,6 +39,8 @@ LL |     'l3 {}
    |     |  |
    |     |  help: add `:` after the label
    |     the label
+   |
+   = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
 
 error: expected `while`, `for`, `loop` or `{` after a label
   --> $DIR/labeled-no-colon-expr.rs:8:9
@@ -48,6 +56,8 @@ LL |     'l4 0;
    |     |  |
    |     |  help: add `:` after the label
    |     the label
+   |
+   = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
 
 error: cannot use a `block` macro fragment here
   --> $DIR/labeled-no-colon-expr.rs:13:17
@@ -72,6 +82,8 @@ LL |             'l5 $b;
 ...
 LL |     m!({});
    |        ^^
+   |
+   = note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
 
 error: aborting due to 8 previous errors