Merge pull request #2154 from topecongiro/issue-2151

Look for a newline after match arm only when there is one
This commit is contained in:
Nick Cameron 2017-11-15 16:46:15 +13:00 committed by GitHub
commit 5a91e0f7e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -602,7 +602,11 @@ where
// Match arms may not have trailing comma. In any case, for match arms,
// we will assume that the post comment belongs to the next arm if they
// do not end with trailing comma.
1
if let Some(newline_index) = newline_index {
newline_index + 1
} else {
0
}
}
}
None => post_snippet

View File

@ -435,6 +435,15 @@ impl<'tcx> Const<'tcx> {
}
}
// #2151
fn issue_2151() {
match either {
x => {
}y => ()
}
}
// #2152
fn issue_2152() {
match m {

View File

@ -128,15 +128,13 @@ fn issue339() {
h => {
// comment above block
}
i => {}
// comment below block
i => {} // comment below block
j => {
// comment inside block
}
j2 => {
// comments inside...
}
// ... and after
} // ... and after
// TODO uncomment when vertical whitespace is handled better
// k => {
//
@ -476,6 +474,14 @@ impl<'tcx> Const<'tcx> {
}
}
// #2151
fn issue_2151() {
match either {
x => {}
y => (),
}
}
// #2152
fn issue_2152() {
match m {