about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorOli Scherer <github35764891676564198441@oli-obk.de>2021-08-10 11:28:54 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2021-09-20 14:15:36 +0000
commit5afeed05e84afc5ee9bec6a8cc1003e0b97aa7fb (patch)
tree81bb558e52423ddca1c13983bad7b295cb9cb729 /compiler/rustc_trait_selection/src
parentdfb11a8a265d967e55c5515e78e741dfdba4db4d (diff)
downloadrust-5afeed05e84afc5ee9bec6a8cc1003e0b97aa7fb.tar.gz
rust-5afeed05e84afc5ee9bec6a8cc1003e0b97aa7fb.zip
Use tracing debugging in `fold_opaque_ty`
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/opaque_types.rs20
1 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs
index 8abcdb5e89b..221ce0062a6 100644
--- a/compiler/rustc_trait_selection/src/opaque_types.rs
+++ b/compiler/rustc_trait_selection/src/opaque_types.rs
@@ -863,7 +863,6 @@ struct 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 {
         let tcx = self.infcx.tcx;
         value.fold_with(&mut BottomUpFolder {
@@ -954,6 +953,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
         })
     }
 
+    #[instrument(skip(self), level = "debug")]
     fn fold_opaque_ty(
         &mut self,
         ty: Ty<'tcx>,
@@ -961,28 +961,20 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
         origin: hir::OpaqueTyOrigin,
     ) -> Ty<'tcx> {
         let infcx = self.infcx;
-        let tcx = infcx.tcx;
         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
         // 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) {
-            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;
         }
+
         let ty_var = infcx.next_ty_var(TypeVariableOrigin {
             kind: TypeVariableOriginKind::TypeInference,
             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
         // from*, but right now we just use the span from the overall
         // value being folded. In simple cases like `-> impl Foo`,
@@ -999,7 +991,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
             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);
 
         ty_var
@@ -1011,7 +1003,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
         let OpaqueTypeKey { def_id, substs } = opaque_type_key;
 
         let item_bounds = tcx.explicit_item_bounds(def_id);
-        debug!("instantiate_opaque_types: bounds={:#?}", item_bounds);
+        debug!(?item_bounds);
         let bounds: Vec<_> =
             item_bounds.iter().map(|(bound, _)| bound.subst(tcx, substs)).collect();
 
@@ -1023,7 +1015,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
         );
         self.obligations.extend(obligations);
 
-        debug!("instantiate_opaque_types: bounds={:?}", bounds);
+        debug!(?bounds);
 
         for predicate in &bounds {
             if let ty::PredicateKind::Projection(projection) = predicate.kind().skip_binder() {