1
Fork 0

Comments on their own lines between args

This commit is contained in:
Nick Cameron 2015-04-28 21:57:16 +12:00
parent cdfda8801e
commit 81b8eb7993
3 changed files with 12 additions and 4 deletions

View file

@ -236,10 +236,11 @@ impl<'a> FmtVisitor<'a> {
let cur_start = get_lo(&item);
let snippet = self.snippet(codemap::mk_sp(prev_end, cur_start));
let mut snippet = snippet.trim();
let white_space: &[_] = &[' ', '\t'];
if snippet.starts_with(separator) {
snippet = snippet[1..].trim();
snippet = snippet[separator.len()..].trim_matches(white_space);
} else if snippet.ends_with(separator) {
snippet = snippet[..snippet.len()-1].trim();
snippet = snippet[..snippet.len()-separator.len()].trim_matches(white_space);
}
result.push(snippet.to_string());
prev_end = get_hi(&item);

View file

@ -124,7 +124,9 @@ pub fn write_list<'b>(items: &[(String, String)], formatting: &ListFormatting<'b
result.push_str(item);
if tactic != ListTactic::Vertical && comment.len() > 0 {
result.push(' ');
if !comment.starts_with('\n') {
result.push(' ');
}
result.push_str(comment);
}
@ -133,7 +135,9 @@ pub fn write_list<'b>(items: &[(String, String)], formatting: &ListFormatting<'b
}
if tactic == ListTactic::Vertical && comment.len() > 0 {
result.push(' ');
if !comment.starts_with('\n') {
result.push(' ');
}
result.push_str(comment);
}
}

View file

@ -4,7 +4,10 @@
fn foo<F, G>(a: aaaaaaaaaaaaa, // A comment
b: bbbbbbbbbbbbb, /* a second comment */
c: ccccccccccccc,
// Newline comment
d: ddddddddddddd,
// A multi line comment
// between args.
e: eeeeeeeeeeeee /* comment before paren*/)
-> bar
where F: Foo, // COmment after where clause