Merge pull request #387 from marcusklaas/prevent-overflow

Prevent arithmetic overflow handling match arm comments
This commit is contained in:
Nick Cameron 2015-09-28 09:27:44 +13:00
commit d7efdd60c8
3 changed files with 15 additions and 6 deletions

View File

@ -693,11 +693,6 @@ fn rewrite_match_arm_comment(context: &RewriteContext,
Some(n) => &missed_str[n+1..],
None => &missed_str[..],
};
// Nor the trailing "}" which closes the match
let missed_str = match missed_str.find_uncommented("}") {
Some(n) => &missed_str[..n-1],
None => &missed_str[..],
};
let mut result = String::new();
// any text not preceeded by a newline is pushed unmodified to the block
@ -777,7 +772,10 @@ fn rewrite_match(context: &RewriteContext,
result.push_str(&snippet);
}
}
let last_comment = context.snippet(mk_sp(arm_end_pos(&arms[arms.len() - 1]), span.hi));
// BytePos(1) = closing match brace.
let last_span = mk_sp(arm_end_pos(&arms[arms.len() - 1]),
span.hi - BytePos(1));
let last_comment = context.snippet(last_span);
let comment = try_opt!(rewrite_match_arm_comment(context,
&last_comment,
width,

View File

@ -221,3 +221,7 @@ fn issue280() {
}
}
}
fn issue383() {
match resolution.last_private {LastImport{..} => false, _ => true};
}

View File

@ -210,3 +210,10 @@ fn issue280() {
}
}
}
fn issue383() {
match resolution.last_private {
LastImport{..} => false,
_ => true,
};
}