Skip to content

Commit a3f3c4a

Browse files
committed
Some refactoring in deriving/debug.rs
1 parent 4e8e607 commit a3f3c4a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/libsyntax_ext/deriving/debug.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
6161
// build fmt.debug_struct(<name>).field(<fieldname>, &<fieldval>)....build()
6262
// or fmt.debug_tuple(<name>).field(&<fieldval>)....build()
6363
// based on the "shape".
64-
let ident = match *substr.fields {
65-
Struct(..) => substr.type_ident,
66-
EnumMatching(_, v, _) => v.node.name,
64+
let (ident, is_struct) = match *substr.fields {
65+
Struct(vdata, _) => (substr.type_ident, vdata.is_struct()),
66+
EnumMatching(_, v, _) => (v.node.name, v.node.data.is_struct()),
6767
EnumNonMatchingCollapsed(..) | StaticStruct(..) | StaticEnum(..) => {
6868
cx.span_bug(span, "nonsensical .fields in `#[derive(Debug)]`")
6969
}
@@ -76,11 +76,6 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
7676
let builder_expr = cx.expr_ident(span, builder.clone());
7777

7878
let fmt = substr.nonself_args[0].clone();
79-
let is_struct = match *substr.fields {
80-
Struct(vdata, _) => vdata,
81-
EnumMatching(_, v, _) => &v.node.data,
82-
_ => unreachable!()
83-
}.is_struct();
8479

8580
let stmts = match *substr.fields {
8681
Struct(_, ref fields) | EnumMatching(_, _, ref fields) => {

0 commit comments

Comments
 (0)