From a186f885bf108411fcf463d825d9d47d485201fd Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 21 Jul 2023 20:09:10 -0700 Subject: [PATCH 1/2] Work around ICE in rustc: the naive layout isn't refined by the actual layout --- src/lib.rs | 4 +++- tests/test.rs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 398a181..ab14180 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -246,7 +246,9 @@ document_iter! { mod void_iter { enum Void {} - pub struct Iter([*const T; 0], Void); + // https://github.com/rust-lang/rust/issues/113941 + const WORK_AROUND_RUST_ISSUE_113941: usize = 1; + pub struct Iter([*const T; WORK_AROUND_RUST_ISSUE_113941], Void); unsafe impl Send for Iter {} unsafe impl Sync for Iter {} diff --git a/tests/test.rs b/tests/test.rs index 4744cec..050299b 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -4,6 +4,7 @@ struct Thing(usize); #[test] fn test_iter() { - assert_eq!(0, mem::size_of::>()); - assert_eq!(1, mem::align_of::>()); + // https://github.com/rust-lang/rust/issues/113941 + assert_eq!(16, mem::size_of::>()); // FIXME + assert_eq!(8, mem::align_of::>()); // FIXME } From 51412b3031dbc19b0ddfc17c89746e0ad3b9bec7 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 21 Jul 2023 20:13:07 -0700 Subject: [PATCH 2/2] Temporarily disable -Zrandomize-layout due to rustc ICE --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3b16a2..27ac4f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: toolchain: ${{matrix.rust}} - name: Enable type layout randomization run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV - if: startsWith(matrix.rust, 'nightly') + if: startsWith(matrix.rust, 'nightly') && false # FIXME https://github.com/rust-lang/rust/issues/113941 - run: cargo test clippy: