syntax: Improve --pretty normal slightly
When printing doc comments, always put a newline after them in a macro invocation to ensure that a line-doc-comment doesn't consume remaining tokens on the line.
This commit is contained in:
parent
25ac81eb89
commit
6878039c12
@ -360,9 +360,9 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> StrBuf {
|
||||
ty_uint(t) => ast_util::uint_ty_to_str(t, None,
|
||||
ast_util::AutoSuffix).to_strbuf(),
|
||||
ty_float(t) => ast_util::float_ty_to_str(t).to_strbuf(),
|
||||
ty_box(typ) => "@".to_strbuf() + ty_to_str(cx, typ),
|
||||
ty_uniq(typ) => "~".to_strbuf() + ty_to_str(cx, typ),
|
||||
ty_ptr(ref tm) => "*".to_strbuf() + mt_to_str(cx, tm),
|
||||
ty_box(typ) => format_strbuf!("@{}", ty_to_str(cx, typ)),
|
||||
ty_uniq(typ) => format_strbuf!("~{}", ty_to_str(cx, typ)),
|
||||
ty_ptr(ref tm) => format_strbuf!("*{}", mt_to_str(cx, tm)),
|
||||
ty_rptr(r, ref tm) => {
|
||||
let mut buf = region_ptr_to_str(cx, r);
|
||||
buf.push_str(mt_to_str(cx, tm).as_slice());
|
||||
@ -370,7 +370,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> StrBuf {
|
||||
}
|
||||
ty_tup(ref elems) => {
|
||||
let strs: Vec<StrBuf> = elems.iter().map(|elem| ty_to_str(cx, *elem)).collect();
|
||||
("(".to_strbuf() + strs.connect(",") + ")").to_strbuf()
|
||||
format_strbuf!("({})", strs.connect(","))
|
||||
}
|
||||
ty_closure(ref f) => {
|
||||
closure_to_str(cx, *f)
|
||||
|
@ -841,7 +841,13 @@ impl<'a> State<'a> {
|
||||
match *tt {
|
||||
ast::TTDelim(ref tts) => self.print_tts(tts.as_slice()),
|
||||
ast::TTTok(_, ref tk) => {
|
||||
word(&mut self.s, parse::token::to_str(tk).as_slice())
|
||||
try!(word(&mut self.s, parse::token::to_str(tk).as_slice()));
|
||||
match *tk {
|
||||
parse::token::DOC_COMMENT(..) => {
|
||||
hardbreak(&mut self.s)
|
||||
}
|
||||
_ => Ok(())
|
||||
}
|
||||
}
|
||||
ast::TTSeq(_, ref tts, ref sep, zerok) => {
|
||||
try!(word(&mut self.s, "$("));
|
||||
@ -2238,7 +2244,7 @@ impl<'a> State<'a> {
|
||||
ast::LitUint(u, t) => {
|
||||
word(&mut self.s,
|
||||
ast_util::uint_ty_to_str(t, Some(u),
|
||||
ast_util::AutoSuffix).as_slice())
|
||||
ast_util::ForceSuffix).as_slice())
|
||||
}
|
||||
ast::LitIntUnsuffixed(i) => {
|
||||
word(&mut self.s, format!("{}", i))
|
||||
|
Loading…
Reference in New Issue
Block a user