Fix handling of for loop patterns in regionck

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
This commit is contained in:
Brian Koropoff 2014-11-08 11:01:06 -08:00
parent b80edf1d12
commit fbc2e92caa

View file

@ -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);