File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ fn rewrite_match_arm(
263263 false ,
264264 ) ?;
265265
266- let arrow_span = mk_sp ( arm. pats . last ( ) . unwrap ( ) . span . hi ( ) , arm. body . span . lo ( ) ) ;
266+ let arrow_span = mk_sp ( arm. pats . last ( ) . unwrap ( ) . span . hi ( ) , arm. body . span ( ) . lo ( ) ) ;
267267 rewrite_match_body (
268268 context,
269269 & arm. body ,
@@ -364,7 +364,8 @@ fn rewrite_match_body(
364364 shape. indent
365365 } ;
366366
367- let forbid_same_line = has_guard && pats_str. contains ( '\n' ) && !is_empty_block;
367+ let forbid_same_line =
368+ ( has_guard && pats_str. contains ( '\n' ) && !is_empty_block) || !body. attrs . is_empty ( ) ;
368369
369370 // Look for comments between `=>` and the start of the body.
370371 let arrow_comment = {
Original file line number Diff line number Diff line change @@ -217,3 +217,18 @@ fn stmt_expr_attributes() {
217217 #[ must_use]
218218 foo = false ;
219219}
220+
221+ // #3509
222+ fn issue3509 ( ) {
223+ match MyEnum {
224+ MyEnum :: Option1 if cfg ! ( target_os = "windows" ) =>
225+ #[ cfg ( target_os = "windows" ) ] {
226+ 1
227+ }
228+ }
229+ match MyEnum {
230+ MyEnum :: Option1 if cfg ! ( target_os = "windows" ) =>
231+ #[ cfg ( target_os = "windows" ) ]
232+ 1 ,
233+ }
234+ }
Original file line number Diff line number Diff line change @@ -252,3 +252,21 @@ fn stmt_expr_attributes() {
252252 #[ must_use]
253253 foo = false ;
254254}
255+
256+ // #3509
257+ fn issue3509 ( ) {
258+ match MyEnum {
259+ MyEnum :: Option1 if cfg ! ( target_os = "windows" ) =>
260+ #[ cfg ( target_os = "windows" ) ]
261+ {
262+ 1
263+ }
264+ }
265+ match MyEnum {
266+ MyEnum :: Option1 if cfg ! ( target_os = "windows" ) =>
267+ {
268+ #[ cfg( target_os = "windows" ) ]
269+ 1
270+ }
271+ }
272+ }
You can’t perform that action at this time.
0 commit comments