1
Fork 0

Format rustfmt's own indices

This commit is contained in:
Marcus Klaas 2015-10-02 11:48:52 +02:00
parent ad2e3b8e2b
commit 84718b5b90
5 changed files with 6 additions and 6 deletions

View file

@ -756,7 +756,7 @@ fn rewrite_match_arm_comment(context: &RewriteContext,
-> Option<String> { -> Option<String> {
// The leading "," is not part of the arm-comment // The leading "," is not part of the arm-comment
let missed_str = match missed_str.find_uncommented(",") { let missed_str = match missed_str.find_uncommented(",") {
Some(n) => &missed_str[n+1..], Some(n) => &missed_str[n + 1..],
None => &missed_str[..], None => &missed_str[..],
}; };
@ -816,7 +816,7 @@ fn rewrite_match(context: &RewriteContext,
let missed_str = if i == 0 { let missed_str = if i == 0 {
context.snippet(mk_sp(open_brace_pos, arm_start_pos(arm))) context.snippet(mk_sp(open_brace_pos, arm_start_pos(arm)))
} else { } else {
context.snippet(mk_sp(arm_end_pos(&arms[i-1]), arm_start_pos(arm))) context.snippet(mk_sp(arm_end_pos(&arms[i - 1]), arm_start_pos(arm)))
}; };
let comment = try_opt!(rewrite_match_arm_comment(context, let comment = try_opt!(rewrite_match_arm_comment(context,
&missed_str, &missed_str,

View file

@ -476,7 +476,7 @@ impl<'a> FmtVisitor<'a> {
}; };
let more_items = itemize_list(self.codemap, let more_items = itemize_list(self.codemap,
args[min_args-1..].iter(), args[min_args - 1..].iter(),
")", ")",
|arg| span_lo_for_arg(arg), |arg| span_lo_for_arg(arg),
|arg| arg.ty.span.hi, |arg| arg.ty.span.hi,

View file

@ -379,7 +379,7 @@ impl<'a, T, I, F1, F2, F3> Iterator for ListItems<'a, I, F1, F2, F3>
// because of the way we divide pre- and post- comments. // because of the way we divide pre- and post- comments.
// Everything from the separator to the next item. // Everything from the separator to the next item.
let test_snippet = &post_snippet[comment_end-1..]; let test_snippet = &post_snippet[comment_end - 1..];
let first_newline = test_snippet.find('\n').unwrap_or(test_snippet.len()); let first_newline = test_snippet.find('\n').unwrap_or(test_snippet.len());
// From the end of the first line of comments. // From the end of the first line of comments.
let test_snippet = &test_snippet[first_newline..]; let test_snippet = &test_snippet[first_newline..];

View file

@ -78,7 +78,7 @@ impl<'a> FmtVisitor<'a> {
self.buffer.push_str(&snippet[line_start..lw]); self.buffer.push_str(&snippet[line_start..lw]);
self.buffer.push_str("\n"); self.buffer.push_str("\n");
} else { } else {
self.buffer.push_str(&snippet[line_start..i+1]); self.buffer.push_str(&snippet[line_start..i + 1]);
} }
line_start = i + 1; line_start = i + 1;

View file

@ -407,7 +407,7 @@ impl<'a> Rewrite for [ast::Attribute] {
let a_str = context.snippet(a.span); let a_str = context.snippet(a.span);
if i > 0 { if i > 0 {
let comment = context.snippet(codemap::mk_sp(self[i-1].span.hi, a.span.lo)); let comment = context.snippet(codemap::mk_sp(self[i - 1].span.hi, a.span.lo));
// This particular horror show is to preserve line breaks in between doc // This particular horror show is to preserve line breaks in between doc
// comments. An alternative would be to force such line breaks to start // comments. An alternative would be to force such line breaks to start
// with the usual doc comment token. // with the usual doc comment token.