"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 => {
) -> 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 });
} 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 => {
.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(),
// 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.
use crate::require_c_abi_if_c_variadic;
use crate::util::common::indenter;
-use crate::TypeAndSubsts;
use self::autoderef::Autoderef;
use self::callee::DeferredCallResolution;
}
}
- // 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(
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;
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) {
| | 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) {}
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) {}
| 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() {}