use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorTactic};
use macros::{rewrite_macro, MacroPosition};
use rewrite::{Rewrite, RewriteContext};
-use utils::{self, mk_sp};
+use utils::{self, contains_skip, mk_sp};
fn is_use_item(item: &ast::Item) -> bool {
match item.node {
ast::StmtKind::Item(ref item) => {
self.visit_item(item);
}
- ast::StmtKind::Local(..) => {
- let rewrite = stmt.rewrite(
- &self.get_context(),
- Shape::indented(self.block_indent, self.config),
- );
+ ast::StmtKind::Local(ref local) => {
+ let rewrite = if contains_skip(&local.attrs) {
+ None
+ } else {
+ stmt.rewrite(
+ &self.get_context(),
+ Shape::indented(self.block_indent, self.config),
+ )
+ };
self.push_rewrite(stmt.span, rewrite);
}
ast::StmtKind::Expr(ref expr) => {
self.push_rewrite(span, rewrite)
}
ast::StmtKind::Mac(ref mac) => {
- let (ref mac, _macro_style, _) = **mac;
- self.visit_mac(mac, None, MacroPosition::Statement);
+ let (ref mac, _macro_style, ref attrs) = **mac;
+ if contains_skip(attrs) {
+ self.push_rewrite(mac.span, None);
+ } else {
+ self.visit_mac(mac, None, MacroPosition::Statement);
+ }
self.format_missing(stmt.span.hi);
}
}
}
}))
}
+
+fn skip_on_statements() {
+ // Semi
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ foo(
+ 1, 2, 3, 4,
+ 1, 2,
+ 1, 2, 3,
+ );
+
+ // Local
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ let x = foo( a, b , c);
+
+ // Item
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ use foobar ;
+
+ // Mac
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ vec![
+ 1, 2, 3, 4,
+ 1, 2, 3, 4,
+ 1, 2, 3, 4,
+ 1, 2, 3,
+ 1,
+ 1, 2,
+ 1,
+ ];
+
+ // Expr
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ foo( a, b , c)
+}
}
}))
}
+
+fn skip_on_statements() {
+ // Semi
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ foo(
+ 1, 2, 3, 4,
+ 1, 2,
+ 1, 2, 3,
+ );
+
+ // Local
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ let x = foo( a, b , c);
+
+ // Item
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ use foobar ;
+
+ // Mac
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ vec![
+ 1, 2, 3, 4,
+ 1, 2, 3, 4,
+ 1, 2, 3, 4,
+ 1, 2, 3,
+ 1,
+ 1, 2,
+ 1,
+ ];
+
+ // Expr
+ #[cfg_attr(rustfmt, rustfmt_skip)]
+ foo( a, b , c)
+}