@@ -863,7 +863,6 @@ struct Instantiator<'a, 'tcx> {
863863}
864864
865865impl<'a, 'tcx> Instantiator<'a, 'tcx> {
866- #[instrument(level = "debug", skip(self))]
867866 fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
868867 let tcx = self.infcx.tcx;
869868 value.fold_with(&mut BottomUpFolder {
@@ -954,35 +953,28 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
954953 })
955954 }
956955
956+ #[instrument(skip(self), level = "debug")]
957957 fn fold_opaque_ty(
958958 &mut self,
959959 ty: Ty<'tcx>,
960960 opaque_type_key: OpaqueTypeKey<'tcx>,
961961 origin: hir::OpaqueTyOrigin,
962962 ) -> Ty<'tcx> {
963963 let infcx = self.infcx;
964- let tcx = infcx.tcx;
965964 let OpaqueTypeKey { def_id, substs } = opaque_type_key;
966965
967- debug!("instantiate_opaque_types: Opaque(def_id={:?}, substs={:?})", def_id, substs);
968-
969966 // Use the same type variable if the exact same opaque type appears more
970967 // than once in the return type (e.g., if it's passed to a type alias).
971968 if let Some(opaque_defn) = infcx.inner.borrow().opaque_types.get(&opaque_type_key) {
972- debug!("instantiate_opaque_types: returning concrete ty {:?}", opaque_defn.concrete_ty);
969+ debug!("re-using cached concrete type {:?}", opaque_defn.concrete_ty.kind() );
973970 return opaque_defn.concrete_ty;
974971 }
972+
975973 let ty_var = infcx.next_ty_var(TypeVariableOrigin {
976974 kind: TypeVariableOriginKind::TypeInference,
977975 span: self.value_span,
978976 });
979977
980- // Make sure that we are in fact defining the *entire* type
981- // (e.g., `type Foo<T: Bound> = impl Bar;` needs to be
982- // defined by a function like `fn foo<T: Bound>() -> Foo<T>`).
983- debug!("instantiate_opaque_types: param_env={:#?}", self.param_env,);
984- debug!("instantiate_opaque_types: generics={:#?}", tcx.generics_of(def_id),);
985-
986978 // Ideally, we'd get the span where *this specific `ty` came
987979 // from*, but right now we just use the span from the overall
988980 // value being folded. In simple cases like `-> impl Foo`,
@@ -999,7 +991,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
999991 infcx.opaque_types_vars.insert(ty_var, ty);
1000992 }
1001993
1002- debug!("instantiate_opaque_types: ty_var= {:?}", ty_var);
994+ debug!("generated new type inference var {:?}", ty_var.kind() );
1003995 self.compute_opaque_type_obligations(opaque_type_key);
1004996
1005997 ty_var
@@ -1011,7 +1003,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10111003 let OpaqueTypeKey { def_id, substs } = opaque_type_key;
10121004
10131005 let item_bounds = tcx.explicit_item_bounds(def_id);
1014- debug!("instantiate_opaque_types: bounds={:#?}", item_bounds);
1006+ debug!(? item_bounds);
10151007 let bounds: Vec<_> =
10161008 item_bounds.iter().map(|(bound, _)| bound.subst(tcx, substs)).collect();
10171009
@@ -1023,7 +1015,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10231015 );
10241016 self.obligations.extend(obligations);
10251017
1026- debug!("instantiate_opaque_types: bounds={:?}", bounds);
1018+ debug!(? bounds);
10271019
10281020 for predicate in &bounds {
10291021 if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {
0 commit comments