]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/print/pprust.rs
Add pretty printer output for `default`
[rust.git] / src / libsyntax / print / pprust.rs
index 5a1a581bc430876d31d1b9c5e9d6cfd725fde085..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));
@@ -2163,11 +2166,15 @@ fn print_expr_outer_attr_style(&mut self,
                 try!(self.print_expr(&index));
                 try!(word(&mut self.s, "]"));
             }
-            ast::ExprKind::Range(ref start, ref end) => {
+            ast::ExprKind::Range(ref start, ref end, limits) => {
                 if let &Some(ref e) = start {
                     try!(self.print_expr(&e));
                 }
-                try!(word(&mut self.s, ".."));
+                if limits == ast::RangeLimits::HalfOpen {
+                    try!(word(&mut self.s, ".."));
+                } else {
+                    try!(word(&mut self.s, "..."));
+                }
                 if let &Some(ref e) = end {
                     try!(self.print_expr(&e));
                 }
@@ -2273,6 +2280,10 @@ fn print_expr_outer_attr_style(&mut self,
                 try!(self.print_inner_attributes_inline(attrs));
                 try!(self.print_expr(&e));
                 try!(self.pclose());
+            },
+            ast::ExprKind::Try(ref e) => {
+                try!(self.print_expr(e));
+                try!(word(&mut self.s, "?"))
             }
         }
         try!(self.ann.post(self, NodeExpr(expr)));
@@ -2478,20 +2489,21 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
                     None => ()
                 }
             }
-            PatKind::Enum(ref path, ref args_) => {
+            PatKind::TupleStruct(ref path, ref args_) => {
                 try!(self.print_path(path, true, 0));
                 match *args_ {
                     None => try!(word(&mut self.s, "(..)")),
                     Some(ref args) => {
-                        if !args.is_empty() {
-                            try!(self.popen());
-                            try!(self.commasep(Inconsistent, &args[..],
-                                              |s, p| s.print_pat(&p)));
-                            try!(self.pclose());
-                        }
+                        try!(self.popen());
+                        try!(self.commasep(Inconsistent, &args[..],
+                                          |s, p| s.print_pat(&p)));
+                        try!(self.pclose());
                     }
                 }
             }
+            PatKind::Path(ref path) => {
+                try!(self.print_path(path, true, 0));
+            }
             PatKind::QPath(ref qself, ref path) => {
                 try!(self.print_qpath(path, qself, false));
             }