about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Koropoff <bkoropoff@gmail.com>2014-11-08 11:01:06 -0800
committerBrian Koropoff <bkoropoff@gmail.com>2014-11-08 11:07:28 -0800
commitfbc2e92caa63674520edc53c7cb8f49df77b81a8 (patch)
tree89326b7d47d4dcb9d564f572bf9f03976a59abe5 /src
parentb80edf1d1257bf521fd9e62b732b6302258374e7 (diff)
downloadrust-fbc2e92caa63674520edc53c7cb8f49df77b81a8.tar.gz
rust-fbc2e92caa63674520edc53c7cb8f49df77b81a8.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/typeck/check/regionck.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs
index 014180a1155..d47d5649c65 100644
--- a/src/librustc/middle/typeck/check/regionck.rs
+++ b/src/librustc/middle/typeck/check/regionck.rs
@@ -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);