pub use self::AnnNode::*;
use abi;
-use ast::{mod, FnUnboxedClosureKind, FnMutUnboxedClosureKind};
+use ast::{self, FnUnboxedClosureKind, FnMutUnboxedClosureKind};
use ast::{FnOnceUnboxedClosureKind};
use ast::{MethodImplItem, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
use ast::{RequiredMethod, ProvidedMethod, TypeImplItem, TypeTraitItem};
use ast_util;
use owned_slice::OwnedSlice;
use attr::{AttrMetaMethods, AttributeMethods};
-use codemap::{mod, CodeMap, BytePos};
+use codemap::{self, CodeMap, BytePos};
use diagnostic;
-use parse::token::{mod, BinOpToken, Token};
+use parse::token::{self, BinOpToken, Token};
use parse::lexer::comments;
use parse;
-use print::pp::{mod, break_offset, word, space, zerobreak, hardbreak};
+use print::pp::{self, break_offset, word, space, zerobreak, hardbreak};
use print::pp::{Breaks, Consistent, Inconsistent, eof};
use ptr::P;
use std::{ascii, mem};
-use std::io::{mod, IoResult};
+use std::io::{self, IoResult};
use std::iter;
pub enum AnnNode<'a> {
fn post(&self, _state: &mut State, _node: AnnNode) -> IoResult<()> { Ok(()) }
}
-#[deriving(Copy)]
+#[derive(Copy)]
pub struct NoAnn;
impl PpAnn for NoAnn {}
-#[deriving(Copy)]
+#[derive(Copy)]
pub struct CurrentCommentAndLiteral {
cur_cmnt: uint,
cur_lit: uint,
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),
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));
}
}
ast::ItemImpl(unsafety,
+ polarity,
ref generics,
ref opt_trait,
ref ty,
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));
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());
));
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());
pub fn print_local_decl(&mut self, loc: &ast::Local) -> IoResult<()> {
try!(self.print_pat(&*loc.pat));
- match loc.ty.node {
- ast::TyInfer => Ok(()),
- _ => {
- try!(self.word_space(":"));
- self.print_type(&*loc.ty)
- }
+ if let Some(ref ty) = loc.ty {
+ try!(self.word_space(":"));
+ try!(self.print_type(&**ty));
}
+ Ok(())
}
pub fn print_decl(&mut self, decl: &ast::Decl) -> 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)),
s.print_ident(name)
},
ast::PathListMod { .. } => {
- word(&mut s.s, "mod")
+ word(&mut s.s, "self")
}
}
}));