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> {
// The leading "," is not part of the arm-comment
let missed_str = match missed_str.find_uncommented(",") {
Some(n) => &missed_str[n+1..],
Some(n) => &missed_str[n + 1..],
None => &missed_str[..],
};
@ -816,7 +816,7 @@ fn rewrite_match(context: &RewriteContext,
let missed_str = if i == 0 {
context.snippet(mk_sp(open_brace_pos, arm_start_pos(arm)))
} 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,
&missed_str,

View File

@ -476,7 +476,7 @@ impl<'a> FmtVisitor<'a> {
};
let more_items = itemize_list(self.codemap,
args[min_args-1..].iter(),
args[min_args - 1..].iter(),
")",
|arg| span_lo_for_arg(arg),
|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.
// 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());
// From the end of the first line of comments.
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("\n");
} else {
self.buffer.push_str(&snippet[line_start..i+1]);
self.buffer.push_str(&snippet[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);
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
// comments. An alternative would be to force such line breaks to start
// with the usual doc comment token.