From b446e3173937f53a860c05db7dbfa8401fc9e81e Mon Sep 17 00:00:00 2001 From: sinkuu Date: Sat, 10 Sep 2016 13:08:32 +0900 Subject: [PATCH] Fix #1040 --- src/visitor.rs | 2 ++ tests/source/skip.rs | 18 ++++++++++++++++++ tests/target/skip.rs | 6 ++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/source/skip.rs diff --git a/src/visitor.rs b/src/visitor.rs index 237866ed9ec..13a4f6ec8a5 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -352,6 +352,7 @@ impl<'a> FmtVisitor<'a> { pub fn visit_trait_item(&mut self, ti: &ast::TraitItem) { if self.visit_attrs(&ti.attrs) { + self.push_rewrite(ti.span, None); return; } @@ -392,6 +393,7 @@ impl<'a> FmtVisitor<'a> { pub fn visit_impl_item(&mut self, ii: &ast::ImplItem) { if self.visit_attrs(&ii.attrs) { + self.push_rewrite(ii.span, None); return; } diff --git a/tests/source/skip.rs b/tests/source/skip.rs new file mode 100644 index 00000000000..21f080e9aba --- /dev/null +++ b/tests/source/skip.rs @@ -0,0 +1,18 @@ +// Test the skip attribute works + +#[rustfmt_skip] +fn foo() { badly; formatted; stuff +; } + +#[rustfmt_skip] +trait Foo +{ +fn foo( +); +} + +impl LateLintPass for UsedUnderscoreBinding { + #[cfg_attr(rustfmt, rustfmt_skip)] + fn check_expr() { // comment + } +} diff --git a/tests/target/skip.rs b/tests/target/skip.rs index bd5a132cced..21f080e9aba 100644 --- a/tests/target/skip.rs +++ b/tests/target/skip.rs @@ -10,3 +10,9 @@ trait Foo fn foo( ); } + +impl LateLintPass for UsedUnderscoreBinding { + #[cfg_attr(rustfmt, rustfmt_skip)] + fn check_expr() { // comment + } +}