diff options
| author | Nick Cameron <nrc@ncameron.org> | 2016-10-12 17:48:20 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-12 17:48:20 +1300 |
| commit | 724f75eaa5d5eb72baabab7bc3ec3b8ed0d52815 (patch) | |
| tree | be366fd04c241a988cd1a4698c05d2918271e279 /src | |
| parent | 8ffb581563e65129dcd07add9113e42e5e0a2951 (diff) | |
| parent | c4a7a7108e155dfb3ada7b0e7def78962f5d6263 (diff) | |
Merge pull request #1182 from philipc/issue-1149
Preserve macro formatting if we can't rewrite it
Diffstat (limited to 'src')
| -rw-r--r-- | src/macros.rs | 6 | ||||
| -rw-r--r-- | src/visitor.rs | 9 |
2 files changed, 2 insertions, 13 deletions
diff --git a/src/macros.rs b/src/macros.rs index 9c275716ad2..dd301ad9de7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -30,7 +30,6 @@ use codemap::SpanUtils; use rewrite::{Rewrite, RewriteContext}; use expr::{rewrite_call, rewrite_array}; use comment::{FindUncommented, contains_comment}; -use utils::wrap_str; const FORCED_BRACKET_MACROS: &'static [&'static str] = &["vec!"]; @@ -141,10 +140,7 @@ pub fn rewrite_macro(mac: &ast::Mac, } MacroStyle::Braces => { // Skip macro invocations with braces, for now. - wrap_str(context.snippet(mac.span), - context.config.max_width, - width, - offset) + None } } } diff --git a/src/visitor.rs b/src/visitor.rs index b0d5a91f1d8..f05fcefdfe8 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -66,7 +66,6 @@ impl<'a> FmtVisitor<'a> { } ast::StmtKind::Mac(ref mac) => { let (ref mac, _macro_style, _) = **mac; - self.format_missing_with_indent(source!(self, stmt.span).lo); self.visit_mac(mac, None); } } @@ -281,7 +280,6 @@ impl<'a> FmtVisitor<'a> { self.format_mod(module, &item.vis, item.span, item.ident); } ast::ItemKind::Mac(ref mac) => { - self.format_missing_with_indent(source!(self, item.span).lo); self.visit_mac(mac, Some(item.ident)); } ast::ItemKind::ForeignMod(ref foreign_mod) => { @@ -418,7 +416,6 @@ impl<'a> FmtVisitor<'a> { self.push_rewrite(ii.span, rewrite); } ast::ImplItemKind::Macro(ref mac) => { - self.format_missing_with_indent(source!(self, ii.span).lo); self.visit_mac(mac, Some(ii.ident)); } } @@ -428,11 +425,7 @@ impl<'a> FmtVisitor<'a> { // 1 = ; let width = self.config.max_width - self.block_indent.width() - 1; let rewrite = rewrite_macro(mac, ident, &self.get_context(), width, self.block_indent); - - if let Some(res) = rewrite { - self.buffer.push_str(&res); - self.last_pos = source!(self, mac.span).hi; - } + self.push_rewrite(mac.span, rewrite); } fn push_rewrite(&mut self, span: Span, rewrite: Option<String>) { |
