@@ -6,7 +6,6 @@ use rustc_errors::{Applicability, Diagnostic};
66use rustc_hir as hir;
77use rustc_hir:: def:: { CtorKind , Namespace } ;
88use rustc_hir:: GeneratorKind ;
9- use rustc_hir_analysis:: hir_ty_to_ty;
109use rustc_infer:: infer:: TyCtxtInferExt ;
1110use rustc_middle:: mir:: tcx:: PlaceTy ;
1211use rustc_middle:: mir:: {
@@ -1137,7 +1136,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11371136 && Some ( def. did ( ) ) == self . infcx . tcx . lang_items ( ) . pin_type ( )
11381137 && let ty:: Ref ( _, _, hir:: Mutability :: Mut ) = substs. type_at ( 0 ) . kind ( )
11391138 // FIXME: this is a hack because we can't call `can_eq`
1140- && ty. to_string ( ) ==
1139+ && ty. to_string ( ) ==
11411140 tcx. fn_sig ( method_did) . input ( 0 ) . skip_binder ( ) . to_string ( )
11421141 {
11431142 err. span_suggestion_verbose (
@@ -1155,22 +1154,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11551154 if let Some ( def_id) = impl_def_id. as_local ( )
11561155 && let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id)
11571156 && let hir:: Node :: Item ( hir:: Item {
1158- kind : hir:: ItemKind :: Impl ( hir:: Impl {
1159- self_ty,
1160- ..
1161- } ) ,
1157+ kind : hir:: ItemKind :: Impl ( _) ,
11621158 ..
11631159 } ) = tcx. hir ( ) . get ( hir_id)
1160+ && tcx. type_of ( impl_def_id) == ty
11641161 {
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+ ) ;
11741169 }
11751170 }
11761171 }
0 commit comments