ast::TyKind::Path(Some(ref qself), ref path) => {
self.print_qpath(path, qself, false)?
}
- ast::TyKind::TraitObject(ref bounds) => {
- self.print_bounds("", &bounds[..])?;
+ ast::TyKind::TraitObject(ref bounds, syntax) => {
+ let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn " } else { "" };
+ self.print_bounds(prefix, &bounds[..])?;
}
ast::TyKind::ImplTrait(ref bounds) => {
self.print_bounds("impl ", &bounds[..])?;
self.end()?; // end the head-ibox
self.end() // end the outer cbox
}
+ ast::ForeignItemKind::Ty => {
+ self.head(&visibility_qualified(&item.vis, "type"))?;
+ self.print_ident(item.ident)?;
+ self.s.word(";")?;
+ self.end()?; // end the head-ibox
+ self.end() // end the outer cbox
+ }
}
}
self.head(&visibility_qualified(&item.vis, "union"))?;
self.print_struct(struct_def, generics, item.ident, item.span, true)?;
}
- ast::ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
+ ast::ItemKind::AutoImpl(unsafety, ref trait_ref) => {
self.head("")?;
self.print_visibility(&item.vis)?;
self.print_unsafety(unsafety)?;
}
self.bclose(item.span)?;
}
- ast::ItemKind::Trait(unsafety, ref generics, ref bounds, ref trait_items) => {
+ ast::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref trait_items) => {
self.head("")?;
self.print_visibility(&item.vis)?;
self.print_unsafety(unsafety)?;
+ self.print_is_auto(is_auto)?;
self.word_nbsp("trait")?;
self.print_ident(item.ident)?;
self.print_generics(generics)?;
pub fn print_visibility(&mut self, vis: &ast::Visibility) -> io::Result<()> {
match *vis {
ast::Visibility::Public => self.word_nbsp("pub"),
- ast::Visibility::Crate(_) => self.word_nbsp("pub(crate)"),
+ ast::Visibility::Crate(_, sugar) => match sugar {
+ ast::CrateSugar::PubCrate => self.word_nbsp("pub(crate)"),
+ ast::CrateSugar::JustCrate => self.word_nbsp("crate")
+ }
ast::Visibility::Restricted { ref path, .. } => {
let path = to_string(|s| s.print_path(path, false, 0, true));
if path == "self" || path == "super" {
pub fn print_method_sig(&mut self,
ident: ast::Ident,
+ generics: &ast::Generics,
m: &ast::MethodSig,
vis: &ast::Visibility)
-> io::Result<()> {
m.constness.node,
m.abi,
Some(ident),
- &m.generics,
+ &generics,
vis)
}
if body.is_some() {
self.head("")?;
}
- self.print_method_sig(ti.ident, sig, &ast::Visibility::Inherited)?;
+ self.print_method_sig(ti.ident, &ti.generics, sig, &ast::Visibility::Inherited)?;
if let Some(ref body) = *body {
self.nbsp()?;
self.print_block_with_attrs(body, &ti.attrs)?;
}
ast::ImplItemKind::Method(ref sig, ref body) => {
self.head("")?;
- self.print_method_sig(ii.ident, sig, &ii.vis)?;
+ self.print_method_sig(ii.ident, &ii.generics, sig, &ii.vis)?;
self.nbsp()?;
self.print_block_with_attrs(body, &ii.attrs)?;
}
Fixity::None => (prec + 1, prec + 1),
};
+ let left_prec = match (&lhs.node, op.node) {
+ // These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is
+ // the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead
+ // of `(x as i32) < ...`. We need to convince it _not_ to do that.
+ (&ast::ExprKind::Cast { .. }, ast::BinOpKind::Lt) |
+ (&ast::ExprKind::Cast { .. }, ast::BinOpKind::Shl) => parser::PREC_FORCE_PAREN,
+ _ => left_prec,
+ };
+
self.print_expr_maybe_paren(lhs, left_prec)?;
self.s.space()?;
self.word_space(op.node.to_string())?;
if limits == ast::RangeLimits::HalfOpen {
self.s.word("..")?;
} else {
- self.s.word("...")?;
+ self.s.word("..=")?;
}
if let Some(ref e) = *end {
self.print_expr_maybe_paren(e, fake_prec)?;
ast::Unsafety::Unsafe => self.word_nbsp("unsafe"),
}
}
+
+ pub fn print_is_auto(&mut self, s: ast::IsAuto) -> io::Result<()> {
+ match s {
+ ast::IsAuto::Yes => self.word_nbsp("auto"),
+ ast::IsAuto::No => Ok(()),
+ }
+ }
}
fn repeat(s: &str, n: usize) -> String { iter::repeat(s).take(n).collect() }