diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9da582a6..a12a2523 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: override: true - name: Downgrade phf to a version compatible with the MSRV - run: cargo update --package phf:0.11.0 --precise 0.10.1 + run: cargo update --package phf --precise 0.10.1 if: matrix.toolchain == '1.40.0' - name: Cargo build diff --git a/build.rs b/build.rs index 07a72ffe..89407f6f 100644 --- a/build.rs +++ b/build.rs @@ -42,5 +42,9 @@ fn main() { println!("cargo:rustc-cfg=rustc_has_pr45225") } + if std::mem::size_of::>() == 24 { + println!("cargo:rustc-cfg=rustc_has_better_cow_layout") + } + codegen::main(); } diff --git a/src/size_of_tests.rs b/src/size_of_tests.rs index 7e39e4c6..f5a63673 100644 --- a/src/size_of_tests.rs +++ b/src/size_of_tests.rs @@ -38,7 +38,7 @@ macro_rules! size_of_test { // Some of these assume 64-bit size_of_test!(token, Token, 32); -size_of_test!(std_cow_str, Cow<'static, str>, 32); +size_of_test!(std_cow_str, Cow<'static, str>, if cfg!(rustc_has_better_cow_layout) { 24 } else { 32 }); size_of_test!(cow_rc_str, CowRcStr, 16); size_of_test!(tokenizer, crate::tokenizer::Tokenizer, 72); @@ -51,9 +51,15 @@ 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!(basic_parse_error, crate::BasicParseError, if cfg!(rustc_has_better_cow_layout) { 40 } else { 48 }); size_of_test!( parse_error_lower_bound, crate::ParseError<()>, - if cfg!(rustc_has_pr45225) { 48 } else { 56 } + if cfg!(rustc_has_better_cow_layout) { + 40 + } else if cfg!(rustc_has_pr45225) { + 48 + } else { + 56 + } );