]> git.lizzy.rs Git - rust.git/commit
Drop tracking: improve break and continue handling
authorEric Holk <ericholk@microsoft.com>
Wed, 26 Jan 2022 00:13:07 +0000 (16:13 -0800)
committerEric Holk <ericholk@microsoft.com>
Tue, 8 Feb 2022 00:30:30 +0000 (16:30 -0800)
commitc37a906db56e5cd3699cdc385af9320615ca0064
tree6489ef06f2ed62fa42381d5992f467978cffda7b
parent29185844c48499278b4a713e9a40f1a6d0437eba
Drop tracking: improve break and continue handling

This commit fixes two issues.

One, sometimes break or continue have a block target instead of an
expression target. This seems to mainly happen with try blocks. Since
the drop tracking analysis only works on expressions, if we see a block
target for break or continue, we substitute the last expression of the
block as the target instead.

Two, break and continue were incorrectly being treated as the same, so
continue would also show up as an exit from the loop or block. This
patch corrects the way continue is handled by keeping a stack of loop
entry points and uses those to find the target of the continue.
compiler/rustc_ast/src/ast.rs
compiler/rustc_typeck/src/check/generator_interior/drop_ranges/cfg_build.rs
src/test/ui/async-await/issue-93197.rs
src/test/ui/generator/drop-control-flow.rs