@@ -75,6 +75,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
75
75
76
76
match * substr. fields {
77
77
Struct ( ref fields) | EnumMatching ( _, _, ref fields) => {
78
+
78
79
if fields. is_empty ( ) || fields[ 0 ] . name . is_none ( ) {
79
80
// tuple struct/"normal" variant
80
81
expr = cx. expr_method_call ( span,
@@ -83,11 +84,14 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
83
84
vec ! [ name] ) ;
84
85
85
86
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
+
86
91
expr = cx. expr_method_call ( span,
87
92
expr,
88
93
token:: str_to_ident ( "field" ) ,
89
- vec ! [ cx. expr_addr_of( field. span,
90
- field. self_. clone( ) ) ] ) ;
94
+ vec ! [ field] ) ;
91
95
}
92
96
} else {
93
97
// normal struct/struct variant
@@ -100,12 +104,14 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
100
104
let name = cx. expr_lit ( field. span , ast:: Lit_ :: LitStr (
101
105
token:: get_ident ( field. name . clone ( ) . unwrap ( ) ) ,
102
106
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) ;
103
111
expr = cx. expr_method_call ( span,
104
112
expr,
105
113
token:: str_to_ident ( "field" ) ,
106
- vec ! [ name,
107
- cx. expr_addr_of( field. span,
108
- field. self_. clone( ) ) ] ) ;
114
+ vec ! [ name, field] ) ;
109
115
}
110
116
}
111
117
}
0 commit comments