pub use self::AnnNode::*;
use abi::{self, Abi};
-use ast::{self, TokenTree, BlockCheckMode};
+use ast::{self, TokenTree, BlockCheckMode, PatKind};
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
use ast::Attribute;
use attr::ThinAttributesExt;
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));
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));
}
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)));
/* Pat isn't normalized, but the beauty of it
is that it doesn't matter */
match pat.node {
- ast::PatWild => try!(word(&mut self.s, "_")),
- ast::PatIdent(binding_mode, ref path1, ref sub) => {
+ PatKind::Wild => try!(word(&mut self.s, "_")),
+ PatKind::Ident(binding_mode, ref path1, ref sub) => {
match binding_mode {
ast::BindingMode::ByRef(mutbl) => {
try!(self.word_nbsp("ref"));
None => ()
}
}
- ast::PatEnum(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());
}
}
}
- ast::PatQPath(ref qself, ref path) => {
+ PatKind::Path(ref path) => {
+ try!(self.print_path(path, true, 0));
+ }
+ PatKind::QPath(ref qself, ref path) => {
try!(self.print_qpath(path, qself, false));
}
- ast::PatStruct(ref path, ref fields, etc) => {
+ PatKind::Struct(ref path, ref fields, etc) => {
try!(self.print_path(path, true, 0));
try!(self.nbsp());
try!(self.word_space("{"));
try!(space(&mut self.s));
try!(word(&mut self.s, "}"));
}
- ast::PatTup(ref elts) => {
+ PatKind::Tup(ref elts) => {
try!(self.popen());
try!(self.commasep(Inconsistent,
&elts[..],
}
try!(self.pclose());
}
- ast::PatBox(ref inner) => {
+ PatKind::Box(ref inner) => {
try!(word(&mut self.s, "box "));
try!(self.print_pat(&inner));
}
- ast::PatRegion(ref inner, mutbl) => {
+ PatKind::Ref(ref inner, mutbl) => {
try!(word(&mut self.s, "&"));
if mutbl == ast::Mutability::Mutable {
try!(word(&mut self.s, "mut "));
}
try!(self.print_pat(&inner));
}
- ast::PatLit(ref e) => try!(self.print_expr(&e)),
- ast::PatRange(ref begin, ref end) => {
+ PatKind::Lit(ref e) => try!(self.print_expr(&**e)),
+ PatKind::Range(ref begin, ref end) => {
try!(self.print_expr(&begin));
try!(space(&mut self.s));
try!(word(&mut self.s, "..."));
try!(self.print_expr(&end));
}
- ast::PatVec(ref before, ref slice, ref after) => {
+ PatKind::Vec(ref before, ref slice, ref after) => {
try!(word(&mut self.s, "["));
try!(self.commasep(Inconsistent,
&before[..],
|s, p| s.print_pat(&p)));
if let Some(ref p) = *slice {
if !before.is_empty() { try!(self.word_space(",")); }
- if p.node != ast::PatWild {
+ if p.node != PatKind::Wild {
try!(self.print_pat(&p));
}
try!(word(&mut self.s, ".."));
|s, p| s.print_pat(&p)));
try!(word(&mut self.s, "]"));
}
- ast::PatMac(ref m) => try!(self.print_mac(m, token::Paren)),
+ PatKind::Mac(ref m) => try!(self.print_mac(m, token::Paren)),
}
self.ann.post(self, NodePat(pat))
}
let m = match *explicit_self {
ast::SelfKind::Static => ast::Mutability::Immutable,
_ => match decl.inputs[0].pat.node {
- ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
+ PatKind::Ident(ast::BindingMode::ByValue(m), _, _) => m,
_ => ast::Mutability::Immutable
}
};
ast::TyKind::Infer if is_closure => try!(self.print_pat(&input.pat)),
_ => {
match input.pat.node {
- ast::PatIdent(_, ref path1, _) if
+ PatKind::Ident(_, ref path1, _) if
path1.node.name ==
parse::token::special_idents::invalid.name => {
// Do nothing.