diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-06-14 22:01:12 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-06-21 13:50:51 +1000 |
| commit | 2b5fd9a3074d0ac5f9e07d135e2cb9d83f270da7 (patch) | |
| tree | 07ec322fa8557d9cfd9f64ad33656abdf00b6291 | |
| parent | 15c701fbc995eb6c5b3a86021c18185f8eee020d (diff) | |
| download | rust-2b5fd9a3074d0ac5f9e07d135e2cb9d83f270da7.tar.gz rust-2b5fd9a3074d0ac5f9e07d135e2cb9d83f270da7.zip | |
rustdoc_json: Add static asserts for the size of important types.
A lot of these are large! Lots of room for improvement in the future.
| -rw-r--r-- | src/librustdoc/json/mod.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 61493c1ed70..f5064ae55b8 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -377,3 +377,33 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { } } } + +// Some nodes are used a lot. Make sure they don't unintentionally get bigger. +// +// These assertions are here, not in `src/rustdoc-json-types/lib.rs` where the types are defined, +// because we have access to `static_assert_size` here. +#[cfg(target_pointer_width = "64")] +mod size_asserts { + use rustc_data_structures::static_assert_size; + + use super::types::*; + // tidy-alphabetical-start + static_assert_size!(AssocItemConstraint, 208); + static_assert_size!(Crate, 184); + static_assert_size!(ExternalCrate, 48); + static_assert_size!(FunctionPointer, 168); + static_assert_size!(GenericArg, 80); + static_assert_size!(GenericArgs, 104); + static_assert_size!(GenericBound, 72); + static_assert_size!(GenericParamDef, 136); + static_assert_size!(Impl, 304); + // `Item` contains a `PathBuf`, which is different sizes on different OSes. + static_assert_size!(Item, 528 + size_of::<std::path::PathBuf>()); + static_assert_size!(ItemSummary, 32); + static_assert_size!(PolyTrait, 64); + static_assert_size!(PreciseCapturingArg, 32); + static_assert_size!(TargetFeature, 80); + static_assert_size!(Type, 80); + static_assert_size!(WherePredicate, 160); + // tidy-alphabetical-end +} |
