Allow {}
to remain.
This commit is contained in:
parent
dc2544712c
commit
d10629d8a5
@ -112,6 +112,11 @@ impl Rewrite for ast::Expr {
|
||||
|
||||
impl Rewrite for ast::Block {
|
||||
fn rewrite(&self, context: &RewriteContext, width: usize, offset: usize) -> Option<String> {
|
||||
let user_str = context.codemap.span_to_snippet(self.span).unwrap();
|
||||
if user_str == "{}" && width > 1 {
|
||||
return Some(user_str);
|
||||
}
|
||||
|
||||
let mut visitor = FmtVisitor::from_codemap(context.codemap, context.config);
|
||||
visitor.block_indent = context.block_indent;
|
||||
|
||||
|
@ -91,3 +91,16 @@ fn baz() {
|
||||
// Regular unsafe block
|
||||
}
|
||||
}
|
||||
|
||||
// Test some empty blocks.
|
||||
fn qux() {
|
||||
{}
|
||||
// FIXME this one could be done better.
|
||||
{ /* a block with a comment */ }
|
||||
{
|
||||
|
||||
}
|
||||
{
|
||||
// A block with a comment.
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,13 @@ fn foo() -> bool {
|
||||
aaaaa)))))))));
|
||||
|
||||
{
|
||||
for _ in 0..10 {
|
||||
}
|
||||
for _ in 0..10 {}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
}
|
||||
{}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,8 +45,7 @@ fn foo() -> bool {
|
||||
}
|
||||
|
||||
if let Some(x) = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {
|
||||
}
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
|
||||
|
||||
if let (some_very_large,
|
||||
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 {
|
||||
@ -56,8 +53,7 @@ fn foo() -> bool {
|
||||
|
||||
if let (some_very_large,
|
||||
tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1111 +
|
||||
2222 {
|
||||
}
|
||||
2222 {}
|
||||
|
||||
if let (some_very_large, tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) =
|
||||
1 + 2 + 3 {
|
||||
@ -121,3 +117,17 @@ fn baz() {
|
||||
// Regular unsafe block
|
||||
}
|
||||
}
|
||||
|
||||
// Test some empty blocks.
|
||||
fn qux() {
|
||||
{}
|
||||
// FIXME this one could be done better.
|
||||
{ /* a block with a comment */
|
||||
}
|
||||
{
|
||||
|
||||
}
|
||||
{
|
||||
// A block with a comment.
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ fn main() {
|
||||
}
|
||||
|
||||
'a: while loooooooooooooooooooooooooooooooooong_variable_name + another_value >
|
||||
some_other_value {
|
||||
}
|
||||
some_other_value {}
|
||||
|
||||
while aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user