Fix 'assign to data in an index of' collection suggestions#152216
Fix 'assign to data in an index of' collection suggestions#152216rust-bors[bot] merged 4 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 |
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 |
added a valid example that violated the assumption in the proposed change: it is possible for a borrowee type to be a ref of it's borrowed type. removed the assumption, treated all cases appropriately.
3c912e3 to
5f1e962
Compare
|
@rustbot ready |
|
@bors r+ rollup |
…uwer Rollup of 4 pull requests Successful merges: - #156073 ([rustdoc] Fix `doc_cfg` feature on reexports) - #152216 (Fix 'assign to data in an index of' collection suggestions) - #155433 (Rip out rustc_layout_scalar_valid_range_* attribute support) - #156098 (Hand-implement `impl Debug for NumBuffer` to avoid constraining `T` or printing MaybeUninit)
Rollup merge of #152216 - GTimothy:map-diagnostics-fix, r=JonathanBrouwer Fix 'assign to data in an index of' collection suggestions fixes #150001 fixes rust-lang/rust-analyzer#16076 fixes #134917 The issues are threefold and linked: 1. Assigning data to a ~~collection~~BTreeMap/HashMap suggests 3 solutions all marked as `MachineApplicable` 2. The suggestions are slightly wrong with regards to their borrowing needs. 3. The suggestions are not guaranteed to produce code that is valid, and suggestion number two is equivalent to an update, not an insertion. This PR: - splits the large triple suggestion into three - sets them to `MaybeIncorrect` - automatically determines the required borrowing to use. I 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'
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'