Fix debugger stepping behavior around match expressions

Previously, we would set up the source lines for `match` expressions so
that the code generated to perform the test of the scrutinee was matched
to the line of the arm that required the test and then jump from the arm
block to the "next" block was matched to all of the lines in the `match`
expression.

While that makes sense, it has the side effect of causing strange
stepping behavior in debuggers.

I've changed the source information so that all of the generated tests
are sourced to `match {scrutinee}` and the jumps are sourced to the last
line of the block they are inside. This resolves the weird stepping
behavior in all debuggers and resolves some instances of "ambiguous
symbol" errors in WinDbg preventing the user from setting breakpoints at
`match` expressions.
This commit is contained in:
Wesley Wiser 2021-07-23 18:55:36 -04:00
parent a992a11913
commit 0a42dfc2fa
92 changed files with 533 additions and 482 deletions

View file

@ -15,8 +15,8 @@ impl Drop for Enum {
fn main() {
let foo = X(1);
drop(foo);
match foo {
X(1) => (), //~ ERROR use of moved value
match foo { //~ ERROR use of moved value
X(1) => (),
_ => unreachable!()
}

View file

@ -1,13 +1,12 @@
error[E0382]: use of moved value: `foo`
--> $DIR/issue-17385.rs:19:11
--> $DIR/issue-17385.rs:18:5
|
LL | let foo = X(1);
| --- move occurs because `foo` has type `X`, which does not implement the `Copy` trait
LL | drop(foo);
| --- value moved here
LL | match foo {
LL | X(1) => (),
| ^ value used here after move
| ^^^^^^^^^ value used here after move
error[E0382]: use of moved value: `e`
--> $DIR/issue-17385.rs:25:11