mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 09:53:04 +03:00
11610db252
Fix 'assign to data in an index of' collection suggestions fixes https://github.com/rust-lang/rust/issues/150001 fixes https://github.com/rust-lang/rust-analyzer/issues/16076 fixes https://github.com/rust-lang/rust/issues/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'