]> git.lizzy.rs Git - rust.git/commitdiff
Fix unclosed boxes in pretty printing of TraitAlias
authorDavid Tolnay <dtolnay@gmail.com>
Sun, 2 Jan 2022 01:52:15 +0000 (17:52 -0800)
committerDavid Tolnay <dtolnay@gmail.com>
Sun, 2 Jan 2022 02:02:00 +0000 (18:02 -0800)
compiler/rustc_ast_pretty/src/pprust/state.rs
compiler/rustc_hir_pretty/src/lib.rs
src/test/ui/macros/stringify.rs

index b87dd449a1e57131cab019899a0f750c51b75fb0..b5b87c0b48af1425bc43641ade84e108dddeb024 100644 (file)
@@ -1354,9 +1354,7 @@ fn print_associated_type(
                 self.bclose(item.span, empty);
             }
             ast::ItemKind::TraitAlias(ref generics, ref bounds) => {
-                self.head("");
-                self.print_visibility(&item.vis);
-                self.word_nbsp("trait");
+                self.head(visibility_qualified(&item.vis, "trait"));
                 self.print_ident(item.ident);
                 self.print_generic_params(&generics.params);
                 let mut real_bounds = Vec::with_capacity(bounds.len());
@@ -1374,6 +1372,8 @@ fn print_associated_type(
                 self.print_type_bounds("=", &real_bounds);
                 self.print_where_clause(&generics.where_clause);
                 self.word(";");
+                self.end(); // end inner head-block
+                self.end(); // end outer head-block
             }
             ast::ItemKind::MacCall(ref mac) => {
                 self.print_mac(mac);
index fb11aaf24c4b8d15804de10ab819e2036a29ef29..ad47c69652035fa652c9f9d5da556c8e8970fbbf 100644 (file)
@@ -705,9 +705,7 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
                 self.bclose(item.span);
             }
             hir::ItemKind::TraitAlias(ref generics, ref bounds) => {
-                self.head("");
-                self.print_visibility(&item.vis);
-                self.word_nbsp("trait");
+                self.head(visibility_qualified(&item.vis, "trait"));
                 self.print_ident(item.ident);
                 self.print_generic_params(&generics.params);
                 let mut real_bounds = Vec::with_capacity(bounds.len());
@@ -725,6 +723,8 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
                 self.print_bounds("=", real_bounds);
                 self.print_where_clause(&generics.where_clause);
                 self.word(";");
+                self.end(); // end inner head-block
+                self.end(); // end outer head-block
             }
         }
         self.ann.post(self, AnnNode::Item(item))
index 343a26c14a9b0034ce617331362db35d7c38d5ed..36e01a7508f3408926fae60cd88713a9667ba2e1 100644 (file)
@@ -589,7 +589,7 @@ trait Trait<'a>: Sized
         stringify_item!(
             pub trait Trait<T> = Sized where T: 'a;
         ),
-        "", // FIXME
+        "pub trait Trait<T> = Sized where T: 'a;",
     );
 
     // ItemKind::Impl