diff options
Diffstat (limited to 'compiler/rustc_session/src/code_stats.rs')
| -rw-r--r-- | compiler/rustc_session/src/code_stats.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_session/src/code_stats.rs b/compiler/rustc_session/src/code_stats.rs index 2553df33cc7..93839fa1186 100644 --- a/compiler/rustc_session/src/code_stats.rs +++ b/compiler/rustc_session/src/code_stats.rs @@ -44,6 +44,10 @@ pub struct FieldInfo { pub offset: u64, pub size: u64, pub align: u64, + /// Name of the type of this field. + /// Present only if the creator thought that this would be important for identifying the field, + /// typically because the field name is uninformative. + pub type_name: Option<Symbol>, } #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] @@ -192,7 +196,7 @@ impl CodeStats { fields.sort_by_key(|f| (f.offset, f.size)); for field in fields { - let FieldInfo { kind, ref name, offset, size, align } = field; + let FieldInfo { kind, ref name, offset, size, align, type_name } = field; if offset > min_offset { let pad = offset - min_offset; @@ -201,21 +205,27 @@ impl CodeStats { if offset < min_offset { // If this happens it's probably a union. - println!( + print!( "print-type-size {indent}{kind} `.{name}`: {size} bytes, \ offset: {offset} bytes, \ alignment: {align} bytes" ); } else if info.packed || offset == min_offset { - println!("print-type-size {indent}{kind} `.{name}`: {size} bytes"); + print!("print-type-size {indent}{kind} `.{name}`: {size} bytes"); } else { // Include field alignment in output only if it caused padding injection - println!( + print!( "print-type-size {indent}{kind} `.{name}`: {size} bytes, \ alignment: {align} bytes" ); } + if let Some(type_name) = type_name { + println!(", type: {type_name}"); + } else { + println!(); + } + min_offset = offset + size; } } |
