Fix 'assign to data in an index of' collection suggestions#152216
Fix 'assign to data in an index of' collection suggestions#152216GTimothy wants to merge 3 commits intorust-lang:mainfrom
Conversation
|
rustbot has assigned @JonathanBrouwer. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
8034656 to
2371906
Compare
|
oops, meant to title "Fix 'assign to data in an index of' map suggestions" edit for clarity: for now, these suggestions only apply to BTreeMap and HashMap. rust/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs Lines 657 to 661 in fef627b |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0fedd40 to
77c2a6e
Compare
This comment has been minimized.
This comment has been minimized.
77c2a6e to
5d997ef
Compare
|
@JonathanBrouwer, I think this is ready for review. Do I need to change anything? Thanks in advance. |
|
I'll take a look sometime in the next few days :) |
|
Reminder, once the PR becomes ready for a review, use |
|
thank you @JonathanBrouwer for your remarks. I had made a completely wrong assumptions about the types in questions. |
|
@rustbot ready |
|
@JonathanBrouwer , I have added a test and removed the Copy check. Questions:
|
|
|
I have encountered a couple issues that need to be fixed before this is ready. |
|
The error does not need to be perfect btw, just making it better is already nice :3 |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
bd3d0d0 to
b799514
Compare
This comment has been minimized.
This comment has been minimized.
splits the large triple suggestion into three sets them to MaybeIncorrect automatically determines the required/nicest borrowing to use.
…7 instead of E0594 a set of slightly different tests showing that E0594 can be reached in some cases via autodereferencing, but also that slight variations produce E0277 instead.
b799514 to
9de80d4
Compare
|
@rustbot ready |
View all comments
fixes #150001
fixes rust-lang/rust-analyzer#16076
fixes #134917
The issues are threefold and linked:
collectionBTreeMap/HashMap suggests 3 solutions all marked asMachineApplicableThis PR:
MaybeIncorrectI think this solution may not be very elegant, expecially the key typechecking / borrowing part, but it works. I am however very open to any improvement/change :)
edit: edited to replace 'collection' with BTreeMap/HashMap'