-
-
Notifications
You must be signed in to change notification settings - Fork 15k
E0507 possibly invalid suggestion to create fresh reborrow for Fn vs FnOnce issue #150175
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
For the following contrived code that should be using
FnOnceinstead ofFn(playground link):The compiler (1.92 stable) generates the following error and suggestions:
The first part of the diagnostics (correctly identifying
!Copy,Fn/FnMutvsFnOnce) is correct and useful, but the second part is somewhat misleading (and I believe the compiler has the necessary information to avoid from suggesting it) as a fresh reborrow wouldn't (directly) resolve the issue (at least, not directly? It would cause further errors becausefooswasn't borrowed asmut, then errors because you're usingFninstead ofFnMut, but if you patch those and assuming you're able to useFnMutinstead ofFnto begin with, it'll work. So I'm not entirely sure whether or not this should be considered a helpful suggestion or not.@rustbot label +T-compiler +A-diagnostics +D-invalid-suggestion +A-closures