Skip to content

Commit f20177a

Browse files
committed
Add a test for the size of important types.
A lot of these are large! Lots of room for improvement in the future.
1 parent 31d0d21 commit f20177a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/rustdoc-json-types/tests.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,28 @@ fn test_union_info_roundtrip() {
3838
let decoded: ItemEnum = bincode::deserialize(&encoded).unwrap();
3939
assert_eq!(u, decoded);
4040
}
41+
42+
// The memory used by a `Crate` can get large. These types are the ones that
43+
// contribute the most to its size.
44+
#[test]
45+
#[cfg(target_pointer_width = "64")]
46+
fn test_type_sizes() {
47+
// tidy-alphabetical-start
48+
assert_eq!(size_of::<AssocItemConstraint>(), 208);
49+
assert_eq!(size_of::<Crate>(), 184);
50+
assert_eq!(size_of::<ExternalCrate>(), 48);
51+
assert_eq!(size_of::<FunctionPointer>(), 168);
52+
assert_eq!(size_of::<GenericArg>(), 80);
53+
assert_eq!(size_of::<GenericArgs>(), 104);
54+
assert_eq!(size_of::<GenericBound>(), 72);
55+
assert_eq!(size_of::<GenericParamDef>(), 136);
56+
assert_eq!(size_of::<Impl>(), 304);
57+
assert_eq!(size_of::<Item>(), 552);
58+
assert_eq!(size_of::<ItemSummary>(), 32);
59+
assert_eq!(size_of::<PolyTrait>(), 64);
60+
assert_eq!(size_of::<PreciseCapturingArg>(), 32);
61+
assert_eq!(size_of::<TargetFeature>(), 80);
62+
assert_eq!(size_of::<Type>(), 80);
63+
assert_eq!(size_of::<WherePredicate>(), 160);
64+
// tidy-alphabetical-end
65+
}

0 commit comments

Comments
 (0)