@@ -24,7 +24,7 @@ use rustc_middle::ty::visit::TypeVisitable;
2424use rustc_middle:: ty:: {
2525 self , AdtKind , CanonicalUserType , DefIdTree , GenericParamDefKind , Ty , UserType ,
2626} ;
27- use rustc_middle:: ty:: { GenericArgKind , InternalSubsts , SubstsRef , UserSelfTy , UserSubsts } ;
27+ use rustc_middle:: ty:: { GenericArgKind , SubstsRef , UserSelfTy , UserSubsts } ;
2828use rustc_session:: lint;
2929use rustc_span:: def_id:: LocalDefId ;
3030use rustc_span:: hygiene:: DesugaringKind ;
@@ -161,47 +161,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
161161 pub fn write_method_call ( & self , hir_id : hir:: HirId , method : MethodCallee < ' tcx > ) {
162162 self . write_resolution ( hir_id, Ok ( ( DefKind :: AssocFn , method. def_id ) ) ) ;
163163 self . write_substs ( hir_id, method. substs ) ;
164-
165- // When the method is confirmed, the `method.substs` includes
166- // parameters from not just the method, but also the impl of
167- // the method -- in particular, the `Self` type will be fully
168- // resolved. However, those are not something that the "user
169- // specified" -- i.e., those types come from the inferred type
170- // of the receiver, not something the user wrote. So when we
171- // create the user-substs, we want to replace those earlier
172- // types with just the types that the user actually wrote --
173- // that is, those that appear on the *method itself*.
174- //
175- // As an example, if the user wrote something like
176- // `foo.bar::<u32>(...)` -- the `Self` type here will be the
177- // type of `foo` (possibly adjusted), but we don't want to
178- // include that. We want just the `[_, u32]` part.
179- if !method. substs . is_empty ( ) {
180- let method_generics = self . tcx . generics_of ( method. def_id ) ;
181- if !method_generics. params . is_empty ( ) {
182- let user_type_annotation = self . probe ( |_| {
183- let user_substs = UserSubsts {
184- substs : InternalSubsts :: for_item ( self . tcx , method. def_id , |param, _| {
185- let i = param. index as usize ;
186- if i < method_generics. parent_count {
187- self . var_for_def ( DUMMY_SP , param)
188- } else {
189- method. substs [ i]
190- }
191- } ) ,
192- user_self_ty : None , // not relevant here
193- } ;
194-
195- self . canonicalize_user_type_annotation ( UserType :: TypeOf (
196- method. def_id ,
197- user_substs,
198- ) )
199- } ) ;
200-
201- debug ! ( "write_method_call: user_type_annotation={:?}" , user_type_annotation) ;
202- self . write_user_type_annotation ( hir_id, user_type_annotation) ;
203- }
204- }
205164 }
206165
207166 pub fn write_substs ( & self , node_id : hir:: HirId , substs : SubstsRef < ' tcx > ) {
0 commit comments