mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
This reverts commit 8e15389cae
.
This commit is contained in:
parent
8e15389cae
commit
d6ae8dc112
152 changed files with 4622 additions and 5862 deletions
|
@ -2,13 +2,33 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
pub use static_assertions::const_assert_eq;
|
||||
|
||||
/// Asserts the size of a type at compile time.
|
||||
#[macro_export]
|
||||
macro_rules! size_of_test {
|
||||
($t: ty, $expected_size: expr) => {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
$crate::const_assert_eq!(std::mem::size_of::<$t>(), $expected_size);
|
||||
($testname: ident, $t: ty, $expected_size: expr) => {
|
||||
#[test]
|
||||
fn $testname() {
|
||||
let new = ::std::mem::size_of::<$t>();
|
||||
let old = $expected_size;
|
||||
if new < old {
|
||||
panic!(
|
||||
"Your changes have decreased the stack size of {} from {} to {}. \
|
||||
Good work! Please update the expected size in {}.",
|
||||
stringify!($t),
|
||||
old,
|
||||
new,
|
||||
file!()
|
||||
)
|
||||
} else if new > old {
|
||||
panic!(
|
||||
"Your changes have increased the stack size of {} from {} to {}. \
|
||||
Please consider choosing a design which avoids this increase. \
|
||||
If you feel that the increase is necessary, update the size in {}.",
|
||||
stringify!($t),
|
||||
old,
|
||||
new,
|
||||
file!()
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue