about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs37
-rw-r--r--src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr2
2 files changed, 13 insertions, 26 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index d0f53f8f74b..c56909ba18b 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -817,25 +817,18 @@ pub trait PrettyPrinter<'tcx>:
             }
         }
 
-        {
-            define_scoped_cx!(self);
-            p!("impl ");
-        }
+        write!(self, "impl ")?;
 
         let mut first = true;
         // Insert parenthesis around (Fn(A, B) -> C) if the opaque ty has more than one other trait
         let paren_needed = fn_traits.len() > 1 || traits.len() > 0 || !is_sized;
 
         for (fn_once_trait_ref, entry) in fn_traits {
-            {
-                define_scoped_cx!(self);
-                p!(
-                    write("{}", if first { "" } else { " + " }),
-                    write("{}", if paren_needed { "(" } else { "" })
-                );
-            }
+            write!(self, "{}", if first { "" } else { " + " })?;
+            write!(self, "{}", if paren_needed { "(" } else { "" })?;
 
-            self = self.wrap_binder(&fn_once_trait_ref, |trait_ref, mut self_| {
+            self = self.wrap_binder(&fn_once_trait_ref, |trait_ref, mut cx| {
+                define_scoped_cx!(cx);
                 // Get the (single) generic ty (the args) of this FnOnce trait ref.
                 let generics = tcx.generics_of(trait_ref.def_id);
                 let args = generics.own_substs_no_defaults(tcx, trait_ref.substs);
@@ -852,7 +845,6 @@ pub trait PrettyPrinter<'tcx>:
                             "FnOnce"
                         };
 
-                        define_scoped_cx!(self_);
                         p!(write("{}(", name));
 
                         for (idx, ty) in arg_tys.tuple_fields().iter().enumerate() {
@@ -892,19 +884,16 @@ pub trait PrettyPrinter<'tcx>:
                     }
                 }
 
-                Ok(self_)
+                Ok(cx)
             })?;
         }
 
         // Print the rest of the trait types (that aren't Fn* family of traits)
         for (trait_ref, assoc_items) in traits {
-            {
-                define_scoped_cx!(self);
-                p!(write("{}", if first { "" } else { " + " }));
-            }
+            write!(self, "{}", if first { "" } else { " + " })?;
 
-            self = self.wrap_binder(&trait_ref, |trait_ref, mut self_| {
-                define_scoped_cx!(self_);
+            self = self.wrap_binder(&trait_ref, |trait_ref, mut cx| {
+                define_scoped_cx!(cx);
                 p!(print(trait_ref.print_only_trait_name()));
 
                 let generics = tcx.generics_of(trait_ref.def_id);
@@ -969,16 +958,14 @@ pub trait PrettyPrinter<'tcx>:
                 }
 
                 first = false;
-                Ok(self_)
+                Ok(cx)
             })?;
         }
 
-        define_scoped_cx!(self);
-
         if !is_sized {
-            p!(write("{}?Sized", if first { "" } else { " + " }));
+            write!(self, "{}?Sized", if first { "" } else { " + " })?;
         } else if first {
-            p!("Sized");
+            write!(self, "Sized")?;
         }
 
         Ok(self)
diff --git a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
index 43b7cb8cece..e9b76b19dc4 100644
--- a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
+++ b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
@@ -22,7 +22,7 @@ LL |   async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> {
 LL | |
 LL | | }
    | |_^
-   = note: required because it captures the following types: `ResumeTy`, `impl Future<Output = ()>`, `()`
+   = note: required because it captures the following types: `ResumeTy`, `impl for<'r, 's, 't0> Future<Output = ()>`, `()`
 note: required because it's used within this `async` block
   --> $DIR/issue-70935-complex-spans.rs:23:16
    |