@@ -356,20 +356,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
356
356
357
357
let trait_ref = ty:: TraitRef :: new_from_args ( self . tcx , trait_def_id, args) ;
358
358
let obligation = traits:: Obligation :: new ( self . tcx , cause, self . param_env , trait_ref) ;
359
- self . construct_obligation_for_trait ( m_name, trait_def_id, obligation, args)
360
- }
361
-
362
- // FIXME(#18741): it seems likely that we can consolidate some of this
363
- // code with the other method-lookup code. In particular, the second half
364
- // of this method is basically the same as confirmation.
365
- fn construct_obligation_for_trait (
366
- & self ,
367
- m_name : Ident ,
368
- trait_def_id : DefId ,
369
- obligation : traits:: PredicateObligation < ' tcx > ,
370
- args : ty:: GenericArgsRef < ' tcx > ,
371
- ) -> Option < InferOk < ' tcx , MethodCallee < ' tcx > > > {
372
- debug ! ( ?obligation) ;
373
359
374
360
// Now we want to know if this can be matched
375
361
if !self . predicate_may_hold ( & obligation) {
@@ -393,8 +379,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
393
379
debug ! ( "lookup_in_trait_adjusted: method_item={:?}" , method_item) ;
394
380
let mut obligations = PredicateObligations :: new ( ) ;
395
381
396
- // FIXME(effects): revisit when binops get `#[const_trait]`
397
-
398
382
// Instantiate late-bound regions and instantiate the trait
399
383
// parameters into the method type to get the actual method type.
400
384
//
@@ -405,12 +389,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
405
389
let fn_sig =
406
390
self . instantiate_binder_with_fresh_vars ( obligation. cause . span , infer:: FnCall , fn_sig) ;
407
391
408
- let InferOk { value, obligations : o } =
392
+ let InferOk { value : fn_sig , obligations : o } =
409
393
self . at ( & obligation. cause , self . param_env ) . normalize ( fn_sig) ;
410
- let fn_sig = {
411
- obligations. extend ( o) ;
412
- value
413
- } ;
394
+ obligations. extend ( o) ;
414
395
415
396
// Register obligations for the parameters. This will include the
416
397
// `Self` parameter, which in turn has a bound of the main trait,
@@ -422,13 +403,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
422
403
// any late-bound regions appearing in its bounds.
423
404
let bounds = self . tcx . predicates_of ( def_id) . instantiate ( self . tcx , args) ;
424
405
425
- let InferOk { value, obligations : o } =
406
+ let InferOk { value : bounds , obligations : o } =
426
407
self . at ( & obligation. cause , self . param_env ) . normalize ( bounds) ;
427
- let bounds = {
428
- obligations. extend ( o) ;
429
- value
430
- } ;
431
-
408
+ obligations. extend ( o) ;
432
409
assert ! ( !bounds. has_escaping_bound_vars( ) ) ;
433
410
434
411
let predicates_cause = obligation. cause . clone ( ) ;
@@ -441,7 +418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
441
418
// Also add an obligation for the method type being well-formed.
442
419
let method_ty = Ty :: new_fn_ptr ( tcx, ty:: Binder :: dummy ( fn_sig) ) ;
443
420
debug ! (
444
- "lookup_in_trait_adjusted : matched method method_ty={:?} obligation={:?}" ,
421
+ "lookup_method_in_trait : matched method method_ty={:?} obligation={:?}" ,
445
422
method_ty, obligation
446
423
) ;
447
424
obligations. push ( traits:: Obligation :: new (
@@ -454,7 +431,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
454
431
) ) ;
455
432
456
433
let callee = MethodCallee { def_id, args, sig : fn_sig } ;
457
-
458
434
debug ! ( "callee = {:?}" , callee) ;
459
435
460
436
Some ( InferOk { obligations, value : callee } )
0 commit comments