use crate::cow_rc_str::CowRcStr;
use crate::tokenizer::Token;
use std::borrow::Cow;
macro_rules! size_of_test {
($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!()
)
}
}
};
}
size_of_test!(token, Token, 32);
size_of_test!(std_cow_str, Cow<'static, str>, 32);
size_of_test!(cow_rc_str, CowRcStr, 16);
size_of_test!(tokenizer, crate::tokenizer::Tokenizer, 72);
size_of_test!(
parser_input,
crate::parser::ParserInput,
if cfg!(rustc_has_pr45225) { 136 } else { 144 }
);
size_of_test!(parser, crate::parser::Parser, 16);
size_of_test!(source_position, crate::SourcePosition, 8);
size_of_test!(parser_state, crate::ParserState, 24);
size_of_test!(basic_parse_error, crate::BasicParseError, 48);
size_of_test!(
parse_error_lower_bound,
crate::ParseError<()>,
if cfg!(rustc_has_pr45225) { 48 } else { 56 }
);