From 51815effbef8777136c88ab146f3638c5fb4de23 Mon Sep 17 00:00:00 2001 From: Sheng Hau Date: Thu, 4 May 2017 00:10:03 +0800 Subject: [PATCH] Format macros in trait item position --- src/visitor.rs | 4 ++-- tests/source/issue-1158.rs | 3 +++ tests/target/issue-1158.rs | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tests/source/issue-1158.rs create mode 100644 tests/target/issue-1158.rs diff --git a/src/visitor.rs b/src/visitor.rs index 86fb1bce9d9..00b2b6c2392 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -382,8 +382,8 @@ impl<'a> FmtVisitor<'a> { self.block_indent); self.push_rewrite(ti.span, rewrite); } - ast::TraitItemKind::Macro(..) => { - // FIXME(#1158) Macros in trait item position + ast::TraitItemKind::Macro(ref mac) => { + self.visit_mac(mac, Some(ti.ident), MacroPosition::Item); } } } diff --git a/tests/source/issue-1158.rs b/tests/source/issue-1158.rs new file mode 100644 index 00000000000..6742e17459e --- /dev/null +++ b/tests/source/issue-1158.rs @@ -0,0 +1,3 @@ +trait T { + itemmacro!(this, is.now() .formatted(yay)); +} diff --git a/tests/target/issue-1158.rs b/tests/target/issue-1158.rs new file mode 100644 index 00000000000..2abfa5a29f2 --- /dev/null +++ b/tests/target/issue-1158.rs @@ -0,0 +1,3 @@ +trait T { + itemmacro!(this, is.now().formatted(yay)); +}