about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2022-11-05 01:11:50 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2022-11-05 01:12:58 +0000
commit2f882c014f3bfabb811177d24bfb72e3f6b6d271 (patch)
tree8bf53e1ae1943a2c7f22c62fe72993892380f959 /compiler/rustc_passes/src
parent09508489efc223287731fe8abbd2a81bbf7adf8e (diff)
downloadrust-2f882c014f3bfabb811177d24bfb72e3f6b6d271.tar.gz
rust-2f882c014f3bfabb811177d24bfb72e3f6b6d271.zip
Specify that `break` cannot be used outside of loop *or* labeled block
Diffstat (limited to 'compiler/rustc_passes/src')
-rw-r--r--compiler/rustc_passes/src/errors.rs1
-rw-r--r--compiler/rustc_passes/src/loops.rs2
2 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs
index d8bed700f52..1dbf0d642e2 100644
--- a/compiler/rustc_passes/src/errors.rs
+++ b/compiler/rustc_passes/src/errors.rs
@@ -956,6 +956,7 @@ pub struct OutsideLoop<'a> {
     #[label]
     pub span: Span,
     pub name: &'a str,
+    pub is_break: bool,
 }
 
 #[derive(Diagnostic)]
diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs
index 077194ec687..b4cf19e4a34 100644
--- a/compiler/rustc_passes/src/loops.rs
+++ b/compiler/rustc_passes/src/loops.rs
@@ -193,7 +193,7 @@ impl<'a, 'hir> CheckLoopVisitor<'a, 'hir> {
                 self.sess.emit_err(BreakInsideAsyncBlock { span, closure_span, name });
             }
             Normal | AnonConst => {
-                self.sess.emit_err(OutsideLoop { span, name });
+                self.sess.emit_err(OutsideLoop { span, name, is_break: name == "break" });
             }
         }
     }