Skip to content

Commit 1b13ca4

Browse files
committed
remove copy/clone check on type of index
1 parent 062ab4f commit 1b13ca4

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -729,10 +729,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
729729
false
730730
}
731731
}
732-
/// checking if the key is copy clone
733-
fn key_is_copyclone<'tcx>(key: Ty<'tcx>) -> bool {
734-
key.is_trivially_pure_clone_copy()
735-
}
736732

737733
// we know ty is a map, with a key type at walk distance 2.
738734
let key_type = self.ty.walk().nth(1).unwrap().expect_ty();
@@ -743,11 +739,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
743739
{
744740
let index_ty =
745741
self.infcx.tcx.typeck(val.hir_id.owner.def_id).expr_ty(index);
746-
// only suggest `insert` and `entry` if K is copy/clone because of the signature.
742+
// only suggest `insert` and `entry` if index is of type K or &K.
747743
let index_is_borrowed_key = index_is_borrowed_key(index_ty, key_type);
748-
if (index_is_borrowed_key
749-
|| index_and_key_are_same_borrowed_type(index_ty, key_type))
750-
&& key_is_copyclone(key_type)
744+
if index_is_borrowed_key
745+
|| index_and_key_are_same_borrowed_type(index_ty, key_type)
751746
{
752747
let offset = BytePos(index_is_borrowed_key as u32);
753748
self.err.multipart_suggestion(

0 commit comments

Comments
 (0)