From 44e9013f6496a806040dc04b03c8d1d9968dd809 Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Tue, 19 Oct 2021 15:16:45 +0200 Subject: [PATCH] tokio: assert platform-minimum requirements at build time (#3797) --- tokio/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs index fc86ccc08..7064c741e 100644 --- a/tokio/src/lib.rs +++ b/tokio/src/lib.rs @@ -350,6 +350,19 @@ //! //! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section +// Test that pointer width is compatible. This asserts that e.g. usize is at +// least 32 bits, which a lot of components in Tokio currently assumes. +// +// TODO: improve once we have MSRV access to const eval to make more flexible. +#[cfg(not(any( + target_pointer_width = "32", + target_pointer_width = "64", + target_pointer_width = "128" +)))] +compile_error! { + "Tokio requires the platform pointer width to be 32, 64, or 128 bits" +} + // Includes re-exports used by macros. // // This module is not intended to be part of the public API. In general, any