@@ -95,6 +95,7 @@ pub struct OpaqueTypeDecl<'tcx> {
95
95
}
96
96
97
97
/// Whether member constraints should be generated for all opaque types
98
+ #[derive(Debug)]
98
99
pub enum GenerateMemberConstraints {
99
100
/// The default, used by typeck
100
101
WhenRequired,
@@ -183,6 +184,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
183
184
/// obligations
184
185
/// - `value` -- the value within which we are instantiating opaque types
185
186
/// - `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.
186
191
fn instantiate_opaque_types<T: TypeFoldable<'tcx>>(
187
192
&self,
188
193
parent_def_id: LocalDefId,
@@ -191,11 +196,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
191
196
value: T,
192
197
value_span: Span,
193
198
) -> 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
- );
199
199
let mut instantiator = Instantiator {
200
200
infcx: self,
201
201
parent_def_id,
@@ -389,22 +389,19 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
389
389
}
390
390
391
391
/// See `constrain_opaque_types` for documentation.
392
+ #[instrument(level = "debug", skip(self, free_region_relations))]
392
393
fn constrain_opaque_type<FRR: FreeRegionRelations<'tcx>>(
393
394
&self,
394
395
def_id: DefId,
395
396
opaque_defn: &OpaqueTypeDecl<'tcx>,
396
397
mode: GenerateMemberConstraints,
397
398
free_region_relations: &FRR,
398
399
) {
399
- debug!("constrain_opaque_type()");
400
- debug!("constrain_opaque_type: def_id={:?}", def_id);
401
- debug!("constrain_opaque_type: opaque_defn={:#?}", opaque_defn);
402
-
403
400
let tcx = self.tcx;
404
401
405
402
let concrete_ty = self.resolve_vars_if_possible(opaque_defn.concrete_ty);
406
403
407
- debug!("constrain_opaque_type: concrete_ty={:?}", concrete_ty);
404
+ debug!(? concrete_ty);
408
405
409
406
let first_own_region = match opaque_defn.origin {
410
407
hir::OpaqueTyOrigin::FnReturn | hir::OpaqueTyOrigin::AsyncFn => {
@@ -469,8 +466,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
469
466
};
470
467
471
468
// 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);
474
471
match least_region {
475
472
None => least_region = Some(subst_region),
476
473
Some(lr) => {
@@ -997,8 +994,8 @@ struct Instantiator<'a, 'tcx> {
997
994
}
998
995
999
996
impl<'a, 'tcx> Instantiator<'a, 'tcx> {
997
+ #[instrument(level = "debug", skip(self))]
1000
998
fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
1001
- debug!("instantiate_opaque_types_in_map(value={:?})", value);
1002
999
let tcx = self.infcx.tcx;
1003
1000
value.fold_with(&mut BottomUpFolder {
1004
1001
tcx,
@@ -1075,12 +1072,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
1075
1072
return self.fold_opaque_ty(ty, def_id.to_def_id(), substs, origin);
1076
1073
}
1077
1074
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");
1084
1076
}
1085
1077
}
1086
1078
@@ -1091,6 +1083,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
1091
1083
})
1092
1084
}
1093
1085
1086
+ #[instrument(level = "debug", skip(self))]
1094
1087
fn fold_opaque_ty(
1095
1088
&mut self,
1096
1089
ty: Ty<'tcx>,
@@ -1101,16 +1094,14 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
1101
1094
let infcx = self.infcx;
1102
1095
let tcx = infcx.tcx;
1103
1096
1104
- debug!("instantiate_opaque_types: Opaque(def_id={:?}, substs={:?})", def_id, substs);
1105
-
1106
1097
// Use the same type variable if the exact same opaque type appears more
1107
1098
// than once in the return type (e.g., if it's passed to a type alias).
1108
1099
if let Some(opaque_defn) = self.opaque_types.get(&def_id) {
1109
1100
debug!("instantiate_opaque_types: returning concrete ty {:?}", opaque_defn.concrete_ty);
1110
1101
return opaque_defn.concrete_ty;
1111
1102
}
1112
1103
let span = tcx.def_span(def_id);
1113
- debug!("fold_opaque_ty {:?} {:?}", self.value_span, span);
1104
+ debug!(? self.value_span, ? span);
1114
1105
let ty_var = infcx
1115
1106
.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::TypeInference, span });
1116
1107
0 commit comments