-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Suggest use .get_mut
instead of &mut
when occur HashMap
and BtreeMap
#144018
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
base: master
Are you sure you want to change the base?
Conversation
You need to compare the defid with the defid of the HashMap/BTreeMap diagnostic item and hard code the special case |
Signed-off-by: xizheyin <[email protected]>
.get_mut
instead of &mut
when occur HashMap
and BtreeMap
…reeMap` Signed-off-by: xizheyin <[email protected]>
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.
The second commit shows the testcase difference.
}) = self.body[location.block].statements.get(location.statement_index) | ||
&& let BorrowedContentSource::OverloadedIndex(ty) = | ||
self.borrowed_content_source(place.as_ref()) | ||
&& let Some(def) = ty.ty_adt_def() | ||
&& (self.infcx.tcx.is_diagnostic_item(sym::HashMap, def.did()) | ||
|| self.infcx.tcx.is_diagnostic_item(sym::BTreeMap, def.did())) | ||
{ | ||
true | ||
} else { | ||
false |
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.
In this version, I hard code HashMap
and BTreeMap
using judge def_id
of the borrwoed_content_source
's ty
.
In your first version you checked if the assignment on the type came from an overloaded index. You should check whether the overloaded index type implements @rustbot author |
Reminder, once the PR becomes ready for a review, use |
Fixes #143732
r? compiler