diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 4e251793f6917..eab16bd5bd1b5 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -77,10 +77,14 @@ impl<'a> CheckLoopVisitor<'a> { match self.cx { Loop => {} Closure => { - span_err!(self.sess, span, E0267, "`{}` inside of a closure", name); + struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name) + .span_label(span, &format!("cannot break inside of a closure")) + .emit(); } Normal => { - span_err!(self.sess, span, E0268, "`{}` outside of loop", name); + struct_span_err!(self.sess, span, E0268, "`{}` outside of loop", name) + .span_label(span, &format!("cannot break outside of a loop")) + .emit(); } } } diff --git a/src/test/compile-fail/E0267.rs b/src/test/compile-fail/E0267.rs index 6287256e866c9..b58fbce8bc648 100644 --- a/src/test/compile-fail/E0267.rs +++ b/src/test/compile-fail/E0267.rs @@ -10,4 +10,5 @@ fn main() { let w = || { break; }; //~ ERROR E0267 + //~| NOTE cannot break inside of a closure } diff --git a/src/test/compile-fail/E0268.rs b/src/test/compile-fail/E0268.rs index 41e88e2f492a9..3313e07667a1c 100644 --- a/src/test/compile-fail/E0268.rs +++ b/src/test/compile-fail/E0268.rs @@ -10,4 +10,5 @@ fn main() { break; //~ ERROR E0268 + //~| NOTE cannot break outside of a loop }