-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 fails to suggest "try removing &mut
here"
#51191
Comments
We might be able to incorporate a fix for this into #51275 ; I haven't quite dug into how we detect this case yet. But its worth at least looking into as part of that PR. |
(at this point I have indeed incorporated a fix for this into #51275 ) |
(except that my fix, in the case of did_you_mean/issue-31424.rs, is suggesting to the user that they write |
…ermissions, r=nikomatsakis NLL diagnostics: revise `fn check_access_permissions` NLL: revise `fn check_access_permissions` so that its (still branchy) shares more code paths between the different cases, and also provide more diagnostics in more cases (though the added diagnostics still do not always meet the quality bar established by AST-borrowck) ---- Transcribing "checklist" suggested by Niko, except I am rendering it as a table to make it clear that I do not regard every item in the list to be a "must have" for landing this PR. goal | does this PR do it? -----|------------------------------ no suggestions for `ref mut` | yes suggestions for direct local assignment (`{ let x = 3; x = 4; }`) | yes (see commits at end) suggestions for direct field assignment (`{ let x = (3, 4); x.0 = 5; }` | yes (see commits at end) suggestions for upvars (`let x = 3; let c = \|\| { &mut x; }`) | yes Note that I added support for a couple of rows via changes that are not strictly part of `fn check_access_permissions`. If desired I can remove those commits from this PR and leave them for a later PR. Fix #51031 Fix #51032 (bug #51191 needs a little more investigation before closing.) Fix #51578
To clarify the current situation. For issue-31424.rs, the AST-based checker gives this error:
and the NLL one gives this one:
Note that the hint is missing from the NLL one. |
This doesn't seem to me to rise to the cut of a Edition Preview blocker, or even a RC blocker. |
I'll tag with the Release milestone for now, though I think it could plausibly be cut. |
NLL fails to suggest "try removing `&mut` here" Fixes #51191. This PR adds ``try removing `&mut` here`` suggestions to functions where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`. This PR also enables the suggestion for adding a `mut` pattern to by-value implicit self arguments without `mut` patterns already. r? @nikomatsakis
For the following tests, AST-borrowck suggests removing
&mut
, while NLL fails to make such a suggestion:fn check_access_permissions
#51275)fn check_access_permissions
#51275)fn check_access_permissions
#51275)The text was updated successfully, but these errors were encountered: