File tree Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -602,15 +602,47 @@ const Y: u32 = X;
602
602
603
603
E0267 : r##"
604
604
This error indicates the use of a loop keyword (`break` or `continue`) inside a
605
- closure but outside of any loop. Break and continue can be used as normal inside
606
- closures as long as they are also contained within a loop. To halt the execution
607
- of a closure you should instead use a return statement.
605
+ closure but outside of any loop. Erroneous code example:
606
+
607
+ ```
608
+ let w = || { break; }; // error: `break` inside of a closure
609
+ ```
610
+
611
+ `break` and `continue` keywords can be used as normal inside closures as long as
612
+ they are also contained within a loop. To halt the execution of a closure you
613
+ should instead use a return statement. Example:
614
+
615
+ ```
616
+ let w = || {
617
+ for _ in 0..10 {
618
+ break;
619
+ }
620
+ };
621
+
622
+ w();
623
+ ```
608
624
"## ,
609
625
610
626
E0268 : r##"
611
627
This error indicates the use of a loop keyword (`break` or `continue`) outside
612
628
of a loop. Without a loop to break out of or continue in, no sensible action can
613
- be taken.
629
+ be taken. Erroneous code example:
630
+
631
+ ```
632
+ fn some_func() {
633
+ break; // error: `break` outside of loop
634
+ }
635
+ ```
636
+
637
+ Please verify that you are using `break` and `continue` only in loops. Example:
638
+
639
+ ```
640
+ fn some_func() {
641
+ for _ in 0..10 {
642
+ break; // ok!
643
+ }
644
+ }
645
+ ```
614
646
"## ,
615
647
616
648
E0271 : r##"
You can’t perform that action at this time.
0 commit comments