@@ -75,6 +75,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
7575
7676 match * substr. fields {
7777 Struct ( ref fields) | EnumMatching ( _, _, ref fields) => {
78+
7879 if fields. is_empty ( ) || fields[ 0 ] . name . is_none ( ) {
7980 // tuple struct/"normal" variant
8081 expr = cx. expr_method_call ( span,
@@ -83,11 +84,14 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
8384 vec ! [ name] ) ;
8485
8586 for field in fields {
87+ // Use double indirection to make sure this works for unsized types
88+ let field = cx. expr_addr_of ( field. span , field. self_ . clone ( ) ) ;
89+ let field = cx. expr_addr_of ( field. span , field) ;
90+
8691 expr = cx. expr_method_call ( span,
8792 expr,
8893 token:: str_to_ident ( "field" ) ,
89- vec ! [ cx. expr_addr_of( field. span,
90- field. self_. clone( ) ) ] ) ;
94+ vec ! [ field] ) ;
9195 }
9296 } else {
9397 // normal struct/struct variant
@@ -100,12 +104,14 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
100104 let name = cx. expr_lit ( field. span , ast:: Lit_ :: LitStr (
101105 token:: get_ident ( field. name . clone ( ) . unwrap ( ) ) ,
102106 ast:: StrStyle :: CookedStr ) ) ;
107+
108+ // Use double indirection to make sure this works for unsized types
109+ let field = cx. expr_addr_of ( field. span , field. self_ . clone ( ) ) ;
110+ let field = cx. expr_addr_of ( field. span , field) ;
103111 expr = cx. expr_method_call ( span,
104112 expr,
105113 token:: str_to_ident ( "field" ) ,
106- vec ! [ name,
107- cx. expr_addr_of( field. span,
108- field. self_. clone( ) ) ] ) ;
114+ vec ! [ name, field] ) ;
109115 }
110116 }
111117 }
0 commit comments