-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NLL: lost "borrowed value needs to live until here" (diagnostic regression compared to AST-borrowck) #54382
Comments
Current output:
the labels look good, but the spans associated with them -- woah... |
Hmm I wonder why the temp is being given the span of the whole block rather than the blocks tail expr |
And likewise, why the drop of the temporary is no longer associated with the span of the semicolon on the whole statement ... |
Triage: While I do want to address this, I don't think we would feel all that inclined to backport a fix to the beta channel. So, tagging as P-high, but removing from the Release milestone. Also, I'm going to assign this to myself since I've taken a special interest in issues involving tail expressions of blocks. |
(I opted to rely on compare-mode=nll rather than opt into `#![feature(nll)]`, mostly to make it easy to observe the interesting differences between the AST-borrwock diagnostic and the NLL one.)
…pans-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. Fix rust-lang#54382
…pans-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. Fix rust-lang#54382
Spun off of my investigation of #21114, #54556
Consider this code (play):
Under AST-borrowck, this emits the diagnostics:
under NLL, it only emits this:
In particular, the note 8 "borrowed value needs to live until here" that highlights the semi-colon after the end of the block is no longer emitted.
My current plan for addressing #54556 is to improve diagnostics. The first step in that path, IMO, would be to figure out how to bring back the note about how long the borrowed value needs to live.
The text was updated successfully, but these errors were encountered: