Skip to content

Commit 7ad9ef3

Browse files
committed
CheckLoopVisitor: also visit closure arguments
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.
1 parent 0e325d0 commit 7ad9ef3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustc_passes/loops.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
8282
hir::ExprLoop(ref b, _, source) => {
8383
self.with_context(Loop(LoopKind::Loop(source)), |v| v.visit_block(&b));
8484
}
85-
hir::ExprClosure(.., b, _, _) => {
85+
hir::ExprClosure(_, ref function_decl, b, _, _) => {
86+
self.visit_fn_decl(&function_decl);
8687
self.with_context(Closure, |v| v.visit_nested_body(b));
8788
}
8889
hir::ExprBlock(ref b, Some(_label)) => {

0 commit comments

Comments
 (0)