Merge pull request #334 from marcusklaas/sparse-mods

Place the closing brace of an inline mod on a new line
This commit is contained in:
Marcus Klaas de Vries 2015-09-21 19:42:36 +02:00
commit fa67e0359a
3 changed files with 32 additions and 2 deletions

View file

@ -326,11 +326,13 @@ impl<'a> FmtVisitor<'a> {
// TODO: Should rewrite properly `mod X;`
if is_internal {
debug!("FmtVisitor::format_mod: internal mod");
self.block_indent = self.block_indent.block_indent(self.config);
visit::walk_mod(self, m);
debug!("... last_pos after: {:?}", self.last_pos);
self.block_indent = self.block_indent.block_unindent(self.config);
self.format_missing_with_indent(m.inner.hi - BytePos(1));
self.buffer.push_str("}");
self.last_pos = m.inner.hi;
}
}

17
tests/source/mod-1.rs Normal file
View file

@ -0,0 +1,17 @@
// Deeply indented modules.
mod foo { mod bar { mod baz {} } }
mod foo {
mod bar {
mod baz {
fn foo() { bar() }
}
}
mod qux {
}
}
mod boxed { pub use std::boxed::{Box, HEAP}; }

View file

@ -1,5 +1,12 @@
// Deeply indented modules.
mod foo {
mod bar {
mod baz {
}
}
}
mod foo {
mod bar {
mod baz {
@ -13,3 +20,7 @@ mod foo {
}
}
mod boxed {
pub use std::boxed::{Box, HEAP};
}