-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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: need a (new) round of review of deltas between .stderr and .nll.stderr output #52663
Comments
see #49862 for the previous round of review here |
In the details, here's a list of all 226 of the current
|
(I've almost finished the initial review; there are just 32 more diffs for me to look at. But I think it will have to wait until Monday.) |
I have finished my initial scan of all 226 files. (See details link in above comment.) I have tagged 152 of the cases as "on par" with AST-borrowck. That leaves 74 cases that are not up to par. Next, I need to take all of the 74 cases where NLL is not up to par with AST-borrowck, and organize those cases into buckets, so that we get a better idea of how many root issues remain to be resolved. |
I'm going to try making a separate comment for each bucket that I identified; that way each bucket will have a specific URL that one can link within this issue. I'm going to skip the cases where NLL is clearer at (or above) par when compared to AST-borrowck. |
On Par, Assuming Faith In RFC 2005There are two cases where NLL is on par, as long as you are a believer in the new These are the cases:
rust/src/test/ui/issue-40402-ref-hints/issue-40402-2.nll.stderr Lines 1 to 10 in fefe816
|
This comment has been minimized.
This comment has been minimized.
Better Diagnostic for Trait Object CaptureIn https://github.com/rust-lang/rust/blob/fefe81605d6111faa8dbb3635ab2c51d59de740a/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr NLL is on par but it would be nice if instead of "borrow later used here" we provided a more specific message about it being captured by a trait object (I presume its that object's destructor that is source of the use referenced here). Has PR: #54848 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
NLL diagnostic for
|
This comment has been minimized.
This comment has been minimized.
The "Later used here" diagnostic is not ideal for return valuesIn this:
Edit: improved by #53177. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
NLL Diagnostic RedundancyIn the following tests we report certain lines as errors two extra times each.
And in the following test we have errors once per match arm rather than AST-borrowck's once per match:
|
This comment has been minimized.
This comment has been minimized.
NLL chooses not great span in its "lifetime required" messageAll of these tests it seems like NLL is choosing a strictly worse span for is suggestion than the span suggested by AST-borrowck:
|
This comment has been minimized.
This comment has been minimized.
NLL fails to report lifetime mismatch errorIn these cases NLL is failing to report a lifetime mismatch error
|
This comment has been minimized.
This comment has been minimized.
I believe that test can be removed outright. It'd be impossible for a new change to go through that breaks this kind of output without it being picked up by multiple other |
Much has changed since this review was done. Not only in the implementation of NLL (which has advanced considerably), but also the test suite, where things like PR #53196 have added a slew of new (For an example of a So, what to do... I think the right thing is to open an entirely fresh ticket saying we need a third (and hopefully final?) round of review.
|
I'm leaving this ticket open right now, despite having opened #54528, under the theory that until effort on #54528 starts, there is useful information in the table on this ticket that could still guide ongoing efforts to improve NLL. However, as soon as anyone starts working on the review associated with #54528, they should probably close this ticket (#52663), in order to encourage there be at most one central location for tracking the differences in NLL diagnostic output. |
…ime-suggestion-test, r=nikomatsakis Remove unneccessary error from test, revealing NLL error. Part of rust-lang#52663. Removes unnecessary type mismatch error from test that was hiding borrow check error from NLL stderr. r? @nikomatsakis
…suggestion, r=nikomatsakis NLL is missing struct field suggestion Part of rust-lang#52663. This commit adds suggestions to change the definitions of fields in struct definitions from immutable references to mutable references. r? @nikomatsakis cc @pnkfelix
… r=nikomatsakis Better Diagnostic for Trait Object Capture Part of rust-lang#52663. This commit enhances `LaterUseKind` detection to identify when a borrow is captured by a trait object which helps explain why there is a borrow error. r? @nikomatsakis cc @pnkfelix
… r=nikomatsakis NLL is missing struct field suggestion Part of #52663. This commit adds suggestions to change the definitions of fields in struct definitions from immutable references to mutable references. r? @nikomatsakis cc @pnkfelix
…akis Better Diagnostic for Trait Object Capture Part of #52663. This commit enhances `LaterUseKind` detection to identify when a borrow is captured by a trait object which helps explain why there is a borrow error. r? @nikomatsakis cc @pnkfelix
…nter, r=pnkfelix NLL says "borrowed content" instead of more precise "dereference of raw pointer" Part of rust-lang#52663. Previously, move errors involving the dereference of a raw pointer would say "borrowed content". This commit changes it to say "dereference of raw pointer". r? @nikomatsakis cc @pnkfelix
…nter, r=pnkfelix NLL says "borrowed content" instead of more precise "dereference of raw pointer" Part of rust-lang#52663. Previously, move errors involving the dereference of a raw pointer would say "borrowed content". This commit changes it to say "dereference of raw pointer". r? @nikomatsakis cc @pnkfelix
…=nikomatsakis NLL lacks various special case handling of closures Part of #52663. Firstly, this PR extends existing handling of closures to also support generators. Second, this PR adds the note found in the AST when a closure is invoked twice and captures a variable by-value: ```text note: closure cannot be invoked more than once because it moves the variable `dict` out of its environment --> $DIR/issue-42065.rs:16:29 | LL | for (key, value) in dict { | ^^^^ ``` r? @nikomatsakis cc @pnkfelix
closing as I am starting on #54528 now. |
This is based on the feedback from estebank: """ I believe that test can be removed outright. It'd be impossible for a new change to go through that breaks this kind of output without it being picked up by multiple other `stderr` tests. This is an artifact of the transition period to the "new" output style. """ see: rust-lang#52663 (comment)
We have made a lot of progress on NLL diagnostics
So much so that it behooves us to take a step back and reevaluate where we stand with respect to overall diagnostic quality.
As part of that, we should do another round of review of the differences between AST borrowck diagnostic output and NLL borrowck diagnostic output.
Update: I finished the review, and have put the cases where NLL is not up to par into "buckets." Each bucket has a linked comment on this issue (and, in some cases, a separate issue that is linked from that comment and from the description here).
Here are all the buckets (with links to each specific comment):
like so).Sort By SpanBetter Diagnostic When "Later" means "A Future Loop Iteration"NLL Spans Show Hypothetical CodeNLL diagnostic is globally bad ... but locally justifiable?The "Later used here" diagnostic is not ideal for return valuesProvide span for declaration of captured variablesNLL is missing struct field suggestionmissing lifetime in suggestionNLL fails to suggest + bound on trait object"does not live long enough" when talking about a (thread-local) staticNLL missing suggestion to extend lifetimes via let bindingsNLL didn't fix interaction of local dying with temps in dropckNLL mentions lifetimes that are not included in printed span(s).FnMut
closure where AST-borrowck accepted itThe text was updated successfully, but these errors were encountered: