@@ -86,7 +86,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
86
86
if !matches ! ( a. kind( ) , ty:: Opaque ( ..) ) {
87
87
return None ;
88
88
}
89
- self . fold_opaque_ty_new ( a, cause. clone ( ) , param_env, |_ , _| b)
89
+ self . fold_opaque_ty_new ( a, cause. clone ( ) , param_env, b)
90
90
} ;
91
91
if let Some ( res) = process ( a, b) {
92
92
res
@@ -482,10 +482,10 @@ impl UseKind {
482
482
impl < ' a , ' tcx > InferCtxt < ' a , ' tcx > {
483
483
fn fold_opaque_ty_new (
484
484
& self ,
485
- ty : Ty < ' tcx > ,
485
+ opaque_type : Ty < ' tcx > ,
486
486
cause : ObligationCause < ' tcx > ,
487
487
param_env : ty:: ParamEnv < ' tcx > ,
488
- mk_ty : impl FnOnce ( & InferCtxt < ' _ , ' tcx > , Span ) -> Ty < ' tcx > ,
488
+ hidden_ty : Ty < ' tcx > ,
489
489
) -> Option < InferResult < ' tcx , ( ) > > {
490
490
// Check that this is `impl Trait` type is
491
491
// declared by `parent_def_id` -- i.e., one whose
@@ -521,30 +521,35 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
521
521
// let x = || foo(); // returns the Opaque assoc with `foo`
522
522
// }
523
523
// ```
524
- let opaque_type_key = ty . expect_opaque_type ( ) ;
524
+ let opaque_type_key = opaque_type . expect_opaque_type ( ) ;
525
525
if let Some ( origin) = self . opaque_type_origin ( opaque_type_key. def_id , cause. span ) {
526
- return Some ( self . fold_opaque_ty ( ty, cause, param_env, opaque_type_key, origin, mk_ty) ) ;
526
+ return Some ( self . fold_opaque_ty (
527
+ opaque_type,
528
+ cause,
529
+ param_env,
530
+ opaque_type_key,
531
+ origin,
532
+ hidden_ty,
533
+ ) ) ;
527
534
}
528
535
529
- debug ! ( ?ty , "encountered opaque outside its definition scope" , ) ;
536
+ debug ! ( ?opaque_type , "encountered opaque outside its definition scope" , ) ;
530
537
None
531
538
}
532
539
533
- #[ instrument( skip( self , mk_ty ) , level = "debug" ) ]
540
+ #[ instrument( skip( self ) , level = "debug" ) ]
534
541
fn fold_opaque_ty (
535
542
& self ,
536
- ty : Ty < ' tcx > ,
543
+ opaque_type : Ty < ' tcx > ,
537
544
cause : ObligationCause < ' tcx > ,
538
545
param_env : ty:: ParamEnv < ' tcx > ,
539
546
opaque_type_key : OpaqueTypeKey < ' tcx > ,
540
547
origin : hir:: OpaqueTyOrigin ,
541
- mk_ty : impl FnOnce ( & InferCtxt < ' _ , ' tcx > , Span ) -> Ty < ' tcx > ,
548
+ hidden_ty : Ty < ' tcx > ,
542
549
) -> InferResult < ' tcx , ( ) > {
543
550
let tcx = self . tcx ;
544
551
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
545
552
546
- let ty_var = mk_ty ( self , cause. span ) ;
547
-
548
553
// Ideally, we'd get the span where *this specific `ty` came
549
554
// from*, but right now we just use the span from the overall
550
555
// value being folded. In simple cases like `-> impl Foo`,
@@ -555,16 +560,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
555
560
let mut obligations = vec ! [ ] ;
556
561
let prev = self . inner . borrow_mut ( ) . opaque_types ( ) . register (
557
562
OpaqueTypeKey { def_id, substs } ,
558
- ty ,
559
- OpaqueHiddenType { ty : ty_var , span } ,
563
+ opaque_type ,
564
+ OpaqueHiddenType { ty : hidden_ty , span } ,
560
565
origin,
561
566
) ;
562
567
if let Some ( prev) = prev {
563
- obligations = self . at ( & cause, param_env) . eq ( prev, ty_var ) ?. obligations ;
568
+ obligations = self . at ( & cause, param_env) . eq ( prev, hidden_ty ) ?. obligations ;
564
569
}
565
570
566
- debug ! ( "generated new type inference var {:?}" , ty_var. kind( ) ) ;
567
-
568
571
let item_bounds = tcx. explicit_item_bounds ( def_id) ;
569
572
570
573
for ( predicate, _) in item_bounds {
@@ -586,7 +589,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
586
589
// Replace all other mentions of the same opaque type with the hidden type,
587
590
// as the bounds must hold on the hidden type after all.
588
591
ty:: Opaque ( def_id2, substs2) if def_id == def_id2 && substs == substs2 => {
589
- ty_var
592
+ hidden_ty
590
593
}
591
594
_ => ty,
592
595
} ,
0 commit comments