about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-19 07:38:24 +0000
committerbors <bors@rust-lang.org>2015-05-19 07:38:24 +0000
commit9c47ebb00abecf2b2fe7fa0b0ea059c8327b40f2 (patch)
tree493b85963a6c35be14df7e7673d9b213eae63206 /src/libsyntax
parentb301e02f37127da993dd2cf370aa1066d48b042e (diff)
parent1973ee479d83f06aea2366963d5ec092d8c591dc (diff)
downloadrust-9c47ebb00abecf2b2fe7fa0b0ea059c8327b40f2.tar.gz
rust-9c47ebb00abecf2b2fe7fa0b0ea059c8327b40f2.zip
Auto merge of #25550 - sfackler:derive-debug-unsized, r=alexcrichton
Closes #25394 
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/deriving/show.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs
index 518bd161c1e..9dcbd2d1f70 100644
--- a/src/libsyntax/ext/deriving/show.rs
+++ b/src/libsyntax/ext/deriving/show.rs
@@ -75,6 +75,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
 
     match *substr.fields {
         Struct(ref fields) | EnumMatching(_, _, ref fields) => {
+
             if fields.is_empty() || fields[0].name.is_none() {
                 // tuple struct/"normal" variant
                 expr = cx.expr_method_call(span,
@@ -83,11 +84,14 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
                                            vec![name]);
 
                 for field in fields {
+                    // Use double indirection to make sure this works for unsized types
+                    let field = cx.expr_addr_of(field.span, field.self_.clone());
+                    let field = cx.expr_addr_of(field.span, field);
+
                     expr = cx.expr_method_call(span,
                                                expr,
                                                token::str_to_ident("field"),
-                                               vec![cx.expr_addr_of(field.span,
-                                                                    field.self_.clone())]);
+                                               vec![field]);
                 }
             } else {
                 // normal struct/struct variant
@@ -100,12 +104,14 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
                     let name = cx.expr_lit(field.span, ast::Lit_::LitStr(
                             token::get_ident(field.name.clone().unwrap()),
                             ast::StrStyle::CookedStr));
+
+                    // Use double indirection to make sure this works for unsized types
+                    let field = cx.expr_addr_of(field.span, field.self_.clone());
+                    let field = cx.expr_addr_of(field.span, field);
                     expr = cx.expr_method_call(span,
                                                expr,
                                                token::str_to_ident("field"),
-                                               vec![name,
-                                                    cx.expr_addr_of(field.span,
-                                                                    field.self_.clone())]);
+                                               vec![name, field]);
                 }
             }
         }