Skip to content

Commit

Permalink
CheckLoopVisitor: also visit closure arguments
Browse files Browse the repository at this point in the history
This turns an ICE on this code:

fn main() {
    |_: [u8; break]| ();
}

from
    'assertion failed: self.tcx.sess.err_count() > 0', librustc_typeck/check/mod.rs
to
    librustc_mir/hair/cx/expr.rs:543: invalid loop id for break: not inside loop scope

which is at a later stage during compilation and most importantly
fixes of bug #50576 will fix this as well.
  • Loading branch information
est31 committed May 17, 2018
1 parent 0e325d0 commit 7ad9ef3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_passes/loops.rs
Expand Up @@ -82,7 +82,8 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
hir::ExprLoop(ref b, _, source) => {
self.with_context(Loop(LoopKind::Loop(source)), |v| v.visit_block(&b));
}
hir::ExprClosure(.., b, _, _) => {
hir::ExprClosure(_, ref function_decl, b, _, _) => {
self.visit_fn_decl(&function_decl);
self.with_context(Closure, |v| v.visit_nested_body(b));
}
hir::ExprBlock(ref b, Some(_label)) => {
Expand Down

0 comments on commit 7ad9ef3

Please sign in to comment.