diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 5250f39003d..762188b73b3 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1132,9 +1132,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { place_name, partially_str, loop_message ), ); - let ty = moved_place.ty(self.body, self.infcx.tcx).ty; - if let ty::Adt(def, ..) = ty.kind() + let ty = tcx.erase_regions(moved_place.ty(self.body, self.infcx.tcx).ty); + if let ty::Adt(def, substs) = ty.kind() && Some(def.did()) == self.infcx.tcx.lang_items().pin_type() + && let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind() + // FIXME: this is a hack because we can't call `can_eq` + && ty.to_string() == + tcx.fn_sig(method_did).input(0).skip_binder().to_string() { err.span_suggestion_verbose( fn_call_span.shrink_to_lo(), diff --git a/src/test/ui/moves/move-fn-self-receiver.stderr b/src/test/ui/moves/move-fn-self-receiver.stderr index 0ed44b7674a..b3f95ee192a 100644 --- a/src/test/ui/moves/move-fn-self-receiver.stderr +++ b/src/test/ui/moves/move-fn-self-receiver.stderr @@ -67,10 +67,6 @@ note: `Foo::use_pin_box_self` takes ownership of the receiver `self`, which move | LL | fn use_pin_box_self(self: Pin>) {} | ^^^^ -help: consider reborrowing the `Pin` instead of moving it - | -LL | pin_box_foo.as_mut().use_pin_box_self(); - | +++++++++ error[E0505]: cannot move out of `mut_foo` because it is borrowed --> $DIR/move-fn-self-receiver.rs:50:5