]> git.lizzy.rs Git - rust.git/commitdiff
Add pretty printer output for `default`
authorAaron Turon <aturon@mozilla.com>
Mon, 14 Mar 2016 05:55:26 +0000 (22:55 -0700)
committerAaron Turon <aturon@mozilla.com>
Mon, 14 Mar 2016 22:05:16 +0000 (15:05 -0700)
src/librustc_front/print/pprust.rs
src/libsyntax/print/pprust.rs
src/test/run-pass/specialization/specialization-default-methods.rs

index 143dfce09b6029f1ee20cd12a22f22797edb7b9b..1100f084454c729747c50c057819d5e80acbecda 100644 (file)
@@ -1014,6 +1014,11 @@ pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
         try!(self.hardbreak_if_not_bol());
         try!(self.maybe_print_comment(ii.span.lo));
         try!(self.print_outer_attributes(&ii.attrs));
+
+        if let hir::Defaultness::Default = ii.defaultness {
+            try!(self.word_nbsp("default"));
+        }
+
         match ii.node {
             hir::ImplItemKind::Const(ref ty, ref expr) => {
                 try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis));
index 2cfed1f82f7ecd455788845cfa85db68f1ba2043..533487ae1c547cb59fa0e613a43e38df08f195b5 100644 (file)
@@ -1582,6 +1582,9 @@ pub fn print_impl_item(&mut self, ii: &ast::ImplItem) -> io::Result<()> {
         try!(self.hardbreak_if_not_bol());
         try!(self.maybe_print_comment(ii.span.lo));
         try!(self.print_outer_attributes(&ii.attrs));
+        if let ast::Defaultness::Default = ii.defaultness {
+            try!(self.word_nbsp("default"));
+        }
         match ii.node {
             ast::ImplItemKind::Const(ref ty, ref expr) => {
                 try!(self.print_associated_const(ii.ident, &ty, Some(&expr), ii.vis));
index b2fad9d171f9dfe1e0e44a6e48730a679987f3b0..3f0f21ff03f27948c3b958ddd2ab4ed1f23774d9 100644 (file)
@@ -63,7 +63,8 @@ fn bar(&self) -> i32 { 0 }
 //                   /  \
 //            Vec<i32>  $Vec<i64>
 
-impl<T> Bar for T {} // use the provided method
+// use the provided method
+impl<T> Bar for T {}
 
 impl Bar for i32 {
     fn bar(&self) -> i32 { 1 }