@@ -324,35 +324,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
324324 Ok ( pick)
325325 }
326326
327- pub ( super ) fn obligation_for_method (
328- & self ,
329- cause : ObligationCause < ' tcx > ,
330- trait_def_id : DefId ,
331- self_ty : Ty < ' tcx > ,
332- opt_input_types : Option < & [ Ty < ' tcx > ] > ,
333- ) -> ( traits:: PredicateObligation < ' tcx > , ty:: GenericArgsRef < ' tcx > ) {
334- // Construct a trait-reference `self_ty : Trait<input_tys>`
335- let args = GenericArgs :: for_item ( self . tcx , trait_def_id, |param, _| {
336- match param. kind {
337- GenericParamDefKind :: Lifetime | GenericParamDefKind :: Const { .. } => { }
338- GenericParamDefKind :: Type { .. } => {
339- if param. index == 0 {
340- return self_ty. into ( ) ;
341- } else if let Some ( input_types) = opt_input_types {
342- return input_types[ param. index as usize - 1 ] . into ( ) ;
343- }
344- }
345- }
346- self . var_for_def ( cause. span , param)
347- } ) ;
348-
349- let trait_ref = ty:: TraitRef :: new_from_args ( self . tcx , trait_def_id, args) ;
350-
351- // Construct an obligation
352- let poly_trait_ref = ty:: Binder :: dummy ( trait_ref) ;
353- ( traits:: Obligation :: new ( self . tcx , cause, self . param_env , poly_trait_ref) , args)
354- }
355-
356327 /// `lookup_method_in_trait` is used for overloaded operators.
357328 /// It does a very narrow slice of what the normal probe/confirm path does.
358329 /// In particular, it doesn't really do any probing: it simply constructs
@@ -367,8 +338,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
367338 self_ty : Ty < ' tcx > ,
368339 opt_input_types : Option < & [ Ty < ' tcx > ] > ,
369340 ) -> Option < InferOk < ' tcx , MethodCallee < ' tcx > > > {
370- let ( obligation, args) =
371- self . obligation_for_method ( cause, trait_def_id, self_ty, opt_input_types) ;
341+ // Construct a trait-reference `self_ty : Trait<input_tys>`
342+ let args = GenericArgs :: for_item ( self . tcx , trait_def_id, |param, _| match param. kind {
343+ GenericParamDefKind :: Lifetime | GenericParamDefKind :: Const { .. } => {
344+ unreachable ! ( "did not expect operator trait to have lifetime/const" )
345+ }
346+ GenericParamDefKind :: Type { .. } => {
347+ if param. index == 0 {
348+ self_ty. into ( )
349+ } else if let Some ( input_types) = opt_input_types {
350+ input_types[ param. index as usize - 1 ] . into ( )
351+ } else {
352+ self . var_for_def ( cause. span , param)
353+ }
354+ }
355+ } ) ;
356+
357+ let trait_ref = ty:: TraitRef :: new_from_args ( self . tcx , trait_def_id, args) ;
358+ let obligation = traits:: Obligation :: new ( self . tcx , cause, self . param_env , trait_ref) ;
372359 self . construct_obligation_for_trait ( m_name, trait_def_id, obligation, args)
373360 }
374361
0 commit comments