Remove FnCtxt::impl_self_ty
This commit is contained in:
parent
9fed360550
commit
ef07cf4518
@ -209,7 +209,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
"impl {:?} is not an inherent impl",
|
||||
impl_def_id
|
||||
);
|
||||
self.impl_self_ty(self.span, impl_def_id).substs
|
||||
self.fresh_substs_for_item(self.span, impl_def_id)
|
||||
}
|
||||
|
||||
probe::ObjectPick => {
|
||||
|
@ -1128,8 +1128,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
) -> Option<PickResult<'tcx>> {
|
||||
let tcx = self.tcx;
|
||||
|
||||
// In general, during probing we erase regions. See
|
||||
// `impl_self_ty()` for an explanation.
|
||||
// In general, during probing we erase regions.
|
||||
let region = tcx.lifetimes.re_erased;
|
||||
|
||||
let autoref_ty = tcx.mk_ref(region, ty::TypeAndMut { ty: self_ty, mutbl });
|
||||
@ -1614,8 +1613,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
} else {
|
||||
match param.kind {
|
||||
GenericParamDefKind::Lifetime => {
|
||||
// In general, during probe we erase regions. See
|
||||
// `impl_self_ty()` for an explanation.
|
||||
// In general, during probe we erase regions.
|
||||
self.tcx.lifetimes.re_erased.into()
|
||||
}
|
||||
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => {
|
||||
|
@ -117,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.span_if_local(item.def_id)
|
||||
.or_else(|| self.tcx.hir().span_if_local(impl_did));
|
||||
|
||||
let impl_ty = self.impl_self_ty(span, impl_did).ty;
|
||||
let impl_ty = self.tcx.at(span).type_of(impl_did);
|
||||
|
||||
let insertion = match self.tcx.impl_trait_ref(impl_did) {
|
||||
None => String::new(),
|
||||
@ -537,7 +537,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// When the "method" is resolved through dereferencing, we really want the
|
||||
// original type that has the associated function for accurate suggestions.
|
||||
// (#61411)
|
||||
let ty = self.impl_self_ty(span, *impl_did).ty;
|
||||
let ty = tcx.at(span).type_of(*impl_did);
|
||||
match (&ty.peel_refs().kind, &actual.peel_refs().kind) {
|
||||
(ty::Adt(def, _), ty::Adt(def_actual, _)) if def == def_actual => {
|
||||
// Use `actual` as it will have more `substs` filled in.
|
||||
|
@ -154,7 +154,6 @@ use std::slice;
|
||||
|
||||
use crate::require_c_abi_if_c_variadic;
|
||||
use crate::util::common::indenter;
|
||||
use crate::TypeAndSubsts;
|
||||
|
||||
use self::autoderef::Autoderef;
|
||||
use self::callee::DeferredCallResolution;
|
||||
@ -4251,24 +4250,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the `Self` type, using fresh variables for all variables
|
||||
// declared on the impl declaration e.g., `impl<A,B> for Vec<(A,B)>`
|
||||
// would return `($0, $1)` where `$0` and `$1` are freshly instantiated type
|
||||
// variables.
|
||||
pub fn impl_self_ty(
|
||||
&self,
|
||||
span: Span, // (potential) receiver for this impl
|
||||
did: DefId,
|
||||
) -> TypeAndSubsts<'tcx> {
|
||||
let ity = self.tcx.type_of(did);
|
||||
debug!("impl_self_ty: ity={:?}", ity);
|
||||
|
||||
let substs = self.fresh_substs_for_item(span, did);
|
||||
let substd_ty = self.instantiate_type_scheme(span, &substs, &ity);
|
||||
|
||||
TypeAndSubsts { substs, ty: substd_ty }
|
||||
}
|
||||
|
||||
/// Unifies the output type with the expected type early, for more coercions
|
||||
/// and forward type information on the input expressions.
|
||||
fn expected_inputs_for_expected_output(
|
||||
|
@ -97,7 +97,6 @@ use rustc_infer::infer::{InferOk, TyCtxtInferExt};
|
||||
use rustc_infer::traits::TraitEngineExt as _;
|
||||
use rustc_middle::middle;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_middle::util;
|
||||
use rustc_session::config::EntryFnType;
|
||||
@ -111,10 +110,6 @@ use rustc_trait_selection::traits::{
|
||||
use std::iter;
|
||||
|
||||
use astconv::{AstConv, Bounds};
|
||||
pub struct TypeAndSubsts<'tcx> {
|
||||
substs: SubstsRef<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) {
|
||||
if decl.c_variadic && !(abi == Abi::C || abi == Abi::Cdecl) {
|
||||
|
@ -7,7 +7,7 @@ LL | x.foo();
|
||||
| | multiple `foo` found
|
||||
| help: disambiguate the method call for candidate #2: `T::foo(&x)`
|
||||
|
|
||||
note: candidate #1 is defined in an impl for the type `dyn T`
|
||||
note: candidate #1 is defined in an impl for the type `(dyn T + 'a)`
|
||||
--> $DIR/issue-18446.rs:9:5
|
||||
|
|
||||
LL | fn foo(&self) {}
|
||||
|
@ -20,12 +20,12 @@ error[E0034]: multiple applicable items in scope
|
||||
LL | let z = x.foo();
|
||||
| ^^^ multiple `foo` found
|
||||
|
|
||||
note: candidate #1 is defined in an impl of the trait `internal::X` for the type `_`
|
||||
note: candidate #1 is defined in an impl of the trait `internal::X` for the type `T`
|
||||
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:43:9
|
||||
|
|
||||
LL | fn foo(self: Smaht<Self, u64>) -> u64 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `_`
|
||||
note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `T`
|
||||
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:70:9
|
||||
|
|
||||
LL | fn foo(self) {}
|
||||
|
@ -11,7 +11,7 @@ LL | x.default_hello();
|
||||
| help: use associated function syntax instead: `GenericAssocMethod::<i32>::default_hello`
|
||||
|
|
||||
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
|
||||
note: the candidate is defined in an impl for the type `GenericAssocMethod<_>`
|
||||
note: the candidate is defined in an impl for the type `GenericAssocMethod<T>`
|
||||
--> $DIR/suggest-assoc-fn-call-with-turbofish.rs:4:5
|
||||
|
|
||||
LL | fn default_hello() {}
|
||||
|
Loading…
Reference in New Issue
Block a user