@@ -95,6 +95,7 @@ pub struct OpaqueTypeDecl<'tcx> {
9595}
9696
9797/// Whether member constraints should be generated for all opaque types
98+ #[ derive( Debug ) ]
9899pub enum GenerateMemberConstraints {
99100 /// The default, used by typeck
100101 WhenRequired ,
@@ -183,6 +184,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
183184 /// obligations
184185 /// - `value` -- the value within which we are instantiating opaque types
185186 /// - `value_span` -- the span where the value came from, used in error reporting
187+ #[ instrument( level = "debug" , skip( self ) ) ]
188+ // FIXME(oli-obk): this function is invoked twice: once with the crate root, and then for each body that
189+ // actually could be a defining use. It is unclear to me why we run all of it twice. Figure out what
190+ // happens and document that or fix it.
186191 fn instantiate_opaque_types < T : TypeFoldable < ' tcx > > (
187192 & self ,
188193 parent_def_id : LocalDefId ,
@@ -191,11 +196,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
191196 value : T ,
192197 value_span : Span ,
193198 ) -> InferOk < ' tcx , ( T , OpaqueTypeMap < ' tcx > ) > {
194- debug ! (
195- "instantiate_opaque_types(value={:?}, parent_def_id={:?}, body_id={:?}, \
196- param_env={:?}, value_span={:?})",
197- value, parent_def_id, body_id, param_env, value_span,
198- ) ;
199199 let mut instantiator = Instantiator {
200200 infcx : self ,
201201 parent_def_id,
@@ -389,22 +389,19 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
389389 }
390390
391391 /// See `constrain_opaque_types` for documentation.
392+ #[ instrument( level = "debug" , skip( self , free_region_relations) ) ]
392393 fn constrain_opaque_type < FRR : FreeRegionRelations < ' tcx > > (
393394 & self ,
394395 def_id : DefId ,
395396 opaque_defn : & OpaqueTypeDecl < ' tcx > ,
396397 mode : GenerateMemberConstraints ,
397398 free_region_relations : & FRR ,
398399 ) {
399- debug ! ( "constrain_opaque_type()" ) ;
400- debug ! ( "constrain_opaque_type: def_id={:?}" , def_id) ;
401- debug ! ( "constrain_opaque_type: opaque_defn={:#?}" , opaque_defn) ;
402-
403400 let tcx = self . tcx ;
404401
405402 let concrete_ty = self . resolve_vars_if_possible ( opaque_defn. concrete_ty ) ;
406403
407- debug ! ( "constrain_opaque_type: concrete_ty={:?}" , concrete_ty) ;
404+ debug ! ( ? concrete_ty) ;
408405
409406 let first_own_region = match opaque_defn. origin {
410407 hir:: OpaqueTyOrigin :: FnReturn | hir:: OpaqueTyOrigin :: AsyncFn => {
@@ -469,8 +466,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
469466 } ;
470467
471468 // Compute the least upper bound of it with the other regions.
472- debug ! ( "constrain_opaque_types: least_region={:?}" , least_region) ;
473- debug ! ( "constrain_opaque_types: subst_region={:?}" , subst_region) ;
469+ debug ! ( ? least_region) ;
470+ debug ! ( ? subst_region) ;
474471 match least_region {
475472 None => least_region = Some ( subst_region) ,
476473 Some ( lr) => {
@@ -997,8 +994,8 @@ struct Instantiator<'a, 'tcx> {
997994}
998995
999996impl < ' a , ' tcx > Instantiator < ' a , ' tcx > {
997+ #[ instrument( level = "debug" , skip( self ) ) ]
1000998 fn instantiate_opaque_types_in_map < T : TypeFoldable < ' tcx > > ( & mut self , value : T ) -> T {
1001- debug ! ( "instantiate_opaque_types_in_map(value={:?})" , value) ;
1002999 let tcx = self . infcx . tcx ;
10031000 value. fold_with ( & mut BottomUpFolder {
10041001 tcx,
@@ -1075,12 +1072,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10751072 return self . fold_opaque_ty ( ty, def_id. to_def_id ( ) , substs, origin) ;
10761073 }
10771074
1078- debug ! (
1079- "instantiate_opaque_types_in_map: \
1080- encountered opaque outside its definition scope \
1081- def_id={:?}",
1082- def_id,
1083- ) ;
1075+ debug ! ( ?def_id, "encountered opaque outside its definition scope" ) ;
10841076 }
10851077 }
10861078
@@ -1091,6 +1083,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10911083 } )
10921084 }
10931085
1086+ #[ instrument( level = "debug" , skip( self ) ) ]
10941087 fn fold_opaque_ty (
10951088 & mut self ,
10961089 ty : Ty < ' tcx > ,
@@ -1101,16 +1094,14 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
11011094 let infcx = self . infcx ;
11021095 let tcx = infcx. tcx ;
11031096
1104- debug ! ( "instantiate_opaque_types: Opaque(def_id={:?}, substs={:?})" , def_id, substs) ;
1105-
11061097 // Use the same type variable if the exact same opaque type appears more
11071098 // than once in the return type (e.g., if it's passed to a type alias).
11081099 if let Some ( opaque_defn) = self . opaque_types . get ( & def_id) {
11091100 debug ! ( "instantiate_opaque_types: returning concrete ty {:?}" , opaque_defn. concrete_ty) ;
11101101 return opaque_defn. concrete_ty ;
11111102 }
11121103 let span = tcx. def_span ( def_id) ;
1113- debug ! ( "fold_opaque_ty {:?} {:?}" , self . value_span, span) ;
1104+ debug ! ( ? self . value_span, ? span) ;
11141105 let ty_var = infcx
11151106 . next_ty_var ( TypeVariableOrigin { kind : TypeVariableOriginKind :: TypeInference , span } ) ;
11161107
0 commit comments