Merge pull request #1732 from olson-sean-k/issue-1377

Keep brace on same line as `match` when using `ClosingNextLine`.
This commit is contained in:
Seiichi Uchida 2017-06-20 12:07:03 +09:00 committed by GitHub
commit f74be44b1c
7 changed files with 27 additions and 2 deletions

View File

@ -1461,8 +1461,8 @@ fn rewrite_match(
let cond_str = try_opt!(cond.rewrite(context, cond_shape)); let cond_str = try_opt!(cond.rewrite(context, cond_shape));
let alt_block_sep = String::from("\n") + &shape.indent.block_only().to_string(context.config); let alt_block_sep = String::from("\n") + &shape.indent.block_only().to_string(context.config);
let block_sep = match context.config.control_brace_style() { let block_sep = match context.config.control_brace_style() {
ControlBraceStyle::AlwaysSameLine => " ", ControlBraceStyle::AlwaysNextLine => alt_block_sep.as_str(),
_ => alt_block_sep.as_str(), _ => " ",
}; };
let mut result = format!("match {}{}{{", cond_str, block_sep); let mut result = format!("match {}{}{{", cond_str, block_sep);

View File

@ -3,4 +3,8 @@
fn main() { fn main() {
if lorem { println!("ipsum!"); } else { println!("dolor!"); } if lorem { println!("ipsum!"); } else { println!("dolor!"); }
match magi {
Homura => "Akemi",
Madoka => "Kaname",
}
} }

View File

@ -3,4 +3,8 @@
fn main() { fn main() {
if lorem { println!("ipsum!"); } else { println!("dolor!"); } if lorem { println!("ipsum!"); } else { println!("dolor!"); }
match magi {
Homura => "Akemi",
Madoka => "Kaname",
}
} }

View File

@ -3,4 +3,8 @@
fn main() { fn main() {
if lorem { println!("ipsum!"); } else { println!("dolor!"); } if lorem { println!("ipsum!"); } else { println!("dolor!"); }
match magi {
Homura => "Akemi",
Madoka => "Kaname",
}
} }

View File

@ -10,4 +10,9 @@ fn main() {
{ {
println!("dolor!"); println!("dolor!");
} }
match magi
{
Homura => "Akemi",
Madoka => "Kaname",
}
} }

View File

@ -7,4 +7,8 @@ fn main() {
} else { } else {
println!("dolor!"); println!("dolor!");
} }
match magi {
Homura => "Akemi",
Madoka => "Kaname",
}
} }

View File

@ -8,4 +8,8 @@ fn main() {
else { else {
println!("dolor!"); println!("dolor!");
} }
match magi {
Homura => "Akemi",
Madoka => "Kaname",
}
} }