Use tracing debugging in fold_opaque_ty
This commit is contained in:
parent
dfb11a8a26
commit
5afeed05e8
@ -863,7 +863,6 @@ struct Instantiator<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
impl<'a, 'tcx> Instantiator<'a, 'tcx> {
|
||||||
#[instrument(level = "debug", skip(self))]
|
|
||||||
fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
|
fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
value.fold_with(&mut BottomUpFolder {
|
value.fold_with(&mut BottomUpFolder {
|
||||||
@ -954,6 +953,7 @@ fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: T) -
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(self), level = "debug")]
|
||||||
fn fold_opaque_ty(
|
fn fold_opaque_ty(
|
||||||
&mut self,
|
&mut self,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
@ -961,28 +961,20 @@ fn fold_opaque_ty(
|
|||||||
origin: hir::OpaqueTyOrigin,
|
origin: hir::OpaqueTyOrigin,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
let infcx = self.infcx;
|
let infcx = self.infcx;
|
||||||
let tcx = infcx.tcx;
|
|
||||||
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
|
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
|
||||||
|
|
||||||
debug!("instantiate_opaque_types: Opaque(def_id={:?}, substs={:?})", def_id, substs);
|
|
||||||
|
|
||||||
// Use the same type variable if the exact same opaque type appears more
|
// Use the same type variable if the exact same opaque type appears more
|
||||||
// than once in the return type (e.g., if it's passed to a type alias).
|
// than once in the return type (e.g., if it's passed to a type alias).
|
||||||
if let Some(opaque_defn) = infcx.inner.borrow().opaque_types.get(&opaque_type_key) {
|
if let Some(opaque_defn) = infcx.inner.borrow().opaque_types.get(&opaque_type_key) {
|
||||||
debug!("instantiate_opaque_types: returning concrete ty {:?}", opaque_defn.concrete_ty);
|
debug!("re-using cached concrete type {:?}", opaque_defn.concrete_ty.kind());
|
||||||
return opaque_defn.concrete_ty;
|
return opaque_defn.concrete_ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ty_var = infcx.next_ty_var(TypeVariableOrigin {
|
let ty_var = infcx.next_ty_var(TypeVariableOrigin {
|
||||||
kind: TypeVariableOriginKind::TypeInference,
|
kind: TypeVariableOriginKind::TypeInference,
|
||||||
span: self.value_span,
|
span: self.value_span,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make sure that we are in fact defining the *entire* type
|
|
||||||
// (e.g., `type Foo<T: Bound> = impl Bar;` needs to be
|
|
||||||
// defined by a function like `fn foo<T: Bound>() -> Foo<T>`).
|
|
||||||
debug!("instantiate_opaque_types: param_env={:#?}", self.param_env,);
|
|
||||||
debug!("instantiate_opaque_types: generics={:#?}", tcx.generics_of(def_id),);
|
|
||||||
|
|
||||||
// Ideally, we'd get the span where *this specific `ty` came
|
// Ideally, we'd get the span where *this specific `ty` came
|
||||||
// from*, but right now we just use the span from the overall
|
// from*, but right now we just use the span from the overall
|
||||||
// value being folded. In simple cases like `-> impl Foo`,
|
// value being folded. In simple cases like `-> impl Foo`,
|
||||||
@ -999,7 +991,7 @@ fn fold_opaque_ty(
|
|||||||
infcx.opaque_types_vars.insert(ty_var, ty);
|
infcx.opaque_types_vars.insert(ty_var, ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("instantiate_opaque_types: ty_var={:?}", ty_var);
|
debug!("generated new type inference var {:?}", ty_var.kind());
|
||||||
self.compute_opaque_type_obligations(opaque_type_key);
|
self.compute_opaque_type_obligations(opaque_type_key);
|
||||||
|
|
||||||
ty_var
|
ty_var
|
||||||
@ -1011,7 +1003,7 @@ fn compute_opaque_type_obligations(&mut self, opaque_type_key: OpaqueTypeKey<'tc
|
|||||||
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
|
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
|
||||||
|
|
||||||
let item_bounds = tcx.explicit_item_bounds(def_id);
|
let item_bounds = tcx.explicit_item_bounds(def_id);
|
||||||
debug!("instantiate_opaque_types: bounds={:#?}", item_bounds);
|
debug!(?item_bounds);
|
||||||
let bounds: Vec<_> =
|
let bounds: Vec<_> =
|
||||||
item_bounds.iter().map(|(bound, _)| bound.subst(tcx, substs)).collect();
|
item_bounds.iter().map(|(bound, _)| bound.subst(tcx, substs)).collect();
|
||||||
|
|
||||||
@ -1023,7 +1015,7 @@ fn compute_opaque_type_obligations(&mut self, opaque_type_key: OpaqueTypeKey<'tc
|
|||||||
);
|
);
|
||||||
self.obligations.extend(obligations);
|
self.obligations.extend(obligations);
|
||||||
|
|
||||||
debug!("instantiate_opaque_types: bounds={:?}", bounds);
|
debug!(?bounds);
|
||||||
|
|
||||||
for predicate in &bounds {
|
for predicate in &bounds {
|
||||||
if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {
|
if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {
|
||||||
|
Loading…
Reference in New Issue
Block a user