@@ -19,8 +19,26 @@ pub enum SizeKind {
1919 Min ,
2020}
2121
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+
2239#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
2340pub struct FieldInfo {
41+ pub kind : FieldKind ,
2442 pub name : Symbol ,
2543 pub offset : u64 ,
2644 pub size : u64 ,
@@ -145,7 +163,7 @@ impl CodeStats {
145163 fields. sort_by_key ( |f| ( f. offset , f. size ) ) ;
146164
147165 for field in fields {
148- let FieldInfo { ref name, offset, size, align } = field;
166+ let FieldInfo { kind , ref name, offset, size, align } = field;
149167
150168 if offset > min_offset {
151169 let pad = offset - min_offset;
@@ -155,16 +173,16 @@ impl CodeStats {
155173 if offset < min_offset {
156174 // If this happens it's probably a union.
157175 println ! (
158- "print-type-size {indent}field `.{name}`: {size} bytes, \
176+ "print-type-size {indent}{kind} `.{name}`: {size} bytes, \
159177 offset: {offset} bytes, \
160178 alignment: {align} bytes"
161179 ) ;
162180 } 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" ) ;
164182 } else {
165183 // Include field alignment in output only if it caused padding injection
166184 println ! (
167- "print-type-size {indent}field `.{name}`: {size} bytes, \
185+ "print-type-size {indent}{kind} `.{name}`: {size} bytes, \
168186 alignment: {align} bytes"
169187 ) ;
170188 }
0 commit comments