You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#55781 - pnkfelix:issue-54382-more-precise-spans-for-temps-and-their-drops, r=davidtwco
More precise spans for temps and their drops
This PR has two main enhancements:
1. when possible during code generation for a statement (like `expr();`), pass along the span of a statement, and then attribute the drops of temporaries from that statement to the statement's end-point (which will be the semicolon if it is a statement that is terminating by a semicolon).
2. when evaluating a block expression into a MIR temp, use the span of the block's tail expression (rather than the span of whole block including its statements and curly-braces) for the span of the temp.
Each of these individually increases the precision of our diagnostic output; together they combine to make a much clearer picture about the control flow through the spans.
Fixrust-lang#54382
| a temporary with access to the borrow is created here ...
9
+
LL | }
10
+
LL | }
11
+
| - `_thing1` dropped here while still borrowed
12
+
LL |
13
+
LL | ;
14
+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D`
15
+
|
16
+
= note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped.
17
+
18
+
error: aborting due to previous error
19
+
20
+
For more information about this error, try `rustc --explain E0597`.
0 commit comments