diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2023-03-03 04:54:42 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2023-03-04 01:46:26 +0100 |
| commit | 1ccb1de5992dce38f7b8a941ee390a4f9aee1159 (patch) | |
| tree | 58114c1a82db4415746562f0c9bc27a6ede4122f | |
| parent | 13471d3b2046cce78181dde6cfc146c09f55e29e (diff) | |
| download | rust-1ccb1de5992dce38f7b8a941ee390a4f9aee1159.tar.gz rust-1ccb1de5992dce38f7b8a941ee390a4f9aee1159.zip | |
Place size limits on query keys and values
| -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 2bc51baf879..9d41e4af959 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -250,6 +250,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>>) |
