Suggest alternatives when trying to mutate a HashMap/BTreeMap via indexing#100906
Merged
bors merged 1 commit intorust-lang:masterfrom Aug 24, 2022
Merged
Suggest alternatives when trying to mutate a HashMap/BTreeMap via indexing#100906bors merged 1 commit intorust-lang:masterfrom
HashMap/BTreeMap via indexing#100906bors merged 1 commit intorust-lang:masterfrom
Conversation
Contributor
|
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
davidtwco
approved these changes
Aug 23, 2022
Member
davidtwco
left a comment
There was a problem hiding this comment.
LGTM, just some wording suggestions then r=me
5934422 to
a3d2bc5
Compare
… indexing The error can be quite confusing to newcomers.
a3d2bc5 to
b0255a1
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Member
|
@bors r+ |
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Aug 24, 2022
…avidtwco Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexing The error can be quite confusing to newcomers. Fixes rust-lang#100873. I'm not so sure about the message, open to wording suggestions.
Contributor
|
CC #45491 |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 24, 2022
…iaskrgr Rollup of 15 pull requests Successful merges: - rust-lang#99993 (linker: Update some outdated comments) - rust-lang#100220 (Properly forward `ByRefSized::fold` to the inner iterator) - rust-lang#100826 (sugg: take into count the debug formatting) - rust-lang#100855 (Extra documentation for new formatting feature) - rust-lang#100888 (Coherence negative impls implied bounds) - rust-lang#100901 (Make some methods private) - rust-lang#100906 (Suggest alternatives when trying to mutate a `HashMap`/`BTreeMap` via indexing) - rust-lang#100912 (Diagnose missing includes in run-make tests) - rust-lang#100919 (Use par_body_owners for liveness) - rust-lang#100922 (Rewrite error index generator to greatly reduce the size of the pages) - rust-lang#100926 (Update README.md) - rust-lang#100930 (Use `--userns=keep-id` when "docker" is really podman) - rust-lang#100938 (rustdoc: remove unused CSS rule) - rust-lang#100940 (Do not suggest adding a bound to a opaque type) - rust-lang#100945 (Add a missing test case for impl generic mismatch) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
eddyb
reviewed
Sep 2, 2022
Comment on lines
+638
to
+641
| if self.infcx.tcx.is_diagnostic_item(sym::HashMap, did) | ||
| || self.infcx.tcx.is_diagnostic_item(sym::BTreeMap, did) | ||
| { | ||
| err.help(format!("to modify a `{ty}`, use `.get_mut()`, `.insert()` or the entry API")); |
Member
There was a problem hiding this comment.
Huh, was entirely expecting #[rustc_on_unimplemented] to be used for this, is that not available here?
Contributor
Author
There was a problem hiding this comment.
Yeah, checked that, but it doesn't work for some reason. I guess this doesn't go through the usual infra for traits lookup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The error can be quite confusing to newcomers.
Fixes #100873.
I'm not so sure about the message, open to wording suggestions.