]> git.lizzy.rs Git - rust.git/commit
Fix HIR visit order
authorAaron Hill <aa1ronham@gmail.com>
Wed, 5 Jun 2019 23:54:34 +0000 (19:54 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sat, 22 Jun 2019 20:00:48 +0000 (16:00 -0400)
commit9d0960a6f8fbd561b2f5d9fb54ba49d533f61832
tree4b52f8cca53781e6f903f61aed4f02366af94009
parent4a365a29d64bec75d107214319a129ba68fc12a3
Fix HIR visit order

Fixes #61442

When rustc::middle::region::ScopeTree ccomputes its yield_in_scope
field, it relies on the HIR visitor order to properly compute which
types must be live across yield points. In order for the computed scopes
to agree with the generated MIR, we must ensure that expressions
evaluated before a yield point are visited before the 'yield'
expression.

However, the visitor order for ExprKind::AssignOp
was incorrect. The left-hand side of a compund assignment expression is
evaluated before the right-hand side, but the right-hand expression was
being visited before the left-hand expression. If the left-hand
expression caused a new type to be introduced (e.g. through a
deref-coercion), the new type would be incorrectly seen as occuring
*after* the yield point, instead of before. This leads to a mismatch
between the computed generator types and the MIR, since the MIR will
correctly see the type as being live across the yield point.

To fix this, we correct the visitor order for ExprKind::AssignOp
to reflect the actual evaulation order.
src/librustc/hir/intravisit.rs
src/test/run-pass/issues/issue-61442.rs [new file with mode: 0644]