From 3bc879e76bb428d42831179829606dede0c84f94 Mon Sep 17 00:00:00 2001 From: Camelid Date: Sun, 21 Feb 2021 17:19:43 -0800 Subject: [PATCH] rustdoc: Add static size assertion for `Context` It's cloned a lot, so we don't want it to grow in size unexpectedly. Only run the assert on x86-64 since the size is architecture-dependent. --- src/librustdoc/html/render/context.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index e8d323b9af1..50d160ccd82 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -70,6 +70,10 @@ crate struct Context<'tcx> { pub(super) cache: Rc, } +// `Context` is cloned a lot, so we don't want the size to grow unexpectedly. +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(Context<'_>, 72); + impl<'tcx> Context<'tcx> { pub(super) fn path(&self, filename: &str) -> PathBuf { // We use splitn vs Path::extension here because we might get a filename