]> git.lizzy.rs Git - rust.git/commitdiff
Remove `FnCtxt::impl_self_ty`
authorYuki Okushi <huyuumi.dev@gmail.com>
Mon, 13 Apr 2020 02:36:37 +0000 (11:36 +0900)
committerYuki Okushi <huyuumi.dev@gmail.com>
Mon, 13 Apr 2020 02:36:37 +0000 (11:36 +0900)
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/lib.rs
src/test/ui/issues/issue-18446.stderr
src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
src/test/ui/suggestions/suggest-assoc-fn-call-with-turbofish.stderr

index 210ba92e8117b87cf18a835cca61c673ef65285b..3f81689cdc90f784195873eca8c8ded6ca42cb04 100644 (file)
@@ -209,7 +209,7 @@ fn fresh_receiver_substs(
                     "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 => {
index 7e7d84c1996763a9e20ba9a6c0804fddc295bc59..fb1cde855657bcba494c36634b7bee82eb720c67 100644 (file)
@@ -1128,8 +1128,7 @@ fn pick_autorefd_method(
     ) -> 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 @@ fn xform_method_sig(&self, method: DefId, substs: SubstsRef<'tcx>) -> ty::FnSig<
                 } 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 => {
index f075d1e74d455df26ab62f9eb7fd81e379a0eef3..6e33acf9afccba90f9f6d2237b4562a90cc5b02b 100644 (file)
@@ -117,7 +117,7 @@ pub fn report_method_error<'b>(
                             .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 @@ macro_rules! report_function {
                         // 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.
index 4b5953b5e958cfad601ce39ce0c5c63843955b06..3aea6b2815fe401684a4571a2a61fba5c80bc64f 100644 (file)
 
 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 @@ fn check_lit(&self, lit: &hir::Lit, expected: Expectation<'tcx>) -> Ty<'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(
index 69d0b3723b0ad8d251a8bf800b03105c8215a60b..df8290fd018c5cd9d6bedd503ffe41f803e7940d 100644 (file)
@@ -97,7 +97,6 @@
 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) {
index 3422add9dd96b701bbae7fee4052f38b96500f89..40cb86e5716a0b3a6aeac905242d90d9856ae406 100644 (file)
@@ -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) {}
index e7f295df8c482642c7ea78a1fb71e0ee975ad094..f6820be7e7709e957e4fdf0062deae16cc7ea533 100644 (file)
@@ -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) {}
index dfc1887d3af90d4796c4168507684f4d6d171bde..f1c0cd6b543e4e4e3d2232de3848eedeb2fc6265 100644 (file)
@@ -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() {}