diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /compiler/rustc_borrowck/src/diagnostics/mod.rs | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_borrowck/src/diagnostics/mod.rs')
-rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/mod.rs | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index d292611e6..099e07e88 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -732,18 +732,18 @@ impl<'tcx> BorrowedContentSource<'tcx> { fn from_call(func: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option<Self> { match *func.kind() { - ty::FnDef(def_id, substs) => { + ty::FnDef(def_id, args) => { let trait_id = tcx.trait_of_item(def_id)?; let lang_items = tcx.lang_items(); if Some(trait_id) == lang_items.deref_trait() || Some(trait_id) == lang_items.deref_mut_trait() { - Some(BorrowedContentSource::OverloadedDeref(substs.type_at(0))) + Some(BorrowedContentSource::OverloadedDeref(args.type_at(0))) } else if Some(trait_id) == lang_items.index_trait() || Some(trait_id) == lang_items.index_mut_trait() { - Some(BorrowedContentSource::OverloadedIndex(substs.type_at(0))) + Some(BorrowedContentSource::OverloadedIndex(args.type_at(0))) } else { None } @@ -847,14 +847,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { kind: TerminatorKind::Call { fn_span, call_source, .. }, .. }) = &self.body[location.block].terminator { - let Some((method_did, method_substs)) = - rustc_middle::util::find_self_call( - self.infcx.tcx, - &self.body, - target_temp, - location.block, - ) - else { + let Some((method_did, method_args)) = rustc_middle::util::find_self_call( + self.infcx.tcx, + &self.body, + target_temp, + location.block, + ) else { return normal_ret; }; @@ -862,7 +860,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { self.infcx.tcx, self.param_env, method_did, - method_substs, + method_args, *fn_span, call_source.from_hir_call(), Some(self.infcx.tcx.fn_arg_names(method_did)[0]), @@ -1041,7 +1039,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }); } } - CallKind::Normal { self_arg, desugaring, method_did, method_substs } => { + CallKind::Normal { self_arg, desugaring, method_did, method_args } => { let self_arg = self_arg.unwrap(); let tcx = self.infcx.tcx; if let Some((CallDesugaringKind::ForLoopIntoIter, _)) = desugaring { @@ -1108,20 +1106,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Erase and shadow everything that could be passed to the new infcx. let ty = moved_place.ty(self.body, tcx).ty; - if let ty::Adt(def, substs) = ty.kind() + if let ty::Adt(def, args) = ty.kind() && Some(def.did()) == tcx.lang_items().pin_type() - && let ty::Ref(_, _, hir::Mutability::Mut) = substs.type_at(0).kind() + && let ty::Ref(_, _, hir::Mutability::Mut) = args.type_at(0).kind() && let self_ty = self.infcx.instantiate_binder_with_fresh_vars( fn_call_span, LateBoundRegionConversionTime::FnCall, - tcx.fn_sig(method_did).subst(tcx, method_substs).input(0), + tcx.fn_sig(method_did).instantiate(tcx, method_args).input(0), ) && self.infcx.can_eq(self.param_env, ty, self_ty) { err.eager_subdiagnostic( &self.infcx.tcx.sess.parse_sess.span_diagnostic, CaptureReasonSuggest::FreshReborrow { - span: fn_call_span.shrink_to_lo(), + span: move_span.shrink_to_hi(), }); } if let Some(clone_trait) = tcx.lang_items().clone_trait() @@ -1135,10 +1133,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { && self.infcx.predicate_must_hold_modulo_regions(&o) { err.span_suggestion_verbose( - fn_call_span.shrink_to_lo(), + move_span.shrink_to_hi(), "you can `clone` the value and consume it, but this might not be \ your desired behavior", - "clone().".to_string(), + ".clone()".to_string(), Applicability::MaybeIncorrect, ); } @@ -1163,7 +1161,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let parent_self_ty = matches!(tcx.def_kind(parent_did), rustc_hir::def::DefKind::Impl { .. }) .then_some(parent_did) - .and_then(|did| match tcx.type_of(did).subst_identity().kind() { + .and_then(|did| match tcx.type_of(did).instantiate_identity().kind() { ty::Adt(def, ..) => Some(def.did()), _ => None, }); |