about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2020-10-28 19:50:08 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2020-10-30 19:38:46 +0000
commit1f5c655d0c379754c2c0e5a6b8194bd2ee91e455 (patch)
treebc3de0c184faab2de374e4f5a2fec7194280e747
parentffe52882ed79be67344dd6085559e308241e7f60 (diff)
downloadrust-1f5c655d0c379754c2c0e5a6b8194bd2ee91e455.tar.gz
rust-1f5c655d0c379754c2c0e5a6b8194bd2ee91e455.zip
Fix query cycle when tracing explicit_item_bounds
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs2
-rw-r--r--compiler/rustc_typeck/src/collect/item_bounds.rs16
2 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index 9735099a4e1..3ea30fcf9f4 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -65,7 +65,7 @@ thread_local! {
 /// Avoids running any queries during any prints that occur
 /// during the closure. This may alter the appearance of some
 /// types (e.g. forcing verbose printing for opaque types).
-/// This method is used during some queries (e.g. `predicates_of`
+/// This method is used during some queries (e.g. `explicit_item_bounds`
 /// for opaque types), to ensure that any debug printing that
 /// occurs during the query computation does not end up recursively
 /// calling the same query.
diff --git a/compiler/rustc_typeck/src/collect/item_bounds.rs b/compiler/rustc_typeck/src/collect/item_bounds.rs
index 9c29ceeb593..e596dd1a396 100644
--- a/compiler/rustc_typeck/src/collect/item_bounds.rs
+++ b/compiler/rustc_typeck/src/collect/item_bounds.rs
@@ -61,23 +61,23 @@ fn opaque_type_bounds<'tcx>(
     bounds: &'tcx [hir::GenericBound<'tcx>],
     span: Span,
 ) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
-    let item_ty =
-        tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
+    ty::print::with_no_queries(|| {
+        let item_ty =
+            tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
 
-    let bounds = ty::print::with_no_queries(|| {
-        AstConv::compute_bounds(
+        let bounds = AstConv::compute_bounds(
             &ItemCtxt::new(tcx, opaque_def_id),
             item_ty,
             bounds,
             SizedByDefault::Yes,
             span,
         )
-    });
+        .predicates(tcx, item_ty);
 
-    let bounds = bounds.predicates(tcx, item_ty);
-    debug!("opaque_type_bounds({}) = {:?}", tcx.def_path_str(opaque_def_id), bounds);
+        debug!("opaque_type_bounds({}) = {:?}", tcx.def_path_str(opaque_def_id), bounds);
 
-    tcx.arena.alloc_slice(&bounds)
+        tcx.arena.alloc_slice(&bounds)
+    })
 }
 
 pub(super) fn explicit_item_bounds(