diff --git a/src/visitor.rs b/src/visitor.rs index d37bf760a262..b0d5a91f1d80 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -342,6 +342,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; } @@ -385,6 +386,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 000000000000..21f080e9abab --- /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 bd5a132cced0..21f080e9abab 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 + } +}