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:
parent
b80edf1d12
commit
fbc2e92caa
1 changed files with 6 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue