diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-11 15:43:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-11 15:43:14 +0100 |
| commit | 1909d933d50799b7ba13fa28b953f400dd18ca61 (patch) | |
| tree | 9091ce78886e5595efbbd582c040a5be330e882f | |
| parent | 9c38ae5653041af5384eca797e6148109d5661b8 (diff) | |
| parent | 1ccb1de5992dce38f7b8a941ee390a4f9aee1159 (diff) | |
Rollup merge of #108690 - Zoxc:query-size-limits, r=cjgillot
Place size limits on query keys and values This just prevents these from growing accidentally too large. I'm not sure if there's an easy way to also print the actual size too.
| -rw-r--r-- | compiler/rustc_middle/src/ty/query.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index 9548be4c138..963cb29ffb3 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -252,6 +252,36 @@ macro_rules! define_callbacks { )* } + $( + // Ensure that keys grow no larger than 64 bytes + #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] + const _: () = { + if mem::size_of::<query_keys::$name<'static>>() > 64 { + panic!("{}", concat!( + "the query `", + stringify!($name), + "` has a key type `", + stringify!($($K)*), + "` that is too large" + )); + } + }; + + // Ensure that values grow no larger than 64 bytes + #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] + const _: () = { + if mem::size_of::<query_values::$name<'static>>() > 64 { + panic!("{}", concat!( + "the query `", + stringify!($name), + "` has a value type `", + stringify!($V), + "` that is too large" + )); + } + }; + )* + pub struct QueryArenas<'tcx> { $($(#[$attr])* pub $name: query_if_arena!([$($modifiers)*] (WorkerLocal<TypedArena<<$V as Deref>::Target>>) |
