@@ -19,8 +19,26 @@ pub enum SizeKind {
19
19
Min ,
20
20
}
21
21
22
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
23
+ pub enum FieldKind {
24
+ AdtField ,
25
+ Upvar ,
26
+ GeneratorLocal ,
27
+ }
28
+
29
+ impl std:: fmt:: Display for FieldKind {
30
+ fn fmt ( & self , w : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
31
+ match self {
32
+ FieldKind :: AdtField => write ! ( w, "field" ) ,
33
+ FieldKind :: Upvar => write ! ( w, "upvar" ) ,
34
+ FieldKind :: GeneratorLocal => write ! ( w, "local" ) ,
35
+ }
36
+ }
37
+ }
38
+
22
39
#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
23
40
pub struct FieldInfo {
41
+ pub kind : FieldKind ,
24
42
pub name : Symbol ,
25
43
pub offset : u64 ,
26
44
pub size : u64 ,
@@ -145,7 +163,7 @@ impl CodeStats {
145
163
fields. sort_by_key ( |f| ( f. offset , f. size ) ) ;
146
164
147
165
for field in fields {
148
- let FieldInfo { ref name, offset, size, align } = field;
166
+ let FieldInfo { kind , ref name, offset, size, align } = field;
149
167
150
168
if offset > min_offset {
151
169
let pad = offset - min_offset;
@@ -155,16 +173,16 @@ impl CodeStats {
155
173
if offset < min_offset {
156
174
// If this happens it's probably a union.
157
175
println ! (
158
- "print-type-size {indent}field `.{name}`: {size} bytes, \
176
+ "print-type-size {indent}{kind} `.{name}`: {size} bytes, \
159
177
offset: {offset} bytes, \
160
178
alignment: {align} bytes"
161
179
) ;
162
180
} else if info. packed || offset == min_offset {
163
- println ! ( "print-type-size {indent}field `.{name}`: {size} bytes" ) ;
181
+ println ! ( "print-type-size {indent}{kind} `.{name}`: {size} bytes" ) ;
164
182
} else {
165
183
// Include field alignment in output only if it caused padding injection
166
184
println ! (
167
- "print-type-size {indent}field `.{name}`: {size} bytes, \
185
+ "print-type-size {indent}{kind} `.{name}`: {size} bytes, \
168
186
alignment: {align} bytes"
169
187
) ;
170
188
}
0 commit comments