-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest alternatives when trying to mutate a HashMap
/BTreeMap
via indexing
#100906
Conversation
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@bors r+ |
…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.
CC #45491 |
…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
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")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, was entirely expecting #[rustc_on_unimplemented]
to be used for this, is that not available here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, checked that, but it doesn't work for some reason. I guess this doesn't go through the usual infra for traits lookup.
The error can be quite confusing to newcomers.
Fixes #100873.
I'm not so sure about the message, open to wording suggestions.