Change:
With: you get: Note how it references "a closure" which seems confusing for a user who doesn't presume the implementation. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim
I'm assuming its ok to leave this as the same error code of E0267 - in essence it's the same error, just more specific text.
Yeah I think it's fine.

Discussion:
use rustc::hir::def_id::DefId; use rustc::hir::map::Map; use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; <del> use rustc::hir::{self, Node, Destination}; </del> <ins> use rustc::hir::{self, Node, Destination, GeneratorMovability}; </ins> use syntax::struct_span_err; use syntax_pos::Span; use errors::Applicability;

Normal, Loop(hir::LoopSource), Closure, <ins> AsyncClosure, </ins> LabeledBlock, AnonConst, }

hir::ExprKind::Loop(ref b, _, source) => { self.with_context(Loop(source), |v| v.visit_block(&b)); } <del> hir::ExprKind::Closure(_, ref function_decl, b, _, _) => { </del> <ins> hir::ExprKind::Closure(_, ref function_decl, b, _, movability) => { let cx = if let Some(GeneratorMovability::Static) = movability { AsyncClosure } else { Closure }; </ins> self.visit_fn_decl(&function_decl); <del> self.with_context(Closure, |v| v.visit_nested_body(b)); </del> <ins> self.with_context(cx, |v| v.visit_nested_body(b)); </ins> } hir::ExprKind::Block(ref b, Some(_label)) => { self.with_context(LabeledBlock, |v| v.visit_block(&b));

.span_label(span, "cannot break inside of a closure") .emit(); } <ins> AsyncClosure => { struct_span_err!(self.sess, span, E0267, "`{}` inside of an async block", name) .span_label(span, "cannot break inside of an async block") .emit(); } </ins> Normal | AnonConst => { struct_span_err!(self.sess, span, E0268, "`{}` outside of loop", name) .span_label(span, "cannot break outside of a loop")

fn no_break_in_async_block() { async { <del> break 0u8; //~ ERROR `break` inside of a closure // FIXME: This diagnostic is pretty bad. </del> <ins> break 0u8; //~ ERROR `break` inside of an async block </ins> }; } fn no_break_in_async_block_even_with_outer_loop() { loop { async { <del> break 0u8; //~ ERROR `break` inside of a closure </del> <ins> break 0u8; //~ ERROR `break` inside of an async block </ins> }; } }

<del> error[E0267]: `break` inside of a closure </del> <ins> error[E0267]: `break` inside of an async block </ins> --> $DIR/async-block-control-flow-static-semantics.rs:35:9 | LL |         break 0u8; <del> |         ^^^^^^^^^ cannot break inside of a closure </del> <ins> |         ^^^^^^^^^ cannot break inside of an async block </ins> <del> error[E0267]: `break` inside of a closure --> $DIR/async-block-control-flow-static-semantics.rs:43:13 </del> <ins> error[E0267]: `break` inside of an async block --> $DIR/async-block-control-flow-static-semantics.rs:42:13 </ins> | LL |             break 0u8; <del> |             ^^^^^^^^^ cannot break inside of a closure </del> <ins> |             ^^^^^^^^^ cannot break inside of an async block </ins> error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:15:43

= note: the return type of a function must have a statically known size error[E0308]: mismatched types <del> --> $DIR/async-block-control-flow-static-semantics.rs:51:44 </del> <ins> --> $DIR/async-block-control-flow-static-semantics.rs:50:44 </ins> | LL | fn rethrow_targets_async_block_not_fn() -> Result<u8, MyErr> { |    ----------------------------------      ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()

found type `()` error[E0308]: mismatched types <del> --> $DIR/async-block-control-flow-static-semantics.rs:60:50 </del> <ins> --> $DIR/async-block-control-flow-static-semantics.rs:59:50 </ins> | LL | fn rethrow_targets_async_block_not_async_fn() -> Result<u8, MyErr> { |    ----------------------------------------      ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()