diff --git a/src/expr.rs b/src/expr.rs index 4a6888e951e2..c9f684c6c101 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -898,8 +898,7 @@ impl Rewrite for ast::Arm { attr_visitor.last_pos = attrs[0].span.lo; if attr_visitor.visit_attrs(attrs) { // Attributes included a skip instruction. - let snippet = context.snippet(mk_sp(attrs[0].span.lo, body.span.hi)); - return Some(snippet); + return None; } attr_visitor.format_missing(pats[0].span.lo); attr_visitor.buffer.to_string() diff --git a/tests/source/match.rs b/tests/source/match.rs index b4d35cb38154..3723424317b8 100644 --- a/tests/source/match.rs +++ b/tests/source/match.rs @@ -100,6 +100,14 @@ fn matches() { } } +fn match_skip() { + let _ = match Some(1) { + #[rustfmt_skip] + Some( n ) => n, + None => 1, + }; +} + fn issue339() { match a { b => {} diff --git a/tests/target/match.rs b/tests/target/match.rs index 2c238ea8a685..94f9bf8ae5e4 100644 --- a/tests/target/match.rs +++ b/tests/target/match.rs @@ -115,6 +115,14 @@ fn matches() { } } +fn match_skip() { + let _ = match Some(1) { + #[rustfmt_skip] + Some( n ) => n, + None => 1, + }; +} + fn issue339() { match a { b => {}