@@ -6,7 +6,6 @@ use rustc_errors::{Applicability, Diagnostic};
6
6
use rustc_hir as hir;
7
7
use rustc_hir:: def:: { CtorKind , Namespace } ;
8
8
use rustc_hir:: GeneratorKind ;
9
- use rustc_hir_analysis:: hir_ty_to_ty;
10
9
use rustc_infer:: infer:: TyCtxtInferExt ;
11
10
use rustc_middle:: mir:: tcx:: PlaceTy ;
12
11
use rustc_middle:: mir:: {
@@ -1137,7 +1136,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1137
1136
&& Some ( def. did ( ) ) == self . infcx . tcx . lang_items ( ) . pin_type ( )
1138
1137
&& let ty:: Ref ( _, _, hir:: Mutability :: Mut ) = substs. type_at ( 0 ) . kind ( )
1139
1138
// FIXME: this is a hack because we can't call `can_eq`
1140
- && ty. to_string ( ) ==
1139
+ && ty. to_string ( ) ==
1141
1140
tcx. fn_sig ( method_did) . input ( 0 ) . skip_binder ( ) . to_string ( )
1142
1141
{
1143
1142
err. span_suggestion_verbose (
@@ -1155,22 +1154,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1155
1154
if let Some ( def_id) = impl_def_id. as_local ( )
1156
1155
&& let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id)
1157
1156
&& let hir:: Node :: Item ( hir:: Item {
1158
- kind : hir:: ItemKind :: Impl ( hir:: Impl {
1159
- self_ty,
1160
- ..
1161
- } ) ,
1157
+ kind : hir:: ItemKind :: Impl ( _) ,
1162
1158
..
1163
1159
} ) = tcx. hir ( ) . get ( hir_id)
1160
+ && tcx. type_of ( impl_def_id) == ty
1164
1161
{
1165
- if ty == hir_ty_to_ty ( tcx, self_ty) {
1166
- err. span_suggestion_verbose (
1167
- fn_call_span. shrink_to_lo ( ) ,
1168
- "you can `clone` the value and consume it, but this \
1169
- might not be your desired behavior",
1170
- "clone()." . to_string ( ) ,
1171
- Applicability :: MaybeIncorrect ,
1172
- ) ;
1173
- }
1162
+ err. span_suggestion_verbose (
1163
+ fn_call_span. shrink_to_lo ( ) ,
1164
+ "you can `clone` the value and consume it, but this might \
1165
+ not be your desired behavior",
1166
+ "clone()." . to_string ( ) ,
1167
+ Applicability :: MaybeIncorrect ,
1168
+ ) ;
1174
1169
}
1175
1170
}
1176
1171
}
0 commit comments