File tree 3 files changed +36
-2
lines changed
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(
263
263
false ,
264
264
) ?;
265
265
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 ( ) ) ;
267
267
rewrite_match_body (
268
268
context,
269
269
& arm. body ,
@@ -364,7 +364,8 @@ fn rewrite_match_body(
364
364
shape. indent
365
365
} ;
366
366
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 ( ) ;
368
369
369
370
// Look for comments between `=>` and the start of the body.
370
371
let arrow_comment = {
Original file line number Diff line number Diff line change @@ -217,3 +217,18 @@ fn stmt_expr_attributes() {
217
217
#[ must_use]
218
218
foo = false ;
219
219
}
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() {
252
252
#[ must_use]
253
253
foo = false ;
254
254
}
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