diff options
| author | est31 <MTest31@outlook.com> | 2018-05-17 23:50:27 +0200 |
|---|---|---|
| committer | est31 <MTest31@outlook.com> | 2018-05-17 23:54:49 +0200 |
| commit | 7ad9ef3c450e538be87a8be90bfcc5b6c9928791 (patch) | |
| tree | 5ed893c8ebef2ed1d34f7656fe2a9635893ba7a3 | |
| parent | 0e325d0141ce8d86524f55c2df53835aab895096 (diff) | |
| download | rust-7ad9ef3c450e538be87a8be90bfcc5b6c9928791.tar.gz rust-7ad9ef3c450e538be87a8be90bfcc5b6c9928791.zip | |
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.
| -rw-r--r-- | src/librustc_passes/loops.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 2368b1aca69..670097e3a48 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -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)) => { |
