Skip to content

Commit

Permalink
Fix handling of for loop patterns in regionck
Browse files Browse the repository at this point in the history
When establishing region links within a pattern, use the mem-cat
of the type the pattern matches against (that is, the result
of `iter.next()`) rather than that of the iterator type.

Closes #17068
Closes #18767
  • Loading branch information
bkoropoff committed Nov 8, 2014
1 parent b80edf1 commit fbc2e92
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustc/middle/typeck/check/regionck.rs
Expand Up @@ -770,8 +770,12 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {

{
let mc = mc::MemCategorizationContext::new(rcx);
let head_cmt = ignore_err!(mc.cat_expr(&**head));
link_pattern(rcx, mc, head_cmt, &**pat);
let pat_ty = rcx.resolve_node_type(pat.id);
let pat_cmt = mc.cat_rvalue(pat.id,
pat.span,
ty::ReScope(body.id),
pat_ty);
link_pattern(rcx, mc, pat_cmt, &**pat);
}

rcx.visit_expr(&**head);
Expand Down

0 comments on commit fbc2e92

Please sign in to comment.