Skip to content

Commit e2f5d4a

Browse files
committed
Include empty 'stmts = []' in snapshots
1 parent fbd9809 commit e2f5d4a

File tree

7 files changed

+34
-14
lines changed

7 files changed

+34
-14
lines changed

codegen/src/snapshot.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ fn expand_impl_body(defs: &Definitions, node: &Node, name: &str, val: &Operand)
263263
let mut call = quote! {
264264
formatter.field(#f, #format);
265265
};
266-
if let Type::Vec(_) | Type::Punctuated(_) = ty {
266+
if node.ident == "Block" && f == "stmts" {
267+
// Format regardless of whether is_empty().
268+
} else if let Type::Vec(_) | Type::Punctuated(_) = ty {
267269
call = quote! {
268270
if !#val.#ident.is_empty() {
269271
#call

tests/debug/gen.rs

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_asyncness.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ fn test_async_fn() {
1818
generics: Generics,
1919
output: ReturnType::Default,
2020
},
21-
block: Block,
21+
block: Block {
22+
stmts: [],
23+
},
2224
}
2325
"###);
2426
}
@@ -32,7 +34,9 @@ fn test_async_closure() {
3234
asyncness: Some,
3335
output: ReturnType::Default,
3436
body: Expr::Block {
35-
block: Block,
37+
block: Block {
38+
stmts: [],
39+
},
3640
},
3741
}
3842
"###);

tests/test_generics.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ fn test_fn_precedence_in_where_clause() {
243243
},
244244
output: ReturnType::Default,
245245
},
246-
block: Block,
246+
block: Block {
247+
stmts: [],
248+
},
247249
}
248250
"###);
249251

tests/test_item.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ fn test_macro_variable_attr() {
3838
generics: Generics,
3939
output: ReturnType::Default,
4040
},
41-
block: Block,
41+
block: Block {
42+
stmts: [],
43+
},
4244
}
4345
"###);
4446
}
@@ -320,7 +322,9 @@ fn test_impl_trait_trailing_plus() {
320322
},
321323
),
322324
},
323-
block: Block,
325+
block: Block {
326+
stmts: [],
327+
},
324328
}
325329
"###);
326330
}

tests/test_shebang.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ fn test_basic() {
1818
generics: Generics,
1919
output: ReturnType::Default,
2020
},
21-
block: Block,
21+
block: Block {
22+
stmts: [],
23+
},
2224
},
2325
],
2426
}
@@ -55,7 +57,9 @@ fn test_comment() {
5557
generics: Generics,
5658
output: ReturnType::Default,
5759
},
58-
block: Block,
60+
block: Block {
61+
stmts: [],
62+
},
5963
},
6064
],
6165
}

tests/test_stmt.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ fn test_none_group() {
7878
generics: Generics,
7979
output: ReturnType::Default,
8080
},
81-
block: Block,
81+
block: Block {
82+
stmts: [],
83+
},
8284
})
8385
"###);
8486
}
@@ -251,7 +253,9 @@ fn test_early_parse_loop() {
251253
[
252254
Stmt::Expr(
253255
Expr::Loop {
254-
body: Block,
256+
body: Block {
257+
stmts: [],
258+
},
255259
},
256260
None,
257261
),
@@ -278,7 +282,9 @@ fn test_early_parse_loop() {
278282
ident: "a",
279283
},
280284
}),
281-
body: Block,
285+
body: Block {
286+
stmts: [],
287+
},
282288
},
283289
None,
284290
),

0 commit comments

Comments
 (0)