]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/print/pprust.rs
rollup merge of #20482: kmcallister/macro-reform
[rust.git] / src / libsyntax / print / pprust.rs
index 9702c79719c64ac62b20dd53fb3e8af0972d411d..402583b60fae5387e6c89055f875408341539c5e 100644 (file)
@@ -272,6 +272,8 @@ pub fn token_to_string(tok: &Token) -> String {
         token::Comment              => "/* */".to_string(),
         token::Shebang(s)           => format!("/* shebang: {}*/", s.as_str()),
 
+        token::SpecialVarNt(var)    => format!("${}", var.as_str()),
+
         token::Interpolated(ref nt) => match *nt {
             token::NtExpr(ref e)  => expr_to_string(&**e),
             token::NtMeta(ref e)  => meta_item_to_string(&**e),
@@ -714,25 +716,6 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> {
                                       Some(&generics),
                                       None));
             }
-            ast::TyClosure(ref f) => {
-                let generics = ast::Generics {
-                    lifetimes: f.lifetimes.clone(),
-                    ty_params: OwnedSlice::empty(),
-                    where_clause: ast::WhereClause {
-                        id: ast::DUMMY_NODE_ID,
-                        predicates: Vec::new(),
-                    },
-                };
-                try!(self.print_ty_fn(None,
-                                      Some('&'),
-                                      f.unsafety,
-                                      f.onceness,
-                                      &*f.decl,
-                                      None,
-                                      &f.bounds,
-                                      Some(&generics),
-                                      None));
-            }
             ast::TyPath(ref path, _) => {
                 try!(self.print_path(path, false));
             }
@@ -917,6 +900,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
             }
 
             ast::ItemImpl(unsafety,
+                          polarity,
                           ref generics,
                           ref opt_trait,
                           ref ty,
@@ -931,6 +915,13 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
                     try!(space(&mut self.s));
                 }
 
+                match polarity {
+                    ast::ImplPolarity::Negative => {
+                        try!(word(&mut self.s, "!"));
+                    },
+                    _ => {}
+                }
+
                 match opt_trait {
                     &Some(ref t) => {
                         try!(self.print_trait_ref(t));
@@ -1067,7 +1058,6 @@ pub fn print_struct(&mut self,
                         span: codemap::Span) -> IoResult<()> {
         try!(self.print_ident(ident));
         try!(self.print_generics(generics));
-        try!(self.print_where_clause(generics));
         if ast_util::struct_def_is_tuple_like(struct_def) {
             if !struct_def.fields.is_empty() {
                 try!(self.popen());
@@ -1086,10 +1076,12 @@ pub fn print_struct(&mut self,
                 ));
                 try!(self.pclose());
             }
+            try!(self.print_where_clause(generics));
             try!(word(&mut self.s, ";"));
             try!(self.end());
             self.end() // close the outer-box
         } else {
+            try!(self.print_where_clause(generics));
             try!(self.nbsp());
             try!(self.bopen());
             try!(self.hardbreak_if_not_bol());
@@ -2092,8 +2084,11 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> IoResult<()> {
                 try!(word(&mut self.s, "box "));
                 try!(self.print_pat(&**inner));
             }
-            ast::PatRegion(ref inner) => {
+            ast::PatRegion(ref inner, mutbl) => {
                 try!(word(&mut self.s, "&"));
+                if mutbl == ast::MutMutable {
+                    try!(word(&mut self.s, "mut "));
+                }
                 try!(self.print_pat(&**inner));
             }
             ast::PatLit(ref e) => try!(self.print_expr(&**e)),