We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0d278ca commit ad50f33Copy full SHA for ad50f33
src/libsyntax_ext/deriving/encodable.rs
@@ -228,13 +228,13 @@ fn encodable_substructure(cx: &mut ExtCtxt,
228
}
229
230
// unit structs have no fields and need to return Ok()
231
- if stmts.is_empty() {
+ let blk = if stmts.is_empty() {
232
let ok = cx.expr_ok(trait_span, cx.expr_tuple(trait_span, vec![]));
233
- let ret_ok = cx.expr(trait_span, ExprKind::Ret(Some(ok)));
234
- stmts.push(cx.stmt_expr(ret_ok));
235
- }
+ cx.lambda1(trait_span, ok, blkarg)
+ } else {
+ cx.lambda_stmts_1(trait_span, stmts, blkarg)
236
+ };
237
- let blk = cx.lambda_stmts_1(trait_span, stmts, blkarg);
238
cx.expr_method_call(trait_span,
239
encoder,
240
cx.ident_of("emit_struct"),
0 commit comments