@@ -26,9 +26,6 @@ use super::InferResult;
26
26
/// appear in the return type).
27
27
#[ derive( Clone , Debug ) ]
28
28
pub struct OpaqueTypeDecl < ' tcx > {
29
- /// The opaque type (`ty::Opaque`) for this declaration.
30
- pub opaque_type : Ty < ' tcx > ,
31
-
32
29
/// The hidden types that have been inferred for this opaque type.
33
30
/// There can be multiple, but they are all `lub`ed together at the end
34
31
/// to obtain the canonical hidden type.
@@ -82,11 +79,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
82
79
return Ok ( InferOk { value : ( ) , obligations : vec ! [ ] } ) ;
83
80
}
84
81
if self . defining_use_anchor . is_some ( ) {
85
- let process = |a : Ty < ' tcx > , b : Ty < ' tcx > | {
86
- if !matches ! ( a. kind( ) , ty:: Opaque ( ..) ) {
87
- return None ;
88
- }
89
- self . fold_opaque_ty_new ( a, cause. clone ( ) , param_env, b)
82
+ let process = |a : Ty < ' tcx > , b : Ty < ' tcx > | match * a. kind ( ) {
83
+ ty:: Opaque ( def_id, substs) => self . fold_opaque_ty_new (
84
+ OpaqueTypeKey { def_id, substs } ,
85
+ cause. clone ( ) ,
86
+ param_env,
87
+ b,
88
+ ) ,
89
+ _ => None ,
90
90
} ;
91
91
if let Some ( res) = process ( a, b) {
92
92
res
@@ -118,7 +118,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
118
118
let origin = self . opaque_ty_origin_unchecked ( key. def_id , cause. span ) ;
119
119
let prev = self . inner . borrow_mut ( ) . opaque_types ( ) . register (
120
120
key,
121
- opaque_type,
122
121
OpaqueHiddenType { ty : hidden_ty, span : cause. span } ,
123
122
origin,
124
123
) ;
@@ -482,7 +481,7 @@ impl UseKind {
482
481
impl < ' a , ' tcx > InferCtxt < ' a , ' tcx > {
483
482
fn fold_opaque_ty_new (
484
483
& self ,
485
- opaque_type : Ty < ' tcx > ,
484
+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
486
485
cause : ObligationCause < ' tcx > ,
487
486
param_env : ty:: ParamEnv < ' tcx > ,
488
487
hidden_ty : Ty < ' tcx > ,
@@ -521,26 +520,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
521
520
// let x = || foo(); // returns the Opaque assoc with `foo`
522
521
// }
523
522
// ```
524
- let opaque_type_key = opaque_type. expect_opaque_type ( ) ;
525
523
if let Some ( origin) = self . opaque_type_origin ( opaque_type_key. def_id , cause. span ) {
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
- ) ) ;
524
+ return Some ( self . fold_opaque_ty ( cause, param_env, opaque_type_key, origin, hidden_ty) ) ;
534
525
}
535
526
536
- debug ! ( ?opaque_type , "encountered opaque outside its definition scope" , ) ;
527
+ debug ! ( ?opaque_type_key , "encountered opaque outside its definition scope" , ) ;
537
528
None
538
529
}
539
530
540
531
#[ instrument( skip( self ) , level = "debug" ) ]
541
532
fn fold_opaque_ty (
542
533
& self ,
543
- opaque_type : Ty < ' tcx > ,
544
534
cause : ObligationCause < ' tcx > ,
545
535
param_env : ty:: ParamEnv < ' tcx > ,
546
536
opaque_type_key : OpaqueTypeKey < ' tcx > ,
@@ -560,7 +550,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
560
550
let mut obligations = vec ! [ ] ;
561
551
let prev = self . inner . borrow_mut ( ) . opaque_types ( ) . register (
562
552
OpaqueTypeKey { def_id, substs } ,
563
- opaque_type,
564
553
OpaqueHiddenType { ty : hidden_ty, span } ,
565
554
origin,
566
555
) ;
0 commit comments